Thread Subject: Using fmincon - interior point algorithm

Subject: Using fmincon - interior point algorithm

From: mashor housh

Date: 15 Sep, 2009 13:12:02

Message: 1 of 9

Hi,

I am using FMINCON-interior point algorithm with conjugate gradient sub algorithm to minimize nonlinear objective function with 62 variables, 124 linear inequalities, 60 nonlinear inequalities and [zeros; ones] as lower and upper bounds respectively.

I performed 10 runs for this problem, each run with different starting point by using the function UNIFRND to produce 62 random variables between 0 and 1.
In 7 runs a local optimum was obtained which satisfies all the criterions.
In 3 runs the optimizer gets near to the optimal solution during the iteration, but before it converge it gets NAN as the objective value and the iterations continue with the NAN as the objective value.

By debugging the objective function it seems that the solver trying to evaluate vector of NaNs( x = NaN ) , I can't understand why this happened, furthermore I can't perform debugging for the optimizer since it's given as protected file BARRIER.P.

Any ideas, which explains why this happens and how to fix it?

p.s.

Meanwhile I wrote output function which records the iterations and stops if the optimizer trying to evaluate vector of NaNs, in such cases the best x would be one iteration before the last since the last is vector of NaNs .

Thank you,
Mashor

Subject: Using fmincon - interior point algorithm

From: Derya Ozyurt

Date: 15 Sep, 2009 16:02:36

Message: 2 of 9

Hello Mashor,
Is it possible for your objective function to return NaNs for a given (not
NaN) x value? Could you check this outside of fmincon?

Best Regards,
Derya

"mashor housh" <mashor@technion.ac.il> wrote in message
news:h8o3r2$cif$1@fred.mathworks.com...
> Hi,
>
> I am using FMINCON-interior point algorithm with conjugate gradient sub
> algorithm to minimize nonlinear objective function with 62 variables, 124
> linear inequalities, 60 nonlinear inequalities and [zeros; ones] as lower
> and upper bounds respectively.
>
> I performed 10 runs for this problem, each run with different starting
> point by using the function UNIFRND to produce 62 random variables between
> 0 and 1.
> In 7 runs a local optimum was obtained which satisfies all the criterions.
> In 3 runs the optimizer gets near to the optimal solution during the
> iteration, but before it converge it gets NAN as the objective value and
> the iterations continue with the NAN as the objective value.
>
> By debugging the objective function it seems that the solver trying to
> evaluate vector of NaNs( x = NaN ) , I can't understand why this happened,
> furthermore I can't perform debugging for the optimizer since it's given
> as protected file BARRIER.P.
>
> Any ideas, which explains why this happens and how to fix it?
>
> p.s.
>
> Meanwhile I wrote output function which records the iterations and stops
> if the optimizer trying to evaluate vector of NaNs, in such cases the best
> x would be one iteration before the last since the last is vector of NaNs
> .
>
> Thank you,
> Mashor

Subject: Using fmincon - interior point algorithm

From: mashor housh

Date: 15 Sep, 2009 17:07:19

Message: 3 of 9

hello Derya,
I checked this by applying the option FunValCheck which tell me whenever the objective or the constraints function return NaN or inf.
The objective didn't return NaN in the iterations process except in the probematic iteration when (x=NaN )

Thanks


"Derya Ozyurt" <dozyurt@mathworks.com> wrote in message <h8odqu$ijg$1@fred.mathworks.com>...
> Hello Mashor,
> Is it possible for your objective function to return NaNs for a given (not
> NaN) x value? Could you check this outside of fmincon?
>
> Best Regards,
> Derya
>
> "mashor housh" <mashor@technion.ac.il> wrote in message
> news:h8o3r2$cif$1@fred.mathworks.com...
> > Hi,
> >
> > I am using FMINCON-interior point algorithm with conjugate gradient sub
> > algorithm to minimize nonlinear objective function with 62 variables, 124
> > linear inequalities, 60 nonlinear inequalities and [zeros; ones] as lower
> > and upper bounds respectively.
> >
> > I performed 10 runs for this problem, each run with different starting
> > point by using the function UNIFRND to produce 62 random variables between
> > 0 and 1.
> > In 7 runs a local optimum was obtained which satisfies all the criterions.
> > In 3 runs the optimizer gets near to the optimal solution during the
> > iteration, but before it converge it gets NAN as the objective value and
> > the iterations continue with the NAN as the objective value.
> >
> > By debugging the objective function it seems that the solver trying to
> > evaluate vector of NaNs( x = NaN ) , I can't understand why this happened,
> > furthermore I can't perform debugging for the optimizer since it's given
> > as protected file BARRIER.P.
> >
> > Any ideas, which explains why this happens and how to fix it?
> >
> > p.s.
> >
> > Meanwhile I wrote output function which records the iterations and stops
> > if the optimizer trying to evaluate vector of NaNs, in such cases the best
> > x would be one iteration before the last since the last is vector of NaNs
> > .
> >
> > Thank you,
> > Mashor
>

Subject: Using fmincon - interior point algorithm

From: Derya Ozyurt

Date: 15 Sep, 2009 21:14:00

Message: 4 of 9

Hi Mashor,
When the 'FunValCheck' option is on, the objective function will be called
with the initial point (x0) only once. The objective function may still
return a NaN for a different (valid) x value.
You mentioned that you have created an output function for recording
iterations. Can you record the x values and use the last non-NaN x with your
objective function?

Best Regards,
Derya


"mashor housh" <mashor@technion.ac.il> wrote in message
news:h8ohk7$qdg$1@fred.mathworks.com...
> hello Derya,
> I checked this by applying the option FunValCheck which tell me whenever
> the objective or the constraints function return NaN or inf.
> The objective didn't return NaN in the iterations process except in the
> probematic iteration when (x=NaN )
>
> Thanks
>
>
> "Derya Ozyurt" <dozyurt@mathworks.com> wrote in message
> <h8odqu$ijg$1@fred.mathworks.com>...
>> Hello Mashor,
>> Is it possible for your objective function to return NaNs for a given
>> (not
>> NaN) x value? Could you check this outside of fmincon?
>>
>> Best Regards,
>> Derya
>>
>> "mashor housh" <mashor@technion.ac.il> wrote in message
>> news:h8o3r2$cif$1@fred.mathworks.com...
>> > Hi,
>> >
>> > I am using FMINCON-interior point algorithm with conjugate gradient sub
>> > algorithm to minimize nonlinear objective function with 62 variables,
>> > 124
>> > linear inequalities, 60 nonlinear inequalities and [zeros; ones] as
>> > lower
>> > and upper bounds respectively.
>> >
>> > I performed 10 runs for this problem, each run with different starting
>> > point by using the function UNIFRND to produce 62 random variables
>> > between
>> > 0 and 1.
>> > In 7 runs a local optimum was obtained which satisfies all the
>> > criterions.
>> > In 3 runs the optimizer gets near to the optimal solution during the
>> > iteration, but before it converge it gets NAN as the objective value
>> > and
>> > the iterations continue with the NAN as the objective value.
>> >
>> > By debugging the objective function it seems that the solver trying to
>> > evaluate vector of NaNs( x = NaN ) , I can't understand why this
>> > happened,
>> > furthermore I can't perform debugging for the optimizer since it's
>> > given
>> > as protected file BARRIER.P.
>> >
>> > Any ideas, which explains why this happens and how to fix it?
>> >
>> > p.s.
>> >
>> > Meanwhile I wrote output function which records the iterations and
>> > stops
>> > if the optimizer trying to evaluate vector of NaNs, in such cases the
>> > best
>> > x would be one iteration before the last since the last is vector of
>> > NaNs
>> > .
>> >
>> > Thank you,
>> > Mashor
>>

Subject: Using fmincon - interior point algorithm

From: mashor housh

Date: 15 Sep, 2009 21:54:03

Message: 5 of 9

Hi,
I did that it didn't return NaN furthermore to vertify that my objective function didn't return a NaN for non-NaN X I added the follwoing to the objective function:

if isnan(fval) & ~any(isnan(x))
error('objective returned NaN')
end

I didn't get an error

Best Regards
Mashor

"Derya Ozyurt" <dozyurt@mathworks.com> wrote in message
<h8p02q$f0u$1@fred.mathworks.com>...
> Hi Mashor,
> When the 'FunValCheck' option is on, the objective function will be called
> with the initial point (x0) only once. The objective function may still
> return a NaN for a different (valid) x value.
> You mentioned that you have created an output function for recording
> iterations. Can you record the x values and use the last non-NaN x with your
> objective function?
>
> Best Regards,
> Derya
>
>
> "mashor housh" <mashor@technion.ac.il> wrote in message
> news:h8ohk7$qdg$1@fred.mathworks.com...
> > hello Derya,
> > I checked this by applying the option FunValCheck which tell me whenever
> > the objective or the constraints function return NaN or inf.
> > The objective didn't return NaN in the iterations process except in the
> > probematic iteration when (x=NaN )
> >
> > Thanks
> >
> >
> > "Derya Ozyurt" <dozyurt@mathworks.com> wrote in message
> > <h8odqu$ijg$1@fred.mathworks.com>...
> >> Hello Mashor,
> >> Is it possible for your objective function to return NaNs for a given
> >> (not
> >> NaN) x value? Could you check this outside of fmincon?
> >>
> >> Best Regards,
> >> Derya
> >>
> >> "mashor housh" <mashor@technion.ac.il> wrote in message
> >> news:h8o3r2$cif$1@fred.mathworks.com...
> >> > Hi,
> >> >
> >> > I am using FMINCON-interior point algorithm with conjugate gradient sub
> >> > algorithm to minimize nonlinear objective function with 62 variables,
> >> > 124
> >> > linear inequalities, 60 nonlinear inequalities and [zeros; ones] as
> >> > lower
> >> > and upper bounds respectively.
> >> >
> >> > I performed 10 runs for this problem, each run with different starting
> >> > point by using the function UNIFRND to produce 62 random variables
> >> > between
> >> > 0 and 1.
> >> > In 7 runs a local optimum was obtained which satisfies all the
> >> > criterions.
> >> > In 3 runs the optimizer gets near to the optimal solution during the
> >> > iteration, but before it converge it gets NAN as the objective value
> >> > and
> >> > the iterations continue with the NAN as the objective value.
> >> >
> >> > By debugging the objective function it seems that the solver trying to
> >> > evaluate vector of NaNs( x = NaN ) , I can't understand why this
> >> > happened,
> >> > furthermore I can't perform debugging for the optimizer since it's
> >> > given
> >> > as protected file BARRIER.P.
> >> >
> >> > Any ideas, which explains why this happens and how to fix it?
> >> >
> >> > p.s.
> >> >
> >> > Meanwhile I wrote output function which records the iterations and
> >> > stops
> >> > if the optimizer trying to evaluate vector of NaNs, in such cases the
> >> > best
> >> > x would be one iteration before the last since the last is vector of
> >> > NaNs
> >> > .
> >> >
> >> > Thank you,
> >> > Mashor
> >>
>

Subject: Using fmincon - interior point algorithm

From: Derya Ozyurt

Date: 16 Sep, 2009 14:09:02

Message: 6 of 9

Hello Mashor,
Do you also have a constraint function (nonlcon) in your problem? If yes,
could you check it too. I also recommend that you make sure no Infs are
returned from both (objective and constraint) functions for valid x values.

Best Regards,
Derya


"mashor housh" <mashor@technion.ac.il> wrote in message
news:h8p2dr$i95$1@fred.mathworks.com...
> Hi,
> I did that it didn't return NaN furthermore to vertify that my objective
> function didn't return a NaN for non-NaN X I added the follwoing to the
> objective function:
>
> if isnan(fval) & ~any(isnan(x))
> error('objective returned NaN')
> end
>
> I didn't get an error
>
> Best Regards
> Mashor
>
> "Derya Ozyurt" <dozyurt@mathworks.com> wrote in message
> <h8p02q$f0u$1@fred.mathworks.com>...
>> Hi Mashor,
>> When the 'FunValCheck' option is on, the objective function will be
>> called
>> with the initial point (x0) only once. The objective function may still
>> return a NaN for a different (valid) x value.
>> You mentioned that you have created an output function for recording
>> iterations. Can you record the x values and use the last non-NaN x with
>> your
>> objective function?
>>
>> Best Regards,
>> Derya
>>
>>
>> "mashor housh" <mashor@technion.ac.il> wrote in message
>> news:h8ohk7$qdg$1@fred.mathworks.com...
>> > hello Derya,
>> > I checked this by applying the option FunValCheck which tell me
>> > whenever
>> > the objective or the constraints function return NaN or inf.
>> > The objective didn't return NaN in the iterations process except in the
>> > probematic iteration when (x=NaN )
>> >
>> > Thanks
>> >
>> >
>> > "Derya Ozyurt" <dozyurt@mathworks.com> wrote in message
>> > <h8odqu$ijg$1@fred.mathworks.com>...
>> >> Hello Mashor,
>> >> Is it possible for your objective function to return NaNs for a given
>> >> (not
>> >> NaN) x value? Could you check this outside of fmincon?
>> >>
>> >> Best Regards,
>> >> Derya
>> >>
>> >> "mashor housh" <mashor@technion.ac.il> wrote in message
>> >> news:h8o3r2$cif$1@fred.mathworks.com...
>> >> > Hi,
>> >> >
>> >> > I am using FMINCON-interior point algorithm with conjugate gradient
>> >> > sub
>> >> > algorithm to minimize nonlinear objective function with 62
>> >> > variables,
>> >> > 124
>> >> > linear inequalities, 60 nonlinear inequalities and [zeros; ones] as
>> >> > lower
>> >> > and upper bounds respectively.
>> >> >
>> >> > I performed 10 runs for this problem, each run with different
>> >> > starting
>> >> > point by using the function UNIFRND to produce 62 random variables
>> >> > between
>> >> > 0 and 1.
>> >> > In 7 runs a local optimum was obtained which satisfies all the
>> >> > criterions.
>> >> > In 3 runs the optimizer gets near to the optimal solution during the
>> >> > iteration, but before it converge it gets NAN as the objective value
>> >> > and
>> >> > the iterations continue with the NAN as the objective value.
>> >> >
>> >> > By debugging the objective function it seems that the solver trying
>> >> > to
>> >> > evaluate vector of NaNs( x = NaN ) , I can't understand why this
>> >> > happened,
>> >> > furthermore I can't perform debugging for the optimizer since it's
>> >> > given
>> >> > as protected file BARRIER.P.
>> >> >
>> >> > Any ideas, which explains why this happens and how to fix it?
>> >> >
>> >> > p.s.
>> >> >
>> >> > Meanwhile I wrote output function which records the iterations and
>> >> > stops
>> >> > if the optimizer trying to evaluate vector of NaNs, in such cases
>> >> > the
>> >> > best
>> >> > x would be one iteration before the last since the last is vector of
>> >> > NaNs
>> >> > .
>> >> >
>> >> > Thank you,
>> >> > Mashor
>> >>
>>

Subject: Using fmincon - interior point algorithm

From: mashor housh

Date: 16 Sep, 2009 19:45:40

Message: 7 of 9

Hi

I added this code to the objective function :

if ( isnan(cost) | isinf(cost) ) & ~any(isnan(x))
error('objective returned NaN or inf')
end

where cost is the objective value

and this code to the constarints functions :

if ( any(isnan(cnl)) | any(isinf(cnl)) ) & ~any(isnan(x))
error('one of the constraints is nan or inf')
end

where cnl is the inequality constraints vector ( I dont have equality constraints)

I still face the same problem, I think that this proves that the optimizer i.e. Barrier.p is responsible for this NaN's.

Thanks

Subject: Using fmincon - interior point algorithm

From: Derya Ozyurt

Date: 16 Sep, 2009 22:18:38

Message: 8 of 9

Hello Mashor,
I recommend that you contact the technical support after trying out one more
thing.
Could you remove "& ~any(isnan(x)" from the if-clauses? Then type "dbstop
if error" at command line. When the debugger stops investigate where the
error is coming from (objective vs constraint function) and what the x value
is at that point.

Best Regards,
Derya

"mashor housh" <mashor@technion.ac.il> wrote in message
news:h8rf94$ceg$1@fred.mathworks.com...
> Hi
>
> I added this code to the objective function :
>
> if ( isnan(cost) | isinf(cost) ) & ~any(isnan(x))
> error('objective returned NaN or inf')
> end
>
> where cost is the objective value
>
> and this code to the constarints functions :
>
> if ( any(isnan(cnl)) | any(isinf(cnl)) ) & ~any(isnan(x))
> error('one of the constraints is nan or inf')
> end
>
> where cnl is the inequality constraints vector ( I dont have equality
> constraints)
>
> I still face the same problem, I think that this proves that the optimizer
> i.e. Barrier.p is responsible for this NaN's.
>
> Thanks

Subject: Using fmincon - interior point algorithm

From: mashor housh

Date: 17 Sep, 2009 12:23:03

Message: 9 of 9

Hi,

The debugger stopped in the objective function, X was vecor of NaNs.
Thank you very much for your help, I will try to contact the technical support.

Thanks
mashor


"Derya Ozyurt" <dozyurt@mathworks.com> wrote in message <h8ro7v$chk$1@fred.mathworks.com>...
> Hello Mashor,
> I recommend that you contact the technical support after trying out one more
> thing.
> Could you remove "& ~any(isnan(x)" from the if-clauses? Then type "dbstop
> if error" at command line. When the debugger stops investigate where the
> error is coming from (objective vs constraint function) and what the x value
> is at that point.
>
> Best Regards,
> Derya
>
> "mashor housh" <mashor@technion.ac.il> wrote in message
> news:h8rf94$ceg$1@fred.mathworks.com...
> > Hi
> >
> > I added this code to the objective function :
> >
> > if ( isnan(cost) | isinf(cost) ) & ~any(isnan(x))
> > error('objective returned NaN or inf')
> > end
> >
> > where cost is the objective value
> >
> > and this code to the constarints functions :
> >
> > if ( any(isnan(cnl)) | any(isinf(cnl)) ) & ~any(isnan(x))
> > error('one of the constraints is nan or inf')
> > end
> >
> > where cnl is the inequality constraints vector ( I dont have equality
> > constraints)
> >
> > I still face the same problem, I think that this proves that the optimizer
> > i.e. Barrier.p is responsible for this NaN's.
> >
> > Thanks
>

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
fmincon Sprinceana 15 Sep, 2009 14:09:39
rssFeed for this Thread

Contact us at files@mathworks.com