如何将 trust-region-reflective essayalgorithm 换为 active-set algorithm

查看: 222|回复: 1
阅读权限20威望0 级论坛币80 个学术水平4 点热心指数4 点信用等级4 点经验716 点帖子59精华0在线时间29 小时注册时间最后登录
积分 142, 距离下一级还需 3 积分
权限: 自定义头衔
道具: 彩虹炫, 雷达卡, 热点灯, 雷鸣之声, 涂鸦板, 金钱卡, 显身卡下一级可获得
道具: 匿名卡
购买后可立即获得
权限: 隐身
道具: 金钱卡, 雷鸣之声, 彩虹炫, 雷达卡, 涂鸦板, 热点灯
本帖最后由 leslie133 于
12:45 编辑
12:38:08 上传
目标函数:maxW'HW,H为N*N的方阵,约束条件为:W’W=1,W&0,求解W
matlab版本是R2010b。
程序如下:
function x=main(H)
v1=zeros(N,1);
v2=ones(N,1);
x0=[zeros(N-1,1);1];
x=fmincon(@objfun1,x0,[],[],[],[],v1,v2,@consfun1,opt);& &
& &function f=objfun1(x)
& && &&&f=-x'*H*x;
& & function [c1,c2]=consfun1(x)
& && &&&c1=[];
& && &&&c2=x'*x-1;
运行之后出现:Warning: Trust-region-reflective algorithm does not solve this type of problem, using active-set algorithm. Youcould also try the interior-point or sqp algorithms: set the Algorithm option to 'interior-point' or 'sqp' andrerun. For more help, see Choosing the Algorithm in the documentation.
& In fmincon at 472
&&In main at 6
Local minimum possible. Constraints satisfied.
fmincon stopped because the size of the current search direction is less thantwice the default value of the step size tolerance and constraints were satisfied to within the default value of the constraint tolerance.
&stopping criteria details&
Active inequalities (to within options.TolCon = 1e-006):
&&lower& && &upper& &&&ineqlin& &ineqnonlin
& &-0.0000
& &-0.0000
& & 0.0000
& & 0.1650
& & 0.0000
& & 0.0200
& & 0.0738
& & 0.0862
& & 0.0020
& & 0.2012
& & 0.2933
& & 0.1685
& & 0.2939
& & 0.2910
& & 0.0000
& & 0.0000
& & 0.1943
& & 0.0561
& & 0.0000
& & 0.0000
& & 0.2886
& & 0.2374
& & 0.2950
& &-0.0000
& & 0.2511
& & 0.2241
& & 0.2893
& & 0.2772
这儿的c值也就是W值还满足约束条件吗?如果有错应该怎么改?
支持楼主:、
购买后,论坛将把您花费的资金全部奖励给楼主,以表示您对TA发好贴的支持
载入中......
阅读权限20威望0 级论坛币80 个学术水平4 点热心指数4 点信用等级4 点经验716 点帖子59精华0在线时间29 小时注册时间最后登录
积分 142, 距离下一级还需 3 积分
权限: 自定义头衔
道具: 彩虹炫, 雷达卡, 热点灯, 雷鸣之声, 涂鸦板, 金钱卡, 显身卡下一级可获得
道具: 匿名卡
购买后可立即获得
权限: 隐身
道具: 金钱卡, 雷鸣之声, 彩虹炫, 雷达卡, 涂鸦板, 热点灯
还是说这个不是非线性规划的问题而是其他的?
论坛好贴推荐查看: 2561|回复: 2
阅读权限20威望0 级论坛币176 个学术水平5 点热心指数5 点信用等级5 点经验583 点帖子34精华0在线时间66 小时注册时间最后登录
积分 124, 距离下一级还需 21 积分
权限: 自定义头衔
道具: 彩虹炫, 雷达卡, 热点灯, 雷鸣之声, 涂鸦板, 金钱卡, 显身卡下一级可获得
道具: 匿名卡
购买后可立即获得
权限: 隐身
道具: 金钱卡, 雷鸣之声, 彩虹炫, 雷达卡, 涂鸦板, 热点灯
开心签到天数: 1 天连续签到: 1 天[LV.1]初来乍到
本帖最后由 T-back 于
19:54 编辑
min f(x1,x2,x3)=x1^2+x2^2+x3^2+x1*x2+x1*x3+x2*x3
s.t.: x1+x2+x3=1 , x1&=0,x2&=0,x3&=0
请问各位,此约束问题如何用Matlab编程实现,谢谢帮助!
载入中......
阅读权限20威望0 级论坛币503 个学术水平8 点热心指数10 点信用等级1 点经验3895 点帖子58精华0在线时间58 小时注册时间最后登录
积分 125, 距离下一级还需 20 积分
权限: 自定义头衔
道具: 彩虹炫, 雷达卡, 热点灯, 雷鸣之声, 涂鸦板, 金钱卡, 显身卡下一级可获得
道具: 匿名卡
购买后可立即获得
权限: 隐身
道具: 金钱卡, 雷鸣之声, 彩虹炫, 雷达卡, 涂鸦板, 热点灯
&& f=@(x1,x2,x3)x1.^2+x2.^2+x3.^2+x1.*x2+x1.*x3+x2.*x3;
&& Aeq =[1,1,1];beq = 1;
&& x = fmincon(@(x)f(x(1),x(2),x(3)),[0.4,0.3,0.3],[],[],Aeq,beq,[0 0 0 ],[])
Warning: Trust-region-reflective algorithm does not solve this type of problem, using active-set
algorithm. You could also try the interior-point or sqp algorithms: set the Algorithm option to
'interior-point' or 'sqp' and rerun. For more help, see Choosing the Algorithm in the documentation.
& In fmincon at 472
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
&stopping criteria details&
No active inequalities.
& & 0.3333& & 0.3333& & 0.3333复制代码
分析的有道理
总评分:&学术水平 + 1&
阅读权限20威望0 级论坛币176 个学术水平5 点热心指数5 点信用等级5 点经验583 点帖子34精华0在线时间66 小时注册时间最后登录
积分 124, 距离下一级还需 21 积分
权限: 自定义头衔
道具: 彩虹炫, 雷达卡, 热点灯, 雷鸣之声, 涂鸦板, 金钱卡, 显身卡下一级可获得
道具: 匿名卡
购买后可立即获得
权限: 隐身
道具: 金钱卡, 雷鸣之声, 彩虹炫, 雷达卡, 涂鸦板, 热点灯
开心签到天数: 1 天连续签到: 1 天[LV.1]初来乍到
论坛好贴推荐matlab编的有关响应面的程序,为什么运行出问题,求高手解决_百度知道
matlab编的有关响应面的程序,为什么运行出问题,求高手解决
function zdglobal Mu Sigama
%定义全局变量Mu=[10 2.5];
%输入平均值Sigama=[2 0.375];
%输入标准差X0=[1 1];
%输入初始迭代点A=[];b=[];Aeq=[];beq=[];lb=[];ub=[];[X,fval,exitflag,output]=fmincon(@bata2,X0,A,b,Aeq,beq,lb,ub,@st);
%调用优化工具箱求解bata=sqrt(fval);Pf=cdf('norm',-bata,0,1)
%计算失效概率function CC=bata2(X);
%目标函数函数global Mu Sigama
%定义全局变量CC=((X(1)-Mu(1))/Sigama(1))^2+((X(2)-Mu(2))/Sigama(2))^2;
function [c,ceq]=st(X)
%约束条件函数c=[];
%非线性等式约束ceq=xym(X);
%非线性等式约束function Z=xym(X)
%响应面函数函数A1=[1.0 2.0 6.2500;
1.0 2.0 6.2500;
1.0 2.0 6.2500;
1.0 3.0 13.1406;
1.0 1.0 1.8906];B1=[13.5;16.7;-10.3136];C=A1\B1; %求解二响应面函数各项系数Z=C(1)+C(2)*X(1)+C(3)*X(2)+C(4)*X(1)^2+C(5)*X(2)^2;
%计算功能函数值运行候现面问题Warning: The default trust-region-reflective algorithm does not solve problems with theconstraints you have specified. FMINCON will use the active-set algorithm instead. Forinformation on applicable algorithms, see Choosing the Algorithm in the documentation. & In fmincon at 486
In jianlind at 8 Local minimum found that satisfies the constraints.Optimization completed because the objective function is non-decreasing in feasible directions, to within the default value of the function tolerance,and constraints are satisfied to within the default value of the constraint tolerance.&stopping criteria details&
运算结fmincon语句加&;&掉
 运行是有结果,但是也有一个warning警告,和说是局部最优解Local minimum possible. Constraints satisfied  &stopping criteria details&.的,望大师能给我分析一下,谢谢了 
Local minimum possible. Constraints satisfied说明达到局部最优解,各约束都满足。点击&stopping criteria details&可看详情
其他类似问题
matlab的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁查看: 1053|回复: 10
使用fmincon函数后报错:If FUN is a MATLAB object, it must have an fev...
syms ifa1 ifa2
BER=10^-3;
PMAX=10^4;
c3=0.2831;
G1=[0.0;0.0];%子信道1的信道增益
G2=[0.7;0.0];%子信道2的信道增益
GAMA11=(2^(ifa1*R1/W)-1)/c3;
GAMA21=(2^((1-ifa1)*R1/W)-1)/c3;
GAMA12=(2^(ifa2*R2/W)-1)/c3;
GAMA22=(2^((1-ifa2)*R2/W)-1)/c3;
P11=(GAMA12*G1(2,1)+G1(2,2))*GAMA11*N0/(G1(1,1)*G1(2,2)-GAMA11*GAMA12*G1(1,2)*G1(2,1));
P21=(GAMA22*G2(2,1)+G2(2,2))*GAMA21*N0/(G2(1,1)*G2(2,2)-GAMA21*GAMA22*G2(1,2)*G2(2,1));& &
P12=(GAMA11*G1(1,2)+G1(1,1))*GAMA12*N0/(G1(1,1)*G1(2,2)-GAMA11*GAMA12*G1(1,2)*G1(2,1));& &&&
P22=(GAMA21*G2(1,2)+G2(1,1))*GAMA22*N0/(G2(1,1)*G2(2,2)-GAMA21*GAMA22*G2(1,2)*G2(2,1));
P1=P11+P21;
P2=P12+P22;
P1A=matlabFunction(P1);
P2A=matlabFunction(P2);
R12=zeros(40,1);
R11=zeros(40,1);
R122=zeros(40,1);
R112=zeros(40,1);
ifaseq=zeros(40,1);
ifaseq2=zeros(40,1);
P1J=zeros(40,1);
P2J=zeros(40,1);
aa2=zeros(40,1);
P1A=matlabFunction(P1);
P2A=matlabFunction(P2);
%&&指定ifa1之后求解P2关于ifa2的最佳反应
for i=1:40
&&ifa10=0.01;
&&[s2,P2J]=fmincon(P2A(i/40,ifa2),ifa10,[],[],[],[],0,1,@conifa1);
%用此函数求解的极小值可能不是全局最小
&&ifaseq2(i)= s2;
&&R112(i)=R1*i/40;
& &R122(i)=s2*R2;
plot(R122,R112,'r');
function&&[c,ceq]=conifa1(x)
c3=0.2831;
G1=[0.0;0.0];%子信道1的信道增益
G2=[0.7;0.0];%子信道2的信道增益
c(1)=(-G1(1,1)*G1(2,2)+(2^(x*R1/W)-1)/c3*(2^(aa2*R2/W)-1)/c3*G1(1,2)*G1(2,1));
c(2)=(-G2(1,1)*G2(2,2)+(2^((1-x)*R1/W)-1)/c3*(2^((1-aa2)*R2/W)-1)/c3*G2(1,2)*G2(2,1));
运行后报错
Error using optimfcnchk (line 288)
If FUN is a MATLAB object, it must have an feval method.
Error in fmincon (line 427)
& &funfcn =
& &optimfcnchk(FUN,'fmincon',length(varargin),funValCheck,flags.grad,flags.hess,false,Algorithm);
Error in test (line 36)
&&[s2,P2J]=fmincon(P2A(i/40,ifa2),ifa10,[],[],[],[],0,1,@conifa1);
%用此函数求解的极小值可能不是全局最小
我运行了一下P1A和P2A,是匿名函数啊,符合fmincon参数设置要求。请各位相助,多谢啦。
& & @(ifa1,ifa2)((2.0.^(ifa1.*(6.0./5.0)).*3.713-3.713).*(2.0.^(ifa2.*(6.0./5.0)).*9.053e-3+2.209e-1).*(-1.0./1.0e3))./((2.0.^(ifa1.*(6.0./5.0)).*3.713-3.713).*(2.0.^(ifa2.*(6.0./5.0)).*3.713-3.713).*2.6e-5-1.33772e-2)-((2.0.^(ifa1.*(-6.0./5.0)+6.0./5.0).*3.713-3.713).*(2.0.^(ifa2.*(-6.0./5.0)+6.0./5.0).*1.587e-2+9.041e-1).*(1.0./1.0e3))./((2.0.^(ifa1.*(-6.0./5.0)+6.0./5.0).*3.713-3.713).*(2.0.^(ifa2.*(-6.0./5.0)+6.0./5.0).*3.713-3.713).*1.943e-5-4.)
& & @(ifa1,ifa2)((2.0.^(ifa2.*(6.0./5.0)).*3.713-3.713).*(2.0.^(ifa1.*(6.0./5.0)).*3.713e-2+2.287e-2).*(-1.0./1.0e3))./((2.0.^(ifa1.*(6.0./5.0)).*3.713-3.713).*(2.0.^(ifa2.*(6.0./5.0)).*3.713-3.713).*2.6e-5-1.33772e-2)-((2.0.^(ifa2.*(-6.0./5.0)+6.0./5.0).*3.713-3.713).*(2.0.^(ifa1.*(-6.0./5.0)+6.0./5.0).*2.218e-2+4.578e-1).*(1.0./1.0e3))./((2.0.^(ifa1.*(-6.0./5.0)+6.0./5.0).*3.713-3.713).*(2.0.^(ifa2.*(-6.0./5.0)+6.0./5.0).*3.713-3.713).*1.943e-5-4.)
P2A 是函数句柄,但是,P2A(i/40,ifa2)不是
换成: @(ifa2) P2A(i/40,ifa2) 试试
P2A 是函数句柄,但是,P2A(i/40,ifa2)不是
换成: @(ifa2) P2A(i/40,ifa2) 试试
多谢,这个成功了,但是又出现新问题,在约束条件文件当中,我使用了主文件中的一个数值aa1,这个需要根据for语句不断更新的,所以不能在约束条件当中指定具体的值,但是matlab报错了,说这个函数没有定义。我再贴给你看看,具体请看我下面的回复,多谢了、
主程序文件
syms ifa1 ifa2
BER=10^-3;
PMAX=10^4;
c3=0.2831;
G1=[0.0;0.0];%子信道1的信道增益
G2=[0.7;0.0];%子信道2的信道增益
GAMA11=(2^(ifa1*R1/W)-1)/c3;
GAMA21=(2^((1-ifa1)*R1/W)-1)/c3;
GAMA12=(2^(ifa2*R2/W)-1)/c3;
GAMA22=(2^((1-ifa2)*R2/W)-1)/c3;
P11=(GAMA12*G1(2,1)+G1(2,2))*GAMA11*N0/(G1(1,1)*G1(2,2)-GAMA11*GAMA12*G1(1,2)*G1(2,1));
P21=(GAMA22*G2(2,1)+G2(2,2))*GAMA21*N0/(G2(1,1)*G2(2,2)-GAMA21*GAMA22*G2(1,2)*G2(2,1));& &
P12=(GAMA11*G1(1,2)+G1(1,1))*GAMA12*N0/(G1(1,1)*G1(2,2)-GAMA11*GAMA12*G1(1,2)*G1(2,1));& &&&
P22=(GAMA21*G2(1,2)+G2(1,1))*GAMA22*N0/(G2(1,1)*G2(2,2)-GAMA21*GAMA22*G2(1,2)*G2(2,1));
P1=P11+P21;
P2=P12+P22;
P1A=matlabFunction(P1);
P2A=matlabFunction(P2);
R12=zeros(40,1);
R11=zeros(40,1);
R122=zeros(40,1);
R112=zeros(40,1);
ifaseq=zeros(40,1);
ifaseq2=zeros(40,1);
P1J=zeros(40,1);
P2J=zeros(40,1);
aa2=zeros(40,1);
P1A=matlabFunction(P1);
P2A=matlabFunction(P2);
%&&指定ifa1之后求解P2关于ifa2的最佳反应
for i=1:40
&&ifa10=0.01;
&&aa1=i/40;
&&[s2,P2J]=fmincon(@(ifa2)P2A(i/40,ifa2),ifa10,[],[],[],[],0,1,@conifa1);&&%用此函数求解的极小值可能不是全局最小
&&ifaseq2(i)= s2;
&&R112(i)=R1*i/40;
& &R122(i)=s2*R2;
plot(R122,R112,'r');
约束函数文件
function&&[c,ceq]=conifa1(x)
c3=0.2831;
G1=[0.0;0.0];%子信道1的信道增益
G2=[0.7;0.0];%子信道2的信道增益
c(1)=(-G1(1,1)*G1(2,2)+(2^(aa1*R1/W)-1)/c3*(2^(x*R2/W)-1)/c3*G1(1,2)*G1(2,1));
c(2)=(-G2(1,1)*G2(2,2)+(2^((1-aa1)*R1/W)-1)/c3*(2^((1-x)*R2/W)-1)/c3*G2(1,2)*G2(2,1));
此回复为最佳答案|
约束函数文件
function&&[c,ceq]=conifa1(x)
把 aa1 以函数参数的形式传入 conifa1,然后按照刚才目标函数的定义法,重新定义约束函数为 x 的函数句柄
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 504
&&In test at 39
Warning: Your current settings will run a different algorithm (interior-point) in a future release.
& In fmincon at 509
&&In test at 39
Undefined function or variable 'aa1'.
Error in conifa1 (line 8)
c(1)=(-G1(1,1)*G1(2,2)+(2^(aa1*R1/W)-1)/c3*(2^(x*R2/W)-1)/c3*G1(1,2)*G1(2,1));
Error in fmincon (line 722)
& && &&&[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Error in test (line 39)
&&[s2,P2J]=fmincon(@(ifa2)P2A(i/40,ifa2),ifa10,[],[],[],[],0,1,@conifa1);&&%用此函数求解的极小值可能不是全局最小
Caused by:
& & Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON cannot continue.
把 aa1 以函数参数的形式传入 conifa1,然后按照刚才目标函数的定义法,重新定义约束函数为 x 的函数句柄 ...
谢谢,能给我示例一下吗,我不是太明白
把 aa1 以函数参数的形式传入 conifa1,然后按照刚才目标函数的定义法,重新定义约束函数为 x 的函数句柄 ...
谢谢了,刚才导师找我讨论问题,所以没有能够及时回复。
谢谢,能给我示例一下吗,我不是太明白
约束文件定义改为: function&&[c,ceq]=conifa1(aa1, x)
主函数优化调用部分改为: [s2,P2J]=fmincon(@(ifa2)P2A(i/40,ifa2),ifa10,[],[],[],[],0,1,@(x)conifa1(aa1, x));
Powered byDocumentation
Examples and How To
Choosing a SolverOptimization Decision TableThe following table is designed to help you choose a solver.
It does not address multiobjective optimization or equation solving.
There are more details on all the solvers in .Use the table as follows:Identify your objective function as one of five types:LinearQuadraticSum-of-squares (Least squares)Smooth nonlinearNonsmoothIdentify your constraints as one of five types:None (unconstrained)BoundLinear (including bound)General smoothDiscrete (integer)Use the table to identify a relevant solver.In this table:* means relevant solvers are found in
(licensed separately from Optimization Toolbox™ solvers).fmincon applies to most smooth
objective functions with smooth constraints. It is not listed as a
preferred solver for least squares or linear or quadratic programming
because the listed solvers are usually more efficient.The table has suggested functions, but it is not meant
to unduly restrict your choices. For example, fmincon can
be effective on some nonsmooth problems.The Global Optimization Toolbox
function can address mixed-integer programming
problems.Solvers by Objective and Constraint Constraint
Type Objective Type
LinearQuadraticLeast SquaresSmooth nonlinearNonsmooth
Nonen/a (f =
const, or min = −∞), , , , , , ,
Bound, , , , , , , , , ,
Linear, , , , , *
General smooth, , , , , *
Discrete, ****
This table does not list multiobjective solvers nor equation
solvers. See
a complete list of problems addressed by Optimization Toolbox functions.Note:&&
Some solvers have several algorithms. For help choosing, see .Choosing the Algorithmfmincon Algorithmsfmincon has four algorithm options:'interior-point' (default)'trust-region-reflective''sqp''active-set'Use
the Algorithm option at the command line.Recommendations
Use the 'interior-point' algorithm
first.For help if the minimization fails, see
or .To run an optimization again to obtain more speed
on small- to medium-sized problems, try 'sqp' next,
and 'active-set' last.Use 'trust-region-reflective' when
applicable. Your problem must have: objective function includes gradient,
only bounds, or only linear equality constraints (but not both).See .
Reasoning Behind the Recommendations.&&'interior-point' handles large,
sparse problems, as well as small dense problems. The algorithm satisfies
bounds at all iterations, and can recover from NaN or Inf results.
It is a large- see . The algorithm can
use special techniques for large-scale problems. For details, see .'sqp' satisfies bounds at all iterations.
The algorithm can recover from NaN or Inf results.
It is not a large- see .'active-set' can take large steps,
which adds speed. The algorithm is effective on some problems with
nonsmooth constraints. It is not a large- see .'trust-region-reflective' requires
you to provide a gradient, and allows only bounds or linear equality
constraints, but not both. Within these limitations, the algorithm
handles both large sparse problems and small dense problems efficiently.
It is a large- see . The algorithm can
use special techniques to save memory usage, such as a Hessian multiply
function. For details, see .fsolve Algorithmsfsolve has three algorithms:'trust-region-dogleg' (default)'trust-region-reflective''levenberg-marquardt'Use
the Algorithm option at the command line.Recommendations
Use the 'trust-region-dogleg' algorithm
first.For help if fsolve fails, see
or .To solve equations again if you have a Jacobian multiply
function, or want to tune the internal algorithm (see ),
try 'trust-region-reflective'.Try timing all the algorithms, including 'levenberg-marquardt',
to find the algorithm that works best on your problem.
Reasoning Behind the Recommendations.&&'trust-region-dogleg' is the only
algorithm that is specially designed to solve nonlinear equations.
The others attempt to minimize the sum of squares of the function.The 'trust-region-reflective' algorithm
is effective on sparse problems. It can use special techniques such
as a Jacobian multiply function for large-scale problems.fminunc Algorithmsfminunc has two algorithms:'trust-region' (formerly LargeScale
= 'on'), the default'quasi-newton' (formerly LargeScale
= 'off')Use
the Algorithm option at the command line.Recommendations
If your objective function includes a gradient, use 'Algorithm'&=&'trust-region', and set the GradObj option
to 'on'.Otherwise, use 'Algorithm'&=&'quasi-newton'.For help if the minimization fails, see
Least Squares Algorithmslsqlin.&&lsqlin has three algorithms:'trust-region-reflective' (formerly LargeScale
= 'on'), the default'active-set' (formerly LargeScale
= 'off')'interior-point'Use
the Algorithm option at the command line.Recommendations
If you have no constraints or only bound constraints,
use 'trust-region-reflective'.If you have linear constraints, try 'interior-point' first.For help if the minimization fails, see
lsqcurvefit and lsqnonlin.&&lsqcurvefit and lsqnonlin have
two algorithms:'trust-region-reflective' (default)'levenberg-marquardt'Use
the Algorithm option at the command line.Recommendations
If you have no constraints or only bound constraints,
use 'trust-region-reflective'.If your problem is underdetermined (fewer equations
than dimensions), use 'levenberg-marquardt'.For help if the minimization fails, see
Linear Programming Algorithmslinprog has four algorithms:'interior-point' (formerly LargeScale
= 'on'), the default'dual-simplex''active-set' (formerly LargeScale
= 'off')'simplex' (formerly LargeScale
= 'off', Simplex = 'on')Use
the Algorithm option at the command line.Recommendations
Use the 'interior-point' algorithm
or the 'dual-simplex' algorithm.For
help if the minimization fails, see
Reasoning Behind the Recommendations.&&Both the 'interior-point' and 'dual-simplex' algorithms
are large-scale algorithms, while the other two are not. See .Generally, the 'interior-point' and 'dual-simplex' algorithms
are faster and use less memory than the other two algorithms.The 'active-set' and 'simplex' algorithms
will be removed in a future release.Quadratic Programming Algorithmsquadprog has three algorithms:'interior-point-convex' (default)'trust-region-reflective' (formerly LargeScale
= 'on')'active-set' (formerly LargeScale
= 'off').Use
the Algorithm option at the command line.Recommendations
If you have a convex problem, or if you don't know
whether your problem is convex, use 'interior-point-convex'.If you have a nonconvex problem with only bounds,
or with only linear equalities, use 'trust-region-reflective'.If you have a nonconvex problem that does not satisfy
the restrictions of 'trust-region-reflective', use 'active-set'.For help if the minimization fails, see
Large-Scale vs. Medium-Scale AlgorithmsAn optimization algorithm is large scale when
it uses linear algebra that does not need to store, nor operate on,
full matrices. This may be done internally by storing sparse matrices,
and by using sparse linear algebra for computations whenever possible.
Furthermore, the internal algorithms either preserve sparsity, such
as a sparse Cholesky decomposition, or do not generate matrices, such
as a conjugate gradient method.In contrast, medium-scale methods internally
create full matrices and use dense linear algebra. If a problem is
sufficiently large, full matrices take up a significant amount of
memory, and the dense linear algebra may require a long time to execute.Don't let the name "large scale"
you can use a large-scale algorithm on a small problem. Furthermore,
you do not need to specify any sparse matrices to use a large-scale
algorithm. Choose a medium-scale algorithm to access extra functionality,
such as additional constraint types, or possibly for better performance.Potential Inaccuracy with Interior-Point AlgorithmsInterior-point algorithms in fmincon, quadprog,
and linprog have many good characteristics, such
as low memory usage and the ability to solve large problems quickly.
However, their solutions can be slightly less accurate than those
from other algorithms. The reason for this potential inaccuracy is
that the (internally calculated) barrier function keeps iterates away
from inequality constraint boundaries.For most practical purposes, this inaccuracy is usually quite
small.To reduce the inaccuracy, try to:Rerun the solver with smaller TolX, TolFun,
and possibly TolCon tolerances (but keep the tolerances
sensible.) See ).Run a different algorithm, starting from the interior-point
solution. This can fail, because some algorithms can use excessive
memory or time, and some linprog and quadprog algorithms
do not accept an initial point.For example, try to minimize the function x when
bounded below by 0. Using the fmincon interior-point algorithm:options = optimoptions(@fmincon,'Algorithm','interior-point','Display','off');
x = fmincon(@(x)x,1,[],[],[],[],0,[],[],options)x =
2.0000e-08Using the fmincon sqp algorithm:options.Algorithm = 'sqp';
x2 = fmincon(@(x)x,1,[],[],[],[],0,[],[],options)x2 =
0Similarly, solve the same problem using the linprog interior-point algorithm:opts = optimoptions(@linprog,'Display','off','Algorithm','interior-point');
x = linprog(1,[],[],[],[],0,[],1,opts)x =
2.0833e-13Using the linprog simplex algorithm:opts.Algorithm = 'simplex';
x2 = linprog(1,[],[],[],[],0,[],1,opts)x2 =
0In these cases, the interior-point algorithms
are less accurate, but the answers are quite close to the correct
answer.Problems Handled by Optimization Toolbox FunctionsThe following tables show the functions available for minimization,
equation solving, multiobjective optimization, and solving least-squares
or data-fitting problems.Minimization ProblemsTypeFormulationSolver
Scalar minimization minxf(x)such that lb&&&x&&&ub (x is
Unconstrained minimizationminxf(x),
Linear programmingminxfTxsuch that
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub
Mixed-integer linear programmingminxfTxsuch that
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub, x(intcon)
is integer-valued.
Quadratic programmingminx12xTHx+cTx such that
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub
Constrained minimizationminxf(x)such that
c(x)&≤&0,
ceq(x)&=&0,
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub
Semi-infinite minimizationminxf(x)such that
K(x,w)&≤&0&for&all&w,
c(x)&≤&0,
ceq(x)&=&0,
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub
Multiobjective ProblemsTypeFormulationSolver
Goal attainmentminx,γγsuch that
F(x)&–&w&γ&≤&goal,
c(x)&≤&0,
ceq(x)&=&0,
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub
MinimaxminxmaxiFi(x)such that
c(x)&≤&0,
ceq(x)&=&0,
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub
Equation Solving ProblemsTypeFormulationSolver
Linear equationsC&x = d, n equations, n variables (matrix left division)
Nonlinear equation of one variablef(x)
Nonlinear equationsF(x)
= 0, n equations, n variables
Least-Squares (Model-Fitting) ProblemsTypeFormulationSolver
Linear least-squaresmin⁡x12‖C⋅x−d‖22m equations, n variables (matrix left division)
Nonnegative linear-least-squaresmin⁡x12‖C⋅x−d‖22such that x&≥&0
Constrained linear-least-squaresmin⁡x12‖C⋅x−d‖22such that
A&x&≤&b,
Aeq&x&=&beq,
lb&≤&x&≤&ub
Nonlinear least-squaresminx‖F(x)‖22=minx∑iFi2(x)such that
lb&≤&x&≤&ub
Nonlinear curve fittingminx‖F(x,xdata)−ydata‖22such that
lb&≤&x&≤&ub
Was this topic helpful?

我要回帖

更多关于 reflective index 的文章

 

随机推荐