3050312039
2009-05-25, 09:02
首先编制目标函数的M文件myfun.m:
function f=myfun(x)
f=(pi/16)*x(1) ^2* x (3) ^2*x (2) * (4 + (4. 64 - 2) ^2*3);
再编写非线性约束函数的M文件mycon.m:
function [c,ceq]=mycon(x)
g(1)= 17-x(1);
g(2)=2-x(3);
g(3)=10-x(2);
g(4)=5*x(3)-x(2);
g(5)=x(2)-17* x (3);
g(6)=-(4.64/2)*sin(pi/3)*x(1)+((4.64-2)/2)* x (1)+2;
g(7)=750937.3/( x(1)*x(3)*x(2) ^(1/2))-550;
g(8)=6328732/( x(1)*x(2)*x(3) ^2)-335;
c=[g(1);g(2);g(3);g(4);g(5);g(6);g(7);g(8)];
ceq=[ ];
在MATLAB命令窗口调用优化程序:
options=optimset(‘largescale’,‘off’);
x0=[22 52 5];
[x,fval]=fmincon(@myfun,x0,[ ],[ ],[ ],[ ],[ ],[ ],@mycon,options);
(理论上可以得到优化的结果:
x = 17. 0000 67. 6649 4. 0526
fval = 1. 1312e + 006
但是 我得不到。。。:confused:)
谢谢啦谢谢啦
function f=myfun(x)
f=(pi/16)*x(1) ^2* x (3) ^2*x (2) * (4 + (4. 64 - 2) ^2*3);
再编写非线性约束函数的M文件mycon.m:
function [c,ceq]=mycon(x)
g(1)= 17-x(1);
g(2)=2-x(3);
g(3)=10-x(2);
g(4)=5*x(3)-x(2);
g(5)=x(2)-17* x (3);
g(6)=-(4.64/2)*sin(pi/3)*x(1)+((4.64-2)/2)* x (1)+2;
g(7)=750937.3/( x(1)*x(3)*x(2) ^(1/2))-550;
g(8)=6328732/( x(1)*x(2)*x(3) ^2)-335;
c=[g(1);g(2);g(3);g(4);g(5);g(6);g(7);g(8)];
ceq=[ ];
在MATLAB命令窗口调用优化程序:
options=optimset(‘largescale’,‘off’);
x0=[22 52 5];
[x,fval]=fmincon(@myfun,x0,[ ],[ ],[ ],[ ],[ ],[ ],@mycon,options);
(理论上可以得到优化的结果:
x = 17. 0000 67. 6649 4. 0526
fval = 1. 1312e + 006
但是 我得不到。。。:confused:)
谢谢啦谢谢啦