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:
Error in svd within fmincon

Subject: Error in svd within fmincon

From: Matteo

Date: 25 Jul, 2008 07:01:05

Message: 1 of 6

Hello,

while running fmincon I get this error for some particular
initial points:

> In fmincon at 303
??? Error using ==> svd
NaN or Inf prevents convergence.

Error in ==> pinv at 29
   [U,S,V] = svd(A,0);

Error in ==> optim/private/qpsub at 492
                    projSD = pinv(projH)*(-Zgf);

Error in ==> optim/private/nlconst at 707
      [SD,lambda,exitflagqp,outputqp,howqp,ACTIND] ...

Error in ==> fmincon at 546
   [X,FVAL,lambda,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...

I don't use any constraint, only box bounds. I checked the
output of my objective function, and it's not giving any NaN
or Inf, but only very big objective values, when this error
occours.

Now I am pretty sure that such big values in the objective
cause the error, but I wonder if there should not be some
kind of error check to prevent the code to stop.

Have you ever had this problem?

I am using 7.2 (2006a). Do you know if this problem has been
solved in recent versions of MATLAB?

Thanks

Matteo

Subject: Error in svd within fmincon

From: Steve

Date: 4 Aug, 2008 15:52:02

Message: 2 of 6

"Matteo " <voto_100.delete.this@hotmail.com> wrote in
message <g6btnh$qpf$1@fred.mathworks.com>...
> Hello,
>
> while running fmincon I get this error for some particular
> initial points:
>
> > In fmincon at 303
> ??? Error using ==> svd
> NaN or Inf prevents convergence.
>
> Error in ==> pinv at 29
> [U,S,V] = svd(A,0);
>
> Error in ==> optim/private/qpsub at 492
> projSD = pinv(projH)*(-Zgf);
>
> Error in ==> optim/private/nlconst at 707
> [SD,lambda,exitflagqp,outputqp,howqp,ACTIND] ...
>
> Error in ==> fmincon at 546
> [X,FVAL,lambda,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
>
> I don't use any constraint, only box bounds. I checked the
> output of my objective function, and it's not giving any NaN
> or Inf, but only very big objective values, when this error
> occours.
>
> Now I am pretty sure that such big values in the objective
> cause the error, but I wonder if there should not be some
> kind of error check to prevent the code to stop.
>
> Have you ever had this problem?
>
> I am using 7.2 (2006a). Do you know if this problem has been
> solved in recent versions of MATLAB?
>
> Thanks
>
> Matteo

Hi Matteo,

How large are the values of the objective function? How
about X?

Why does that matter: In this case the pseudo-inverse
command is trying to compute the SVD of a matrix with a NaN
or Inf in it. That means there was overflow in the
arithmetic leading to that matrix.

One way to combat this is to scale your problem. If you know
that your objective function produces large values, then
scale it such that it produces values in a range near 1. (If
you provide gradients with your objective function, then
you'd have to scale those likewise.)

++Steve

PS: There is a failsafe option to check if your objective or
constraint functions give Inf or NaN values. It's called
'FunValCheck'. However, as you noted, neither this nor any
other options will help in your case.

Subject: Error in svd within fmincon

From: Matteo

Date: 4 Aug, 2008 20:01:03

Message: 3 of 6

"Steve " <steve.grikschat@mathworks.com> wrote in message
<g778j2$af7$1@fred.mathworks.com>...
>
> Hi Matteo,
>
> How large are the values of the objective function? How
> about X?
>
> Why does that matter: In this case the pseudo-inverse
> command is trying to compute the SVD of a matrix with a NaN
> or Inf in it. That means there was overflow in the
> arithmetic leading to that matrix.
>
> One way to combat this is to scale your problem. If you know
> that your objective function produces large values, then
> scale it such that it produces values in a range near 1. (If
> you provide gradients with your objective function, then
> you'd have to scale those likewise.)
>
> ++Steve
>
> PS: There is a failsafe option to check if your objective or
> constraint functions give Inf or NaN values. It's called
> 'FunValCheck'. However, as you noted, neither this nor any
> other options will help in your case.

Hi Steve, thanks for your answer. This is roughly what I
did: I down-scaled the output of my objective just to avoid
very big values. This in fact solved the problem.

Thanks,

Matteo

Subject: Error in svd within fmincon

From: Didi Cvet

Date: 14 Sep, 2009 14:41:02

Message: 4 of 6

"Matteo " <voto_100.delete.this@hotmail.com> wrote in message <g77n5u$6fv$1@fred.mathworks.com>...
> "Steve " <steve.grikschat@mathworks.com> wrote in message
> <g778j2$af7$1@fred.mathworks.com>...
> >
> > Hi Matteo,
> >
> > How large are the values of the objective function? How
> > about X?
> >
> > Why does that matter: In this case the pseudo-inverse
> > command is trying to compute the SVD of a matrix with a NaN
> > or Inf in it. That means there was overflow in the
> > arithmetic leading to that matrix.
> >
> > One way to combat this is to scale your problem. If you know
> > that your objective function produces large values, then
> > scale it such that it produces values in a range near 1. (If
> > you provide gradients with your objective function, then
> > you'd have to scale those likewise.)
> >
> > ++Steve
> >
> > PS: There is a failsafe option to check if your objective or
> > constraint functions give Inf or NaN values. It's called
> > 'FunValCheck'. However, as you noted, neither this nor any
> > other options will help in your case.
>
> Hi Steve, thanks for your answer. This is roughly what I
> did: I down-scaled the output of my objective just to avoid
> very big values. This in fact solved the problem.
>
> Thanks,
>
> Matteo


Hi Metteo
I have the same problem - Error in svd within fmincon. You said that down-scaled the output of objective to avoid very big values solves the problem. Could you be a little more precise and tell me how did you down-scaled the output of the objective function?

Thanks

Didi

Subject: Error in svd within fmincon

From: Didi Cvet

Date: 14 Sep, 2009 14:43:17

Message: 5 of 6

"Matteo " <voto_100.delete.this@hotmail.com> wrote in message <g77n5u$6fv$1@fred.mathworks.com>...
> "Steve " <steve.grikschat@mathworks.com> wrote in message
> <g778j2$af7$1@fred.mathworks.com>...
> >
> > Hi Matteo,
> >
> > How large are the values of the objective function? How
> > about X?
> >
> > Why does that matter: In this case the pseudo-inverse
> > command is trying to compute the SVD of a matrix with a NaN
> > or Inf in it. That means there was overflow in the
> > arithmetic leading to that matrix.
> >
> > One way to combat this is to scale your problem. If you know
> > that your objective function produces large values, then
> > scale it such that it produces values in a range near 1. (If
> > you provide gradients with your objective function, then
> > you'd have to scale those likewise.)
> >
> > ++Steve
> >
> > PS: There is a failsafe option to check if your objective or
> > constraint functions give Inf or NaN values. It's called
> > 'FunValCheck'. However, as you noted, neither this nor any
> > other options will help in your case.
>
> Hi Steve, thanks for your answer. This is roughly what I
> did: I down-scaled the output of my objective just to avoid
> very big values. This in fact solved the problem.
>
> Thanks,
>
> Matteo


Hi Metteo
I have the same problem - Error in svd within fmincon. You said that down-scaled the output of objective to avoid very big values solves the problem. Could you be a little more precise and tell me how did you down-scaled the output of the objective function?

Thanks

Didi

Subject: Error in svd within fmincon

From: Didi Cvet

Date: 14 Sep, 2009 14:43:18

Message: 6 of 6

"Matteo " <voto_100.delete.this@hotmail.com> wrote in message <g77n5u$6fv$1@fred.mathworks.com>...
> "Steve " <steve.grikschat@mathworks.com> wrote in message
> <g778j2$af7$1@fred.mathworks.com>...
> >
> > Hi Matteo,
> >
> > How large are the values of the objective function? How
> > about X?
> >
> > Why does that matter: In this case the pseudo-inverse
> > command is trying to compute the SVD of a matrix with a NaN
> > or Inf in it. That means there was overflow in the
> > arithmetic leading to that matrix.
> >
> > One way to combat this is to scale your problem. If you know
> > that your objective function produces large values, then
> > scale it such that it produces values in a range near 1. (If
> > you provide gradients with your objective function, then
> > you'd have to scale those likewise.)
> >
> > ++Steve
> >
> > PS: There is a failsafe option to check if your objective or
> > constraint functions give Inf or NaN values. It's called
> > 'FunValCheck'. However, as you noted, neither this nor any
> > other options will help in your case.
>
> Hi Steve, thanks for your answer. This is roughly what I
> did: I down-scaled the output of my objective just to avoid
> very big values. This in fact solved the problem.
>
> Thanks,
>
> Matteo


Hi Metteo
I have the same problem - Error in svd within fmincon. You said that down-scaled the output of objective to avoid very big values solves the problem. Could you be a little more precise and tell me how did you down-scaled the output of the objective function?

Thanks

Didi

Tags for 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