Page 176 - 数学建模算法与应用
P. 176

Mathematical Modeling Algorithms and Applications
             数学建模算法与应用


                  题目中目标函数的梯度为:





                  解 1. 编写 M 文件, 以 fun9.m 定义目标函数及梯度函数:
                  function [f,df]=fun9(x);
                  f=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1);
                  df=[exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+8*x(1)+6*x(2)+1);

             exp(x(1))*(4*x(2)
                  +4*x(1)+2)];
                  2. 编写 M 文件 , 以 fun10.m 定义约束条件及其梯度函数:
                  function [c,ceq,dc,dceq]=fun10(x);

                  c=[x(1)*x(2)-x(1)-x(2)+1.5;-x(1)*x(2)-10];
                  dc=[x(2)-1,-x(2);x(1)-1,-x(1)];
                  ceq=[];dceq=[];
                  3. 调用函数 fmincon, 以编写主函数文件 example13.m :

                  % 采用标准算法
                  options=optimset(‘largescale’,’off’);
                  % 采用梯度
                  options=optimset(options,’GradObj’,’on’,’GradConstr’,’on’);

                  [x,y]=fmincon(@fun9,rand(2,1),[],[],[],[],[],[],@fun10,
             options)
                  4. Matlab 优化工具箱的用户图形界面解法
                  Matlab 优化工具箱的命令 Optimchair 能够为优化问题提供了解决方案。

             Optimtool 可应用于解决所有优化问题,计算结果最后输入至 Matlab 工作空间。
















             166
   171   172   173   174   175   176   177   178   179   180   181