永发信息网

求教关于利用matlab优化工具fmincon函数的问题

答案:2  悬赏:70  手机版
解决时间 2021-03-03 11:13
  • 提问者网友:心牵心
  • 2021-03-02 21:23
弹出Warning: Options LargeScale = 'off' and Algorithm = 'trust-region-reflective' conflict.
Ignoring Algorithm and running active-set algorithm. To run trust-region-reflective, set
LargeScale = 'on'. To run active-set without this warning, use Algorithm = 'active-set'.
对结果有何影响,该如何正确设置保证精度并阻止继续弹出?
最佳答案
  • 五星知识达人网友:鱼芗
  • 2021-03-02 21:56
ction(非线性约束辅助函数)改成
function [c,ceq]=opt115(x)
c(1)=-x(1);
c(2)=-x(2);
c(3)=-x(3);
c(4)=-x(4);
cep=[];
全部回答
  • 1楼网友:迷人又混蛋
  • 2021-03-02 22:32
1 function [c,ceq]=yueshufun(x) x1=x(1);x2=x(2);x3=x(3); c=[(x2^2+x3^2-(1-x1)^2)/2*x2*x3-sqrt(3)/2; sqrt(2)/2-(x2^2+x3^2-(1-x1)^2)/2*x2*x3]; ceq=[]; %%非线性约束关系函数的输入是一个矩阵 2 function h=goal_func(x) x1=x(1);x2=x(2);x3=x(3);x4=x(4); f=0; for i=1:20; %w表示输入角θ。输入角变化180度,分20次,每次变化9度。 wi=1*pi*i./20; g=(atan(x1*sin(x4)/(1-x1*cos(x4)))+acos((x1^2-x2^2+x3^2+1-2*x1*cos(x4))... /(2*x3*sqrt(x1^2+1-2*x1*cos(x4))))-atan((x1*sin(x4+wi))/(1-x1*cos(x4+wi)))... -acos((x1^2-x2^2+x3^2+1-2* x1*cos(x4+wi))/(2*x3*sqrt(x1^2+1-2*x1*cos(x4+wi))))-6*sin(pi*wi/180)/pi)^2; f=f+g; end %运算之后是数学模型中的目标函数。 h=f-r*(log(-x1-x2+x3+1)+log(-x1+x2-x3+1)+log(-x1+x2+x3-1)+log(x1-0.1)+log(-x1+0.5)... +log(x2-0.1)+log(-x2+1.4)+log(x3-0.1)+log(-x3+0.9)... +log(x2^2+x3^2-(1-x1)^2)/2*x2*x3-sqrt(3)/2+log(sqrt(2)/2-(x2^2+x3^2-(1-x1)^2)/2*x2*x3)); %%目标函数中r没有定义,在目标函数中定义r。 3 a中,楼主要求的参数是3个,但是g中用到了x4,那你的x中就必须有四个值,而不是三个值; 4 x0=[0.3;1;0.6;2*pi/3;];初始值x0应该是列向量 5 options=optimset('largescale','on','display','iter','tolx',1e-4); 是用来控制fmincon的各种参数,tolx是优化终止条件;largescale是采用的算法;display选择iter显示迭代次数; 6 注意log(a)a不能为0,我测试了下,提示log运算中a出现0的情况;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯