Matlab线性/非线性规划优化算法(6)

实例:
寻找曲面到平面的最短距离:
在这里插入图片描述

%% how the initial points affect the results
clc
clear all
[x,y] = meshgrid(-4:0.1:4,-4:0.1:4);
z = x.^2 + y.^2;
 mesh (x,y,z);
plot3(x,y,z)
hold on 
zz = x-3*y -9;
if zz>0
    zz = 0;
end
mesh(x,y,zz);


hold on
x0 = [0,-0.2];
Aeq = [1 -3]; beq = 9;
A = [];
b = [];
nonlcon = [];
lb = [-4,-4];
ub = [4,4];
fun = @(x)x(1).^2 + x(2).^2;
options = optimoptions('fmincon','Display','iter','Algorithm','interior-point');
 [x,fval,exitflag,output,lambda,grad,hessian] ...
    = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,options)
    
plot3(x(1),x(2),x(1)-3*x(2) -9,'r*')

结果如下:

                                      First-order      Norm of
 Iter F-count            f(x)  Feasibility   optimality         step
    0       3    4.000000e-02    8.400e+00    1.133e-01
    1       6    8.103372e+00    1.776e-15    3.148e+00    2.659e+00
    2       9    8.102246e+00    0.000e+00    9.832e-02    1.055e-01
    3      12    8.100000e+00    1.776e-15    9.528e-04    4.699e-02
    4      15    8.100000e+00    0.000e+00    8.229e-06    3.996e-04
    5      18    8.100000e+00    0.000e+00    7.692e-08    3.500e-07

Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.

<stopping criteria details>

x =

    0.9000   -2.7000


fval =

    8.1000


exitflag =

     1


output = 

  struct with fields:

         iterations: 5
          funcCount: 18
    constrviolation: 0
           stepsize: 3.4999e-07
          algorithm: 'interior-point'
      firstorderopt: 7.6924e-08
       cgiterations: 0
            message: '↵Local minimum found that satisfies the constraints.↵↵Optimization completed because the objective function is non-decreasing in ↵feasible directions, to within the value of the optimality tolerance,↵and constraints are satisfied to within the value of the constraint tolerance.↵↵<stopping criteria details>↵↵Optimization completed: The relative first-order optimality measure, 1.424514e-08,↵is less than options.OptimalityTolerance = 1.000000e-06, and the relative maximum constraint↵violation, 0.000000e+00, is less than options.ConstraintTolerance = 1.000000e-06.↵↵'


lambda = 

  struct with fields:

         eqlin: -1.8000
      eqnonlin: [0×1 double]
       ineqlin: [0×1 double]
         lower: [2×1 double]
         upper: [2×1 double]
    ineqnonlin: [0×1 double]


grad =

    1.8000
   -5.4000


hessian =

    1.7636    0.0948
    0.0948    2.1038

图中红色星号即为最优点
在这里插入图片描述

matlab最优化程序包括:无约束一维极值问题、进退法、黄金分割法、斐波那契法、牛顿法基本牛顿法、全局牛顿法、割线法、抛物线法、三次插值法、可接受搜索法、Goidstein法、Wolfe Powell法、单纯形搜索法、Powell法、最速下降法、共轭梯度法、牛顿法、修正牛顿法、拟牛顿法、信赖域法、显式最速下降法、Rosen梯度投影法、罚函数法、外点罚函数法、內点罚函数法、混合罚函数法、乘子法、G-N法、修正G-N法、L-M法、线性规划、单纯形法、修正单纯形法、大M法、变量有界单纯形法、整数规划、割平面法、分支定界法、0-1规划、二次规划、拉格朗曰法、起作用集算法、路径跟踪法、粒子群优化算法、基本粒子群算法、带压缩因子的粒子群算法、权重改进的粒子群算法、线性递减权重法、自适应权重法、随机权重法、变学习因子的粒子群算法、同步变化的学习因子、异步变化的学习因子、二阶粒子群算法、二阶振荡粒子群算法 (matlab optimization process includes Non-binding one-dimensional extremum problems Advance and retreat method Golden Section Fibonacci method of basic Newton s method Newton s method Newton s Law of the global secant method parabola method acceptable to the three interpolation search method Goidstein France Wolfe.Powell France Simplex search method Powell steepest descent method Conjugate gradient method Newton s method Newton s method to amend Quasi-Newton Method trust region method explicitly steepest descent method, Rosen gradient projection method Penalty function method outside the penalty function method within the penalty function method Mixed penalty function multiplier method G-N was amended in G-N method L-M method Of linear programming simplex method, revised simplex method Big M method variables bounded simplex method, Cutting Plane Method integer programming branch and bound method 0-1 programming quadratic programming )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值