From: David Chan on 15 Jan 2010 17:37 Hi, I have a problem when I run fminunc, which involves a termination of the optimization with this error message: ??? Error using ==> roots at 28 Input to ROOTS must not contain NaN or Inf. I've read other threads about this problem that seem to say that it is due to initial parameter values, but the strange thing about my problem is that it seems to happen at random iterations. Sometimes the optimization procedure will last only 2 iterations, other times it can last for >100 iterations. Also strange is that it is causing problems with Kenneth Train's code for mixed logit (http://elsa.berkeley.edu/Software/abstracts/train1006mxlmsl.html), which is apparently a very commonly used code to do mixed logit. I haven't modified the code at all, so it's supposed to work on his default data. The output that it produces matches exactly the output that he says it's supposed to produce, until my program terminates due to fminunc. Thanks, Dave
From: John D'Errico on 15 Jan 2010 18:52 "David Chan" <david.c.chan(a)gmail.com> wrote in message <hiqqme$4ee$1(a)fred.mathworks.com>... > Hi, > > I have a problem when I run fminunc, which involves a termination of the optimization with this error message: > > ??? Error using ==> roots at 28 > Input to ROOTS must not contain NaN or Inf. > > I've read other threads about this problem that seem to say that it is due to initial parameter values, but the strange thing about my problem is that it seems to happen at random iterations. Sometimes the optimization procedure will last only 2 iterations, other times it can last for >100 iterations. > > Also strange is that it is causing problems with Kenneth Train's code for mixed logit (http://elsa.berkeley.edu/Software/abstracts/train1006mxlmsl.html), which is apparently a very commonly used code to do mixed logit. I haven't modified the code at all, so it's supposed to work on his default data. The output that it produces matches exactly the output that he says it's supposed to produce, until my program terminates due to fminunc. > No. It is happening because you really have a function that SHOULD have constraints applied to it. There are some regions of your parameter space that yield garbage. This is not due to your initial values, although it might be made more robust by a better choice of initial values. John
From: Alan Weiss on 18 Jan 2010 08:01 John D'Errico wrote: > "David Chan" <david.c.chan(a)gmail.com> wrote in message > <hiqqme$4ee$1(a)fred.mathworks.com>... >> Hi, >> >> I have a problem when I run fminunc, which involves a termination of >> the optimization with this error message: >> >> ??? Error using ==> roots at 28 >> Input to ROOTS must not contain NaN or Inf. >> >> I've read other threads about this problem that seem to say that it is >> due to initial parameter values, but the strange thing about my >> problem is that it seems to happen at random iterations. Sometimes the >> optimization procedure will last only 2 iterations, other times it can >> last for >100 iterations. >> Also strange is that it is causing problems with Kenneth Train's code >> for mixed logit >> (http://elsa.berkeley.edu/Software/abstracts/train1006mxlmsl.html), >> which is apparently a very commonly used code to do mixed logit. I >> haven't modified the code at all, so it's supposed to work on his >> default data. The output that it produces matches exactly the output >> that he says it's supposed to produce, until my program terminates due >> to fminunc. >> > > No. It is happening because you really have a > function that SHOULD have constraints applied > to it. There are some regions of your parameter > space that yield garbage. > > This is not due to your initial values, although > it might be made more robust by a better choice > of initial values. > > John To expand on John's comment, the problem is your objective function is returning a illegal values (NaN or Inf or complex) at some points. You should write some constraint function(s) that keep your optimization away from these points. For example, if you take the square root of f in your objective function, make sure f is positive by writing a constraint function. For more information on which solver to use, and on writing constraints, see http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-18.html and http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brhkghv-11.html Alan Weiss MATLAB mathematical toolbox documentation
From: Matt J on 18 Jan 2010 09:38 Alan Weiss <aweiss(a)mathworks.com> wrote in message <hj1m2g$cct$1(a)fred.mathworks.com>... > To expand on John's comment, the problem is your objective function is > returning a illegal values (NaN or Inf or complex) at some points. You > should write some constraint function(s) that keep your optimization > away from these points. But then you end up using fmincon() which doesn't ensure that you stay away from the illegal values either, if any of the required constraints are non-linear. The different algorithms used by fmincon either do not support non-linear constraints or don't ensure that they are satisifed at each iteration...
From: John D'Errico on 18 Jan 2010 09:52
"Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hj1roa$jla$1(a)fred.mathworks.com>... > Alan Weiss <aweiss(a)mathworks.com> wrote in message <hj1m2g$cct$1(a)fred.mathworks.com>... > > > To expand on John's comment, the problem is your objective function is > > returning a illegal values (NaN or Inf or complex) at some points. You > > should write some constraint function(s) that keep your optimization > > away from these points. > > But then you end up using fmincon() which doesn't ensure that you stay away from the illegal values either, if any of the required constraints are non-linear. The different algorithms used by fmincon either do not support non-linear constraints or don't ensure that they are satisifed at each iteration... But NOT using a constrained optimizer is equivalent to putting your head in the sand and pretending it never happens! John |