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:
Minimization using Fmincon Error

Subject: Minimization using Fmincon Error

From: Vsh

Date: 5 Aug, 2013 18:02:10

Message: 1 of 3

Hello everyone,
I'm working on a minimization problem with the objective of minimizing the difference between the measured properties and my model's input parameters (5 variables). I'm using fmincon: thus I have an objective function (i.e. my mechanistic model), initial guesses for my variables, no linear equality/inequality (i.e. [],[],[],[]), lower bound, upper bound for all variables and a constraint function (i.e. nlconst) to ensure positive, definitness of my variables.

Of course my code is not working but I quiet don't get where it fails, I was hoping you guys could help me understand what these error messages mean:

Error using optimfcnchk/checkfun (line 318)
User function 'homogenizationRoutine1t' returned NaN
when evaluated;
FMINCON cannot continue.

Error in nlconst (line 744)
                f = feval(funfcn{3},x,varargin{:});

Error in fmincon (line 837)
    [X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...

Does this mean that my constraints (defined by me) cannot be met using the defined objective function (also defined by me)?

Subject: Minimization using Fmincon Error

From: Alan_Weiss

Date: 5 Aug, 2013 19:41:39

Message: 2 of 3

On 8/5/2013 2:02 PM, Vsh wrote:
> Hello everyone,
> I'm working on a minimization problem with the objective of minimizing
> the difference between the measured properties and my model's input
> parameters (5 variables). I'm using fmincon: thus I have an objective
> function (i.e. my mechanistic model), initial guesses for my
> variables, no linear equality/inequality (i.e. [],[],[],[]), lower
> bound, upper bound for all variables and a constraint function (i.e.
> nlconst) to ensure positive, definitness of my variables.
>
> Of course my code is not working but I quiet don't get where it fails,
> I was hoping you guys could help me understand what these error
> messages mean:
> Error using optimfcnchk/checkfun (line 318)
> User function 'homogenizationRoutine1t' returned NaN
> when evaluated;
> FMINCON cannot continue.
>
> Error in nlconst (line 744)
> f = feval(funfcn{3},x,varargin{:});
>
> Error in fmincon (line 837)
> [X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
>
> Does this mean that my constraints (defined by me) cannot be met using
> the defined objective function (also defined by me)?

The error means that your nonlinear constraint function returned a NaN
value.

It appears that you are using the fmincon active-set algorithm. I
suggest that you try the interior-point algorithm, which can be robust
to this kind of error (as long as it does not occur at the initial point
or during the calculation of the gradient at the initial point).

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: Minimization using Fmincon Error

From: Vsh

Date: 5 Aug, 2013 20:29:10

Message: 3 of 3

Thanks Alan for the advice. I'll give it a try.


Alan_Weiss <aweiss@mathworks.com> wrote in message <ktov5i$6ng$1@newscl01ah.mathworks.com>...
> On 8/5/2013 2:02 PM, Vsh wrote:
> > Hello everyone,
> > I'm working on a minimization problem with the objective of minimizing
> > the difference between the measured properties and my model's input
> > parameters (5 variables). I'm using fmincon: thus I have an objective
> > function (i.e. my mechanistic model), initial guesses for my
> > variables, no linear equality/inequality (i.e. [],[],[],[]), lower
> > bound, upper bound for all variables and a constraint function (i.e.
> > nlconst) to ensure positive, definitness of my variables.
> >
> > Of course my code is not working but I quiet don't get where it fails,
> > I was hoping you guys could help me understand what these error
> > messages mean:
> > Error using optimfcnchk/checkfun (line 318)
> > User function 'homogenizationRoutine1t' returned NaN
> > when evaluated;
> > FMINCON cannot continue.
> >
> > Error in nlconst (line 744)
> > f = feval(funfcn{3},x,varargin{:});
> >
> > Error in fmincon (line 837)
> > [X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
> >
> > Does this mean that my constraints (defined by me) cannot be met using
> > the defined objective function (also defined by me)?
>
> The error means that your nonlinear constraint function returned a NaN
> value.
>
> It appears that you are using the fmincon active-set algorithm. I
> suggest that you try the interior-point algorithm, which can be robust
> to this kind of error (as long as it does not occur at the initial point
> or during the calculation of the gradient at the initial point).
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

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