MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB工具箱] 麻烦哪位高人帮忙看看这个程序到底哪里出错了?很急 (https://www.labfans.com/bbs/showthread.php?t=8603)

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:)
谢谢啦谢谢啦

anbcjys 2009-05-26 17:33

回复: 麻烦哪位高人帮忙看看这个程序到底哪里出错了?很急
 
[QUOTE=3050312039;28542]首先编制目标函数的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:)
谢谢啦谢谢啦[/QUOTE]

什么错误 放出来 .


所有时间均为北京时间。现在的时间是 11:07

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.