How to verify my optimal solution given by Matlab
3 views (last 30 days)
Show older comments
Hello,
I am trying to verify that the solution that Matlab provides as my optimal objective value (fval) is correct.
For some reason when I put the values that matlab generates back into my problem just to verify that the same optimal solution will be returned, I can never get the same answer. Is there a logical reason for this or am I doing something wrong?
For instance, My Objective function may be: 4x + 6t + 8q and matlab may return the values: 3,4, and 5 respectively along with an fval as the optimal solution. But when I try and put the values 3,4, and 5 back into my function to verify the answer, I don't get the same solution.
Of course, my actual problem is way more complicated than the above example, but any type of explanation would help. I am trying to publish this code in a book.
Thanks, Kam
3 Comments
Matt J
on 24 Oct 2012
Walter's suggestion sounds like a possibility. Show us an example of the 2 different fvals that you get.
Answers (3)
Walter Roberson
on 23 Oct 2012
Possibly round-off in the display of the solutions, if you are relying on what is displayed instead of assigning the values to variables and passing in those variables.
0 Comments
Kam Selley
on 24 Oct 2012
2 Comments
Matt J
on 29 Oct 2012
Edited: Matt J
on 29 Oct 2012
I can't see how it makes sense to try to minimize a function that is randomly changing. It's also unclear to me where/how you display the random variable "at the end".
In any case, the expression you gave for the objective function
(ExpUnitProfit*ExpIncMarketShare)/(UnitPrice*MarShareWOExtWar)
looks like it should always be positive, so the question is how the actual objective function that you're feeding to fmincon is different from the above. You should use DBSTOP or set breakpoints to trigger a stop in the code whenever fval<0. Then you can examine what your objective function is doing wrong.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!