´ó¼ÒºÃ£¬×î½ü³¢ÊÔÁËÒ»ÏÂÒÅ´«Ëã·¨£¬³õʼÖÖȺÊÇϵͳËæ»ú³éÈ¡µÄ£¬ÒÔÖÂÓÚÿ´ÎËã³öÀ´µÄ½á¹û¶¼²»Ì«Ò»Ñù¡£±¾À´Ïë˵ͨ¹ýÒÅ´«Ëã·¨µÃµ½½Ó½üÈ«¾Ö×îÓŵĽ⣬½á¹ûÕâЩ½âºÃÏñ¶¼ÊǾֲ¿×îÓÅ¡£ÓÚÊdz¢ÊÔÁËÒ»¸öÈ«¾Ö×îÓŵÄËã·¨£¬ÏÈ×öÁ˸öСʵÑ飬µ«²»³É¹¦¡£Ï£Íû´óÏÀÃÇ°ïæ¿´¿´ÎÊÌâ³öÔÚÄÄÀïÁË£¬²»Ê¤¸Ð¼¤£¡
¶ÔÓÚÒÅ´«Ëã·¨ºÜÊìϤµÄÅóÓÑ£¬Ò²Ïò´ó¼ÒÇë½ÌÒ»ÏÂÔÚʹÓÃÒÅ´«Ë㷨ʱµ±×¢ÒâʲôÎÊÌ⣬ÔõôʹµÃµ½µÄ½âÄܱȽϽӽüÈ«¾Ö×îÓÅ¡£Ð»Ð»£¡
function main
clear all
close all
clc
A=[];b=[];
Aeq=[];beq=[];
lb=[0.2;0.1];
ub=[4.0;1.6];
x0=[2.5;1.0];
opts1 = optimset('Algorithm','interior-point');
opts2 = optimset('Algorithm','sqp');
opts3 = optimset('Algorithm','trust-region-reflective');
opts4 = optimset('Algorithm','active-set');
problem1 = createOptimProblem('fmincon','objective',...
@objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts1);
problem2 = createOptimProblem('fmincon','objective',...
@objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts2);
problem3 = createOptimProblem('fmincon','objective',...
@objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts3);
problem4 = createOptimProblem('fmincon','objective',...
@objfun,'x0',x0, 'Aineq', A, 'bineq', b, 'nonlcon', @mycon, 'options',opts4);
gs = GlobalSearch;
[x1,fval1] = run(gs,problem1);
[x2,fval2] = run(gs,problem2);
[x3,fval3] = run(gs,problem3);
[x4,fval4] = run(gs,problem4);
end
% objective function
function f0=objfun(x)
f0=x(1)*sqrt(1.0+x(2)^2);
end
% constraint function
function [f,ceq]=mycon(x)
f=(0.124*(8.0/x(1)+1.0/(x(1)*x(2)))*sqrt(1.0+x(2)^2))-1.0;
ceq=[];
end
ÔËÐкóµÃµ½
GlobalSearch stopped because it analyzed all the trial points.
1 out of 39 local solver runs converged with a positive local solver exit flag.
No solution found.
GlobalSearch did not find any solutions after 399 local solver runs.
Warning: The default trust-region-reflective algorithm does not solve problems
with the constraints you have specified. FMINCON will use the active-set
algorithm instead. For information on applicable algorithms, see Choosing the
Algorithm in the documentation.
> In fmincon at 486
In C:\Program Files\MATLAB\R2011b\toolbox\globaloptim\globaloptim\private\globalsearchnlp.p>globalsearchnlp at 152
In GlobalSearch>GlobalSearch.run at 330
GlobalSearch stopped with one or more of the local solver runs stopping prematurely.
15 out of 39 local solver runs exceeded the iteration limit (problem.options.MaxIter) or
the function evaluation limit (problem.options.MaxFunEvals).
None of the 39 local solver runs converged with a positive local solver exit flag.
GlobalSearch stopped with one or more of the local solver runs stopping prematurely.
13 out of 36 local solver runs exceeded the iteration limit (problem.options.MaxIter) or
the function evaluation limit (problem.options.MaxFunEvals).
None of the 36 local solver runs converged with a positive local solver exit flag.
ÕâÊÇΪʲôÄØ? |