Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
初级会员
注册日期: 2018-07-22
帖子: 1
声望力: 0 ![]() |
![]()
在做求最优解的非线性规划问题,之前用fmincon结果不够理想,但还是有结果,之后用了globalsearch, 代码和出错如下,请教是哪里有问题?如何修改?谢谢!
opts1=optimset('Algorithm','sqp'); problem=createOptimProblem('fmincon','objective',fun,'x0',[14,25,15,23,18,44000,43500,43000,42500,42000],'Aineq',[],'bineq',[],'Aeq',[],'beq',[],'lb',[10,10,10,10,10,40000,40000,40000,40000,40000],'ub',[],'nonlcon',nonlinearcondition,'options',opts1); gs=GlobalSearch; [x,fval]=run(gs,problem) 输入参数的数目不足。 出错 fun (line 2) f=50000-(1400000-0.103075*x(1)^2*x(6)^(2/3)-0.103075*x(2)^2*x(7)^(2/3)-0.103075*x(3)^2*x(8)^(2/3)-0.103075*x(4)^2*x(9)^(2/3)-0.103075*x(5)^2*x(10)^(2/3))/(5.83/x(1)+5.83/x(2)+5.83/x(3)+5.83/x(4)+5.83/x(5)+2); 注:fun是目标函数,m文件如下: function f=fun(x) f=50000-(1400000-0.103075*x(1)^2*x(6)^(2/3)-0.103075*x(2)^2*x(7)^(2/3)-0.103075*x(3)^2*x(8)^(2/3)-0.103075*x(4)^2*x(9)^(2/3)-0.103075*x(5)^2*x(10)^(2/3))/(5.83/x(1)+5.83/x(2)+5.83/x(3)+5.83/x(4)+5.83/x(5)+2); end 共10个变量 |
![]() |
![]() |