FMINCON does not optimize error function
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Manni0404
am 16 Mär. 2017
Bearbeitet: Walter Roberson
am 16 Mär. 2017
I am trying to minimize the error between two price functions using the mean squared error. I want to minimize the error by changing five variables used in the first price function. After the optimization ran, the new error I get is huge (in the millions, I would expect getting a small decimal number) and the problem does not seem to be optimized at all. Someone please tell me what's wrong.
This is my code:
Z = [a, b, c, d, e];
MSE = @(Z) (immse(price1(Z(1),Z(2),Z(3),Z(4),Z(5)),price2));
initial =[0.1, 0.1, 0.1, 0.1, 0.1];
lb = [0, 0, 0, 0, 0];
ub = [1, 1, 1, 1, 1];
nonlcon = @myconstraint;
Z1 = fmincon(MSE,initial,[],[],[],[],lb,ub,nonlcon)
0 Kommentare
Akzeptierte Antwort
Alan Weiss
am 16 Mär. 2017
Without seeing your pricee1 function or your price2 vector or your nonlinear constraint function, it is impossible to guess what is going on.
What do you get when you evaluate MSE(initial) and [c,ceq] = myconstraint(initial)? That might give you an idea about what is happening. But again, without seeing your functions, I have no idea what is happening.
Alan Weiss
MATLAB mathematical toolbox documentation
1 Kommentar
John D'Errico
am 16 Mär. 2017
Bearbeitet: John D'Errico
am 16 Mär. 2017
+1. A rule that I strongly suggest for optimization have is ALWAYS test/verify your objective function. Evaluate it at the start point. Verify that if you try different values, you get different results. Is the objective function returning something that seems reasonable? Do the same for your constraint function. Think about what you see. Only then should you throw it at an optimizer.
Next, the first time through an optimization, turn the display flag to show as much output as possible. Again, verify that it is doing something that seems intelligent to you.
Even if for some unknown reason you did not do these things before you saw a problem, then it is even more reason to have done these tests. Is it possible to do something more than always?
One other thing to consider: is your start point a feasible one? Or does it fail to satisfy the constraints? If they are not satisfied, then fmincon will need to look for a point that is feasible, and it may need to go a long way.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!