关于matlab最优化中fmincon函数

问题描述:

关于matlab最优化中fmincon函数
主程序如下:
x0=[0.17352;-0.33959;3.2403;3.043;-0.046951;6.8701e-011];
A=[-1,0,0,0,0,0;0,-1,0,0,0,0;0,0,-1,0,0,0;0,0,0,-1,0,0;0,0,0,0,-1,0;0,0,0,0,0,-1];
b=zeros(6,1);
[x,fval]=fmincon(@myfun11,x0,A,b,[],[],[],[],@opt115)
辅助函数如下:
function [c,ceq]=opt115(x)
c(1)=-x(1);
c(2)=-x(2);
c(3)=-x(3);
c(4)=-x(4);
主函数就省去了
出现如下问题:
Error using ==> fmincon
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:
Output argument "ceq" (and maybe others) not assigned during call to "C:\Documents and Settings\Administrator\桌面\fmincon优化程序\opt115.m (opt115)".
Error in ==> main at 8
[x,fval]=fmincon(@myfun11,x0,A,b,[],[],[],[],@opt115)
希望朋友们帮忙给看下,
1个回答 分类:综合 2014-10-22

问题解答:

我来补答
nonlinear constraint function(非线性约束辅助函数)改成
function [c,ceq]=opt115(x)
c(1)=-x(1);
c(2)=-x(2);
c(3)=-x(3);
c(4)=-x(4);
cep=[];
 
 
展开全文阅读
剩余:2000
下一页:老师第一十三题