fllzx_2004
2008-09-05, 13:44
请教一下各位英雄:
我写了一个关于优化问题的东西,M文件opt25_3o.m为:
function f=myfun(x)
f=0.192457*10^(-4)*(x(2)+2)*x(1)^2*x(3)
M文件opt25_3c.m为:
function [c,ceq]=mycon(x)
c(1)=350-163*x(1)^(-2.86)*x(3)^(0.86);
c(2)=10-0.4*0.01*x(1)^(-4)*x(2)*x(3)^3;
c(3)=(x(2)+1.5)*x(1)+0.44*0.01*x(1)^(-4)*x(2)*x(3)^3-3.7*x(3);
c(4)=375-0.356*10^6*x(1)*x(2)^(-1)*x(3)^(-2);
c(5)=4-x(3)/x(1);
然后在命令窗口写的为:
A=[-1 0 0;1 0 0;0 -1 0;0 1 0;0 0 -1;0 0 1];
>> b=[-1;4;-4.5;50;;-10;30];
>> x0=[2.0; 5.0; 25.0];
>> lb=zeros(3,1);
>> [x,fval,exitflag,output,lambda]=fmincon(@opt25_3o,x0,A,b,[],[],lb,[],@opt25_3c)
可是结果有问题,显示为:
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 274
f =
0.0135
??? 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 "D:\matlab\work\opt25_3c.m (opt25_3c)".
这是怎么回事啊?应该怎么解决呢?
谢谢
我写了一个关于优化问题的东西,M文件opt25_3o.m为:
function f=myfun(x)
f=0.192457*10^(-4)*(x(2)+2)*x(1)^2*x(3)
M文件opt25_3c.m为:
function [c,ceq]=mycon(x)
c(1)=350-163*x(1)^(-2.86)*x(3)^(0.86);
c(2)=10-0.4*0.01*x(1)^(-4)*x(2)*x(3)^3;
c(3)=(x(2)+1.5)*x(1)+0.44*0.01*x(1)^(-4)*x(2)*x(3)^3-3.7*x(3);
c(4)=375-0.356*10^6*x(1)*x(2)^(-1)*x(3)^(-2);
c(5)=4-x(3)/x(1);
然后在命令窗口写的为:
A=[-1 0 0;1 0 0;0 -1 0;0 1 0;0 0 -1;0 0 1];
>> b=[-1;4;-4.5;50;;-10;30];
>> x0=[2.0; 5.0; 25.0];
>> lb=zeros(3,1);
>> [x,fval,exitflag,output,lambda]=fmincon(@opt25_3o,x0,A,b,[],[],lb,[],@opt25_3c)
可是结果有问题,显示为:
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 274
f =
0.0135
??? 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 "D:\matlab\work\opt25_3c.m (opt25_3c)".
这是怎么回事啊?应该怎么解决呢?
谢谢