Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: fmincon initial point problem
Posted:
Mar 18, 2013 10:52 AM
|
|
On 3/18/2013 10:08 AM, Haemish wrote: > Dear sir, > > I have some questions on fmincon initial value problem. > > The code belows are very simple one which find the minimum value. > > That is finding x^2+y^2+z^2+75 when lb=[0 0 0] and ub=[5 5 5] > with constraint of x+y+z=8 > > I think that even such a simple problem depends on the initial value > strongly. > > Initial point [0 0 0] gives the answer [2.667 2.667 2.667] but initial > point [0 1 1] gives the answer [0 4 4]. However I know that the answer > is [0 3 5] (irrespective the [x y z] sequence). > > I think that this is convex quadratic problem but fmincon minimization > answer should be found uniquely. > Are there any problems on my probelm definition? And are there any > tips to overcome fmincon initial value problem except for random > initial value startings? > > Sincerely yours > > Thank you. > > ----------------------------- code > ---------------------------------------- > %main.m > optNLP = optimset( 'UseParallel','always','Algorithm', > 'active-set','Display','iter-detailed','TolX',1e-10,'TolFun',1e-15,'TolCon',1e-20,'MaxFunEval',10000,'MaxIter',1000000,'DiffMinChange',1e-15 > ); > pCOM0 = [0 5 5]'; > lb = [0*ones(3,1)]; ub = > [5*ones(3,1)]; [popt, Jopt, > exitflag,output,labda,grad,hessian] = fmincon( @(p)obj(p), pCOM0,[], > [], [], [], lb, ub, @(p)ctr(p), optNLP) > > %ctr.m > function [c,ceq] = ctr(p) > ceq=sum(p)-8; > c=[]; > end > > %obj.m > function Y = obj(p) > Y = -p(1).^2-p(2).^2-p(3).^2+75; > end
You are finding a maximum, not a minimum, with your objective function. That is the result when you take -sum(p.^2) as the objective instead of sum(p.^2). See http://www.mathworks.com/help/optim/ug/writing-objective-functions.html#brhkghv-5
Also, your options settings are not very good. In particular, setting TolCon to 1e-20 is the same as setting it to zero, which can cause problems for fmincon. And setting DiffMinChange to 1e-15 makes no sense at all, leave it at the default value, and use centered finite differences if you want more accuracy (set FinDiffType to 'centered'). See http://www.mathworks.com/help/optim/ug/tolerances-and-stopping-criteria.html
Good luck,
Alan Weiss MATLAB mathematical toolbox documentation
|
|
|
|