ZKX's LAB

matlab 求约束优化问题 matlab 带约束优化问题

2021-04-26知识12

求大神帮忙编个程序 matlab的非线性约束优化问题 function aamyfun=(x)0.00613*(x(1)^2-x(2)^2)*x(3);option=optimset('Algorithm','sqp');[x,fval]=fmincon(myfun,[1;1;11],[],[],[],[],[],[],@mycon,option)endfunction[c,ceq]=mycon(x)c(1)=41.67*x(3)/x(1)^3*(1-(x(2)/x(1))^4)-1;c(2)=2.5/x(1)^3*(1-(x(2)/x(1))^4)-1;c(3)=10-x(3);ceq=[];end

有关matlab无约束优化问题,请大神指教 fun2有问题1,f=后面部分不用引号括起来的2,你的s是什么?函数里从没有定义s3,函数中间忽然有个分号你的fun2是怎么来的,为什么怪怪的

matlab 非线性约束最优化问题,希望给出代码 先建立M文件fun.m定义目标函数:function f=fun(x)f=((x(1)+1)^2+4*(x(2)-1.5)^2)*((x(1)-1.2)^2+0.4*(x(2)-0.5)^2);再建立M文件mycon.m定义非线性约束:function[g,ceq]=mycon(x)g=[2*x(1)-x(1)*x(2)+5*x(2)-6;x(1)-x(2)+0.5;x(1)^2-4*x(2)^2+x(2)];ceq=0;主程序为:x0=[0;0];VLB=[0 0];VUB=[];[x,fval,exitflag,output]=fmincon('fun',x0,[],[],[],[],VLB,VUB,'mycon2')结果为:x=0.59251.0925fval=1.6306exitflag=1output=iterations:5funcCount:18lssteplength:1stepsize:8.6939e-007algorithm:'medium-scale:SQP,Quasi-Newton,line-search'firstorderopt:3.2838e-008constrviolation:1.6077e-011message:[1x144 char]

随机阅读

qrcode
访问手机版