Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Keeping track of fmincon iterations

Subject: Keeping track of fmincon iterations

From: C F

Date: 13 Apr, 2009 07:10:04

Message: 1 of 2

Hi,

I'm using fmincon to solve an MLE problem and have run into some problems:

1) max function evaluation seems to occur after each run. what is the difference between this and an iteration max being reached?

2) i omitted the semicolon after the final line in my function .m file so that I could see the function values during iteration. most read "Nan"

Is there a way I can see the path the algorithm is using to find the minimum over this (8 dimensional) surface? I'd like to see this because I believe the function is well defined over the whole space, and am wondering why the function values are "Nan"

thanks.

Subject: Keeping track of fmincon iterations

From: Steven Lord

Date: 13 Apr, 2009 13:18:49

Message: 2 of 2


"C F" <cfrydman@caltech.edu> wrote in message
news:gruogc$p$1@fred.mathworks.com...
> Hi,
>
> I'm using fmincon to solve an MLE problem and have run into some problems:
>
> 1) max function evaluation seems to occur after each run. what is the
> difference between this and an iteration max being reached?

The MaxFunEvals option controls how many times FMINCON is allowed to
evaluate your objective function.

The MaxIter option controls how many times FMINCON is allowed to step to a
new point that it thinks is a "better" solution to the problem.

One iteration usually involves multiple function evaluations, as FMINCON
tries to locate a new "better" solution.

> 2) i omitted the semicolon after the final line in my function .m file so
> that I could see the function values during iteration. most read "Nan"

That's not good.

> Is there a way I can see the path the algorithm is using to find the
> minimum over this (8 dimensional) surface? I'd like to see this because I
> believe the function is well defined over the whole space, and am
> wondering why the function values are "Nan"

Two things you can do:

1) Create an OutputFcn that displays the solution at the given iteration
and/or updates a variable in a MAT-file with the current solution.

http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/f19175.html#f11022

2) Add the following command at the beginning of your objective function:

dbstop if infnan

This will cause MATLAB to stop as soon as it sees an Inf or NaN value. This
way you can locate where the NaN is being introduced. You will likely want
to use an onCleanup object to restore the state, or if you're sure you're
not going to cancel out of the execution of your objective function you can
instead put the following command at the end of your objective function:

dbclear if infnan

--
Steve Lord
slord@mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us