<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: HELP &#8211; I Got the Wrong Answer for My Optimization!</title>
	<atom:link href="http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/</link>
	<description>Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.</description>
	<lastBuildDate>Thu, 09 Feb 2012 04:19:21 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: shankar</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31547</link>
		<dc:creator>shankar</dc:creator>
		<pubDate>Tue, 27 Jul 2010 07:50:54 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31547</guid>
		<description>Hi james, great information. Thanks. in fact what you suggested is what i kind of did. wrote down the hessian at the initial point, and minimizing it gives us the bifurcation modes. However nonlinear an energy be, usually its hessian&#039;s minimization gives a linear eqn. for bifurcation. Since the bifurcation problem is an eigenvalue, discretizing gives a simple AX=tX matrix eigenvalue problem. Choosing smallest eigenvalue of A, and its corresponding eigenvector, I used that eigenvector multiplied by a (any) small number to perturb the intial point. As soon as it is perturbed, fmincon works very well. Also if the perturbation is not correct direction, ideally it should fall back into the maxima.</description>
		<content:encoded><![CDATA[<p>Hi james, great information. Thanks. in fact what you suggested is what i kind of did. wrote down the hessian at the initial point, and minimizing it gives us the bifurcation modes. However nonlinear an energy be, usually its hessian&#8217;s minimization gives a linear eqn. for bifurcation. Since the bifurcation problem is an eigenvalue, discretizing gives a simple AX=tX matrix eigenvalue problem. Choosing smallest eigenvalue of A, and its corresponding eigenvector, I used that eigenvector multiplied by a (any) small number to perturb the intial point. As soon as it is perturbed, fmincon works very well. Also if the perturbation is not correct direction, ideally it should fall back into the maxima.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31522</link>
		<dc:creator>James</dc:creator>
		<pubDate>Thu, 22 Jul 2010 12:16:49 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31522</guid>
		<description>Shankar: while algorithms in the optimization toolbox may not be able to descend from a maximum or a saddle point, gradient-free algorithms in the Global Optimization Toolbox certainly can, such as ga or patternsearch. It&#039;s a matter of choosing an algorithm appropriate for your problem. 

If you don&#039;t know a lot about what the problem space looks like, and have some indication that multiple stationary points may exist, then a hybrid approach can be helpful, i.e., starting off with a gradient-free method with relatively loose tolerances, and then using the result as a starting point for a gradient-based method to identify a precise solution. The new GlobalSearch and MultiStart algorithms may also be very helpful.</description>
		<content:encoded><![CDATA[<p>Shankar: while algorithms in the optimization toolbox may not be able to descend from a maximum or a saddle point, gradient-free algorithms in the Global Optimization Toolbox certainly can, such as ga or patternsearch. It&#8217;s a matter of choosing an algorithm appropriate for your problem. </p>
<p>If you don&#8217;t know a lot about what the problem space looks like, and have some indication that multiple stationary points may exist, then a hybrid approach can be helpful, i.e., starting off with a gradient-free method with relatively loose tolerances, and then using the result as a starting point for a gradient-based method to identify a precise solution. The new GlobalSearch and MultiStart algorithms may also be very helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shankar</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31521</link>
		<dc:creator>shankar</dc:creator>
		<pubDate>Thu, 22 Jul 2010 00:46:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31521</guid>
		<description>Thanks alan and james. i understand what you are saying. i am especially surprised as there seems to be no code which can make a point descend from a maxima or even a saddle point. the only way i could get anything out of my matlab code is to perturb the initial point slightly. but then since i am looking at the subsequent evolution of the problem, i fear i might be getting the wrong or right answer depending upon how i perturb the initial point, however so slightly (its a stability/bifurcation problem). strange indeed that numerical guys have not figured out this issue.</description>
		<content:encoded><![CDATA[<p>Thanks alan and james. i understand what you are saying. i am especially surprised as there seems to be no code which can make a point descend from a maxima or even a saddle point. the only way i could get anything out of my matlab code is to perturb the initial point slightly. but then since i am looking at the subsequent evolution of the problem, i fear i might be getting the wrong or right answer depending upon how i perturb the initial point, however so slightly (its a stability/bifurcation problem). strange indeed that numerical guys have not figured out this issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Allison</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31511</link>
		<dc:creator>James Allison</dc:creator>
		<pubDate>Mon, 19 Jul 2010 12:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31511</guid>
		<description>Regarding the answer to Ben&#039;s comment: fmincon is a gradient-based algorithm. It&#039;s search direction depends on the gradient of the function at a point, and it stops when first-order conditions are satisfied, i.e., the gradient is zero if no constraints are active. In this case Ben is starting fmincon at a point where the gradient is zero, so of course the algorithm doesn&#039;t move. Another term like this is a &#039;stationary point&#039;. This is a property of gradient-based algorithms, and not just MATLAB&#039;s fmincon. It&#039;s expected behavior. In cases like this you might want to try a multi-start approach, or an initial search with a gradient-free algorithm. The new global optimization toolbox can handle problems like this very well (multiple stationary points, noisy responses, etc.).</description>
		<content:encoded><![CDATA[<p>Regarding the answer to Ben&#8217;s comment: fmincon is a gradient-based algorithm. It&#8217;s search direction depends on the gradient of the function at a point, and it stops when first-order conditions are satisfied, i.e., the gradient is zero if no constraints are active. In this case Ben is starting fmincon at a point where the gradient is zero, so of course the algorithm doesn&#8217;t move. Another term like this is a &#8216;stationary point&#8217;. This is a property of gradient-based algorithms, and not just MATLAB&#8217;s fmincon. It&#8217;s expected behavior. In cases like this you might want to try a multi-start approach, or an initial search with a gradient-free algorithm. The new global optimization toolbox can handle problems like this very well (multiple stationary points, noisy responses, etc.).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Weiss</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31510</link>
		<dc:creator>Alan Weiss</dc:creator>
		<pubDate>Mon, 19 Jul 2010 12:18:49 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31510</guid>
		<description>When your initial point is stationary (i.e., has gradient = 0 or satisfies the KKT conditions), the solver has no way to know whether the point is a local minimum, local maximum, or is simply an indefinite stationary point. The issue is addressed in these sections of the documentation:
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#br44j7o
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#br44i5e
http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#brhkghv-65

The final link is particularly relevant, in the it explains the difference between a local and a global solution, and why the initial point is so important.</description>
		<content:encoded><![CDATA[<p>When your initial point is stationary (i.e., has gradient = 0 or satisfies the KKT conditions), the solver has no way to know whether the point is a local minimum, local maximum, or is simply an indefinite stationary point. The issue is addressed in these sections of the documentation:<br />
<a href="http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#br44j7o" rel="nofollow">http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#br44j7o</a><br />
<a href="http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#br44i5e" rel="nofollow">http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#br44i5e</a><br />
<a href="http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#brhkghv-65" rel="nofollow">http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/br44i40.html#brhkghv-65</a></p>
<p>The final link is particularly relevant, in the it explains the difference between a local and a global solution, and why the initial point is so important.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shankar</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31502</link>
		<dc:creator>shankar</dc:creator>
		<pubDate>Fri, 16 Jul 2010 16:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31502</guid>
		<description>Hi, did anyone figure out what Ben asked? Why does matlab get stuck at intitial point for minimizing even cosine. I am having a similiar problem with my objective function getting stuck at initial point. as soon as i perturb the initial point ever so slightly, it evolves very well. but unfortunately i fear that the direction of the perturbation might be influencing the evolution of the solution.</description>
		<content:encoded><![CDATA[<p>Hi, did anyone figure out what Ben asked? Why does matlab get stuck at intitial point for minimizing even cosine. I am having a similiar problem with my objective function getting stuck at initial point. as soon as i perturb the initial point ever so slightly, it evolves very well. but unfortunately i fear that the direction of the perturbation might be influencing the evolution of the solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31252</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 07 Apr 2010 12:46:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31252</guid>
		<description>Lishuqin-

The message is telling you what the issue is (and how to change it).  If that doesn&#039;t help, please contact technical support - link at the right.

--Loren</description>
		<content:encoded><![CDATA[<p>Lishuqin-</p>
<p>The message is telling you what the issue is (and how to change it).  If that doesn&#8217;t help, please contact technical support &#8211; link at the right.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lishuqin</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31249</link>
		<dc:creator>lishuqin</dc:creator>
		<pubDate>Wed, 07 Apr 2010 02:30:56 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-31249</guid>
		<description>ti have the problem:Maximum number of function evaluations exceeded;
increase OPTIONS.MaxFunEvals.
my function as follows:

function f=gear(x)
f=1*0.7408*x(1)^3*x(2)^3*x(3)*[1+(1-x(3))^2+(1-x(3))]+0*[-1.88+4.858/x(2)]
function [g,q]=mycon(x)
g(1)=160057/[x(1)^3*x(2)^3*(1-0.5*x(3))^2*x(3)]^(-0.5)-664;
g(2)=398121*x(1)^(-3)*x(2)^(-2)*(1-0.5*x(3))^(-2)*x(3)^(-1)-480;
g(3)=358848*x(1)^(-3)*x(2)^(-2)*(1-0.5*x(3))^(-2)*x(3)^(-1)-464;
g(4)=-0.48+4.858/x(2);
g(5)=4-x(1);
g(6)=0.25-x(3);
g(7)=x(3)-0.33;
g(8)=x(2)-40;
g(9)=x(1)-10;
g(10)=11-x(2);
q=[];

options=optimset(&#039;largescale&#039;,&#039;off&#039;);x0=[4,14,0.3];[x,fval]=fmincon(@gear,x0,[ ],[ ],[ ],[ ],[ ],[ ],@mycon,options);please give me help ,thanks.</description>
		<content:encoded><![CDATA[<p>ti have the problem:Maximum number of function evaluations exceeded;<br />
increase OPTIONS.MaxFunEvals.<br />
my function as follows:</p>
<p>function f=gear(x)<br />
f=1*0.7408*x(1)^3*x(2)^3*x(3)*[1+(1-x(3))^2+(1-x(3))]+0*[-1.88+4.858/x(2)]<br />
function [g,q]=mycon(x)<br />
g(1)=160057/[x(1)^3*x(2)^3*(1-0.5*x(3))^2*x(3)]^(-0.5)-664;<br />
g(2)=398121*x(1)^(-3)*x(2)^(-2)*(1-0.5*x(3))^(-2)*x(3)^(-1)-480;<br />
g(3)=358848*x(1)^(-3)*x(2)^(-2)*(1-0.5*x(3))^(-2)*x(3)^(-1)-464;<br />
g(4)=-0.48+4.858/x(2);<br />
g(5)=4-x(1);<br />
g(6)=0.25-x(3);<br />
g(7)=x(3)-0.33;<br />
g(8)=x(2)-40;<br />
g(9)=x(1)-10;<br />
g(10)=11-x(2);<br />
q=[];</p>
<p>options=optimset(&#8216;largescale&#8217;,'off&#8217;);x0=[4,14,0.3];[x,fval]=fmincon(@gear,x0,[ ],[ ],[ ],[ ],[ ],[ ],@mycon,options);please give me help ,thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-29871</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Tue, 18 Nov 2008 12:49:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-29871</guid>
		<description>Ben-

What you mention is not about the quality of the objective function itself.  In fact, when I run the problem in R2008b, I get a warning before I get my answer:

&lt;pre class=&#039;code&#039;&gt;
Warning: Trust-region-reflective method does not currently solve this type of problem,
 using active-set (line search) instead. 
&gt; In fmincon at 437
Optimization terminated: first-order optimality measure less
 than options.TolFun and maximum constraint violation is less
 than options.TolCon.
&lt;/pre&gt;

which hints at the answer (and the problem as posed, perhaps) needing scrutiny. 

--loren</description>
		<content:encoded><![CDATA[<p>Ben-</p>
<p>What you mention is not about the quality of the objective function itself.  In fact, when I run the problem in R2008b, I get a warning before I get my answer:</p>
<pre class='code'>
Warning: Trust-region-reflective method does not currently solve this type of problem,
 using active-set (line search) instead.
> In fmincon at 437
Optimization terminated: first-order optimality measure less
 than options.TolFun and maximum constraint violation is less
 than options.TolCon.
</pre>
<p>which hints at the answer (and the problem as posed, perhaps) needing scrutiny. </p>
<p>&#8211;loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-29870</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Tue, 18 Nov 2008 09:17:54 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/loren/2008/07/08/help-i-got-the-wrong-answer-for-my-optimization/#comment-29870</guid>
		<description>It&#039;s worth pointing out that fmincon (R2007b) can get stuck at the initial point even for &quot;nice&quot; functions, like

&gt;&gt;fmincon(@cos,0,[],[],[],[],-1,1)

which returns 0 the local maximum.  Not that we&#039;d do that in practice though :)</description>
		<content:encoded><![CDATA[<p>It&#8217;s worth pointing out that fmincon (R2007b) can get stuck at the initial point even for &#8220;nice&#8221; functions, like</p>
<p>&gt;&gt;fmincon(@cos,0,[],[],[],[],-1,1)</p>
<p>which returns 0 the local maximum.  Not that we&#8217;d do that in practice though :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

