|
"Vista" <abc@gmai.com> wrote in message
news:f48h9q$no3$1@news.Stanford.EDU...
> Hi all,
>
> Is there a way to debug into the objective function of "fmincon"?
>
> I found that the debugging of optimization code in Matlab is extremely
> hard. Basically, "fmincon" and all other Matlab optimization functions
> just don't allow debugging into the objective function, even when I turn
> on "stop when errors" option in Matlab.
I'm guessing you changed the options in the Errors tab of the "Stop if
Errors/Warnings" dialog (or used "dbstop if error".) When the Optimization
Toolbox functions, like FMINCON, call your function they call it inside a
TRY/CATCH block (so they can catch the error and exit gracefully, rather
than having their execution stopped immediately when the error occurs. You
want to change the options in the Try/Catch Errors tab instead (or use
"dbstop if all error" or "dbstop if caught error", depending on which
version of MATLAB you're using.)
However, there's another option, and that is to test your function outside
of FMINCON. It's a good idea to perform unit testing on your function
before you try to use it in your application. That way you hopefully don't
run into a problem in your code in the middle of an optimization, which
would mean you'd need to rerun the whole optimization.
--
Steve Lord
slord@mathworks.com
|