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:
optimization result same as x0u

Subject: optimization result same as x0u

From: Tiam

Date: 10 Jul, 2009 20:24:02

Message: 1 of 6

Hi,

I am using fgoalattain to solve an optimization problem. however, my final result for the x value is always the same as the x0u that i provide to the optimizer.

for instance, i know that the final result should be [5;1.7090], i've tried providing the optimizer with [5;1], but i was asked to increase the number of MaxFunEvals when the result was also x=[5;1], so i increased the MaxFunEvals, but nothong changed

furthermore, i tried to use a closer value as my x0u, this time being [5;1.7040], but the value still wouldn't converge to the desired [5;1.7090].

Can someone pls explain to me what i'm doing wrong, (programming mistake or math), and how i should go about fixing this problem?

thanks in advance

Subject: optimization result same as x0u

From: Faraz Afzal

Date: 10 Jul, 2009 23:32:03

Message: 2 of 6

AHaan.. Hi tiam...

There you go.. Few golden rules that You will need for your whole life when solving optimization problem.

Your initial guess should not be near the minimized value.. I would say this is a kind of bug, but not exactly bug in matlab optimization routine..

If your initial guess is quite near the exact minimized value MATLAB is not able to find the real minimum. So start with somethign nearly zero. GOLDEN RULE>.. WHy would you do so becuz then MATLAB would search in the neighbourhood of your guess and will not use its capability to look further , and would return you your provided initial guess..
 And yeah THE Second golden rule is this , when u need to verify if you are doing right or not then your initial guess should be around the minimized value and MATLAB return the same.. This proves your algorithm working. now start playing with optimset, and initial guess etc etc..

increase the MaxFuncEvals to a large number, do not hesitate. Play with TolX and also with TolFun.. I hope when you try this your algorithm gives you what you ask it for..

Regards,
Muhammad Faraz.

"Tiam " <tiamz84@gmail.com> wrote in message <h38812$3hr$1@fred.mathworks.com>...
> Hi,
>
> I am using fgoalattain to solve an optimization problem. however, my final result for the x value is always the same as the x0u that i provide to the optimizer.
>
> for instance, i know that the final result should be [5;1.7090], i've tried providing the optimizer with [5;1], but i was asked to increase the number of MaxFunEvals when the result was also x=[5;1], so i increased the MaxFunEvals, but nothong changed
>
> furthermore, i tried to use a closer value as my x0u, this time being [5;1.7040], but the value still wouldn't converge to the desired [5;1.7090].
>
> Can someone pls explain to me what i'm doing wrong, (programming mistake or math), and how i should go about fixing this problem?
>
> thanks in advance

Subject: optimization result same as x0u

From: Paul Kerr-Delworth

Date: 13 Jul, 2009 10:00:11

Message: 3 of 6

Hi Tiam,

A couple of other things you can try:

- Check your objective and constraint definitions. Is your function returning NaN or Inf? One way of checking this out is to inspect the iterative display for fgoalattain. To switch the iterative display on, set the 'Display' option to 'iter' using optimset.
- Try several different start points for the problem.

As Muhammed says, relaxing the tolerances (i.e. increase TolX, TolFun and TolCon) may also help you

Hope this helps.

Best regards,

Paul

"Faraz Afzal" <farazafzal@gmail.com> wrote in message <h38j1j$lek$1@fred.mathworks.com>...
> AHaan.. Hi tiam...
>
> There you go.. Few golden rules that You will need for your whole life when solving optimization problem.
>
> Your initial guess should not be near the minimized value.. I would say this is a kind of bug, but not exactly bug in matlab optimization routine..
>
> If your initial guess is quite near the exact minimized value MATLAB is not able to find the real minimum. So start with somethign nearly zero. GOLDEN RULE>.. WHy would you do so becuz then MATLAB would search in the neighbourhood of your guess and will not use its capability to look further , and would return you your provided initial guess..
> And yeah THE Second golden rule is this , when u need to verify if you are doing right or not then your initial guess should be around the minimized value and MATLAB return the same.. This proves your algorithm working. now start playing with optimset, and initial guess etc etc..
>
> increase the MaxFuncEvals to a large number, do not hesitate. Play with TolX and also with TolFun.. I hope when you try this your algorithm gives you what you ask it for..
>
> Regards,
> Muhammad Faraz.
>
> "Tiam " <tiamz84@gmail.com> wrote in message <h38812$3hr$1@fred.mathworks.com>...
> > Hi,
> >
> > I am using fgoalattain to solve an optimization problem. however, my final result for the x value is always the same as the x0u that i provide to the optimizer.
> >
> > for instance, i know that the final result should be [5;1.7090], i've tried providing the optimizer with [5;1], but i was asked to increase the number of MaxFunEvals when the result was also x=[5;1], so i increased the MaxFunEvals, but nothong changed
> >
> > furthermore, i tried to use a closer value as my x0u, this time being [5;1.7040], but the value still wouldn't converge to the desired [5;1.7090].
> >
> > Can someone pls explain to me what i'm doing wrong, (programming mistake or math), and how i should go about fixing this problem?
> >
> > thanks in advance

Subject: optimization result same as x0u

From: Tiam

Date: 13 Jul, 2009 17:54:03

Message: 4 of 6

Hi,

thanks very much Paul, and Muhammed.
I tried the thnigs you suggested, such as using an initial x that is relatively far away from the optimal x, and modifying the values of TolX and TolFun (by making them even smaller than the default values of 1e-6, am I correct?).
I can see a change in the number of 'funcCount' as i modify the TolX nd TolFun values, but the x in each iteration still doesnt change, and after increasign both the MaxFunEvals AND MaxIter to about 20000, the x value still doesn't change...

Is there anything else i might have overlooked?

Thanks so much!


"Paul Kerr-Delworth" <paul.kerr-delworth@mathworks.co.uk> wrote in message <h3f0jb$b5v$1@fred.mathworks.com>...
> Hi Tiam,
>
> A couple of other things you can try:
>
> - Check your objective and constraint definitions. Is your function returning NaN or Inf? One way of checking this out is to inspect the iterative display for fgoalattain. To switch the iterative display on, set the 'Display' option to 'iter' using optimset.
> - Try several different start points for the problem.
>
> As Muhammed says, relaxing the tolerances (i.e. increase TolX, TolFun and TolCon) may also help you
>
> Hope this helps.
>
> Best regards,
>
> Paul
>
> "Faraz Afzal" <farazafzal@gmail.com> wrote in message <h38j1j$lek$1@fred.mathworks.com>...
> > AHaan.. Hi tiam...
> >
> > There you go.. Few golden rules that You will need for your whole life when solving optimization problem.
> >
> > Your initial guess should not be near the minimized value.. I would say this is a kind of bug, but not exactly bug in matlab optimization routine..
> >
> > If your initial guess is quite near the exact minimized value MATLAB is not able to find the real minimum. So start with somethign nearly zero. GOLDEN RULE>.. WHy would you do so becuz then MATLAB would search in the neighbourhood of your guess and will not use its capability to look further , and would return you your provided initial guess..
> > And yeah THE Second golden rule is this , when u need to verify if you are doing right or not then your initial guess should be around the minimized value and MATLAB return the same.. This proves your algorithm working. now start playing with optimset, and initial guess etc etc..
> >
> > increase the MaxFuncEvals to a large number, do not hesitate. Play with TolX and also with TolFun.. I hope when you try this your algorithm gives you what you ask it for..
> >
> > Regards,
> > Muhammad Faraz.
> >
> > "Tiam " <tiamz84@gmail.com> wrote in message <h38812$3hr$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I am using fgoalattain to solve an optimization problem. however, my final result for the x value is always the same as the x0u that i provide to the optimizer.
> > >
> > > for instance, i know that the final result should be [5;1.7090], i've tried providing the optimizer with [5;1], but i was asked to increase the number of MaxFunEvals when the result was also x=[5;1], so i increased the MaxFunEvals, but nothong changed
> > >
> > > furthermore, i tried to use a closer value as my x0u, this time being [5;1.7040], but the value still wouldn't converge to the desired [5;1.7090].
> > >
> > > Can someone pls explain to me what i'm doing wrong, (programming mistake or math), and how i should go about fixing this problem?
> > >
> > > thanks in advance

Subject: optimization result same as x0u

From: Tiam

Date: 14 Jul, 2009 14:49:03

Message: 5 of 6

So I've played around a bit more, and after some tweaking, I found out that I can not use '0' as a weighting factor, even though i would like the result strictly as desired. The 'x' values seem to move about and land on a desirable value if i use '1' as a weighting factor, so I think that issue is somewhat resolved.
However, I am including the constraints, but as soon as I include these nonlinear constraints in my optimization, I am back to where i was at the very start - x0u does not move and x is the same as x0u. If i remove these constraints from the opoimization routine, i.e use '[]' instead of '@mycon' when calling 'fgoalattain' and change nothing else, i will still be able to find a suitable x value.

How is the constraint affecting the search and how can i change it so that it would allow my algorithm to continue as desired?

thanks,


"Tiam " <tiamz84@gmail.com> wrote in message <h3fsbr$ebs$1@fred.mathworks.com>...
> Hi,
>
> thanks very much Paul, and Muhammed.
> I tried the thnigs you suggested, such as using an initial x that is relatively far away from the optimal x, and modifying the values of TolX and TolFun (by making them even smaller than the default values of 1e-6, am I correct?).
> I can see a change in the number of 'funcCount' as i modify the TolX nd TolFun values, but the x in each iteration still doesnt change, and after increasign both the MaxFunEvals AND MaxIter to about 20000, the x value still doesn't change...
>
> Is there anything else i might have overlooked?
>
> Thanks so much!
>
>
> "Paul Kerr-Delworth" <paul.kerr-delworth@mathworks.co.uk> wrote in message <h3f0jb$b5v$1@fred.mathworks.com>...
> > Hi Tiam,
> >
> > A couple of other things you can try:
> >
> > - Check your objective and constraint definitions. Is your function returning NaN or Inf? One way of checking this out is to inspect the iterative display for fgoalattain. To switch the iterative display on, set the 'Display' option to 'iter' using optimset.
> > - Try several different start points for the problem.
> >
> > As Muhammed says, relaxing the tolerances (i.e. increase TolX, TolFun and TolCon) may also help you
> >
> > Hope this helps.
> >
> > Best regards,
> >
> > Paul
> >
> > "Faraz Afzal" <farazafzal@gmail.com> wrote in message <h38j1j$lek$1@fred.mathworks.com>...
> > > AHaan.. Hi tiam...
> > >
> > > There you go.. Few golden rules that You will need for your whole life when solving optimization problem.
> > >
> > > Your initial guess should not be near the minimized value.. I would say this is a kind of bug, but not exactly bug in matlab optimization routine..
> > >
> > > If your initial guess is quite near the exact minimized value MATLAB is not able to find the real minimum. So start with somethign nearly zero. GOLDEN RULE>.. WHy would you do so becuz then MATLAB would search in the neighbourhood of your guess and will not use its capability to look further , and would return you your provided initial guess..
> > > And yeah THE Second golden rule is this , when u need to verify if you are doing right or not then your initial guess should be around the minimized value and MATLAB return the same.. This proves your algorithm working. now start playing with optimset, and initial guess etc etc..
> > >
> > > increase the MaxFuncEvals to a large number, do not hesitate. Play with TolX and also with TolFun.. I hope when you try this your algorithm gives you what you ask it for..
> > >
> > > Regards,
> > > Muhammad Faraz.
> > >
> > > "Tiam " <tiamz84@gmail.com> wrote in message <h38812$3hr$1@fred.mathworks.com>...
> > > > Hi,
> > > >
> > > > I am using fgoalattain to solve an optimization problem. however, my final result for the x value is always the same as the x0u that i provide to the optimizer.
> > > >
> > > > for instance, i know that the final result should be [5;1.7090], i've tried providing the optimizer with [5;1], but i was asked to increase the number of MaxFunEvals when the result was also x=[5;1], so i increased the MaxFunEvals, but nothong changed
> > > >
> > > > furthermore, i tried to use a closer value as my x0u, this time being [5;1.7040], but the value still wouldn't converge to the desired [5;1.7090].
> > > >
> > > > Can someone pls explain to me what i'm doing wrong, (programming mistake or math), and how i should go about fixing this problem?
> > > >
> > > > thanks in advance

Subject: optimization result same as x0u

From: Alan Weiss

Date: 14 Jul, 2009 19:00:59

Message: 6 of 6

Hi, have you looked at the documentation?
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/brnoyfe.html
explains how the weights are used, and equation 4-118 explains how the
constraints are incorporated into the algorithm.

Alan Weiss
MATLAB mathematical toolbox documentation

Tiam wrote:
> So I've played around a bit more, and after some tweaking, I found out that I can not use '0' as a weighting factor, even though i would like the result strictly as desired. The 'x' values seem to move about and land on a desirable value if i use '1' as a weighting factor, so I think that issue is somewhat resolved.
> However, I am including the constraints, but as soon as I include these nonlinear constraints in my optimization, I am back to where i was at the very start - x0u does not move and x is the same as x0u. If i remove these constraints from the opoimization routine, i.e use '[]' instead of '@mycon' when calling 'fgoalattain' and change nothing else, i will still be able to find a suitable x value.
>
> How is the constraint affecting the search and how can i change it so that it would allow my algorithm to continue as desired?
>
> thanks,
>

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