matlab优化工具箱"solve"函数。如何更改求解器?

matlab optimization toolbox "solve" function. How to change solver?

我想在 Matlab 的优化工具箱中使用不同的求解器(例如 quadprogfminconfminunc)/具有 solve 函数的算法来求解相同的基本非线性最小化.

情况如下: 我尝试使用 optimoptions 函数通过结构设置求解器和算法。它是这样的:

options = optimoptions(@fminunc, 'Algorithm', 'quasi-newton')
[S, fval, exitflag] =  solve(nonlinprob, x0,'options', options)

但函数显然只使用 quadprog 解算器与内点凸算法无论如何。它似乎忽略了我设置的不同选项。我是 运行 Matlab r2018b。 代码部分介绍了使用示例求解器和所选算法处理的优化问题以及求解函数调用返回的内容

该函数正在覆盖选项,但我需要强制它以不同的方式进行。 我怎样才能做到这一点?

OptimizationProblem : 

    minimize :
       4*x^2 + 2*y^2 + 4*x*y + 2*y - 1

    subject to cons1:
       x + 6*y <= 2

    subject to cons2:
       -4*x + 2*y <= 0

    variable bounds:
       -10 <= x <= 10

       -10 <= y
x0 = 
    x: -3
    y: 3

x0 = 
    x: -3
    y: 3

options = 
  fminunc options:

   Options used by current Algorithm ('quasi-newton'):
   (Other available algorithms: 'trust-region')

   Set properties:
                   Algorithm: 'quasi-newton'

   Default properties:
              CheckGradients: 0
                     Display: 'final'
    FiniteDifferenceStepSize: 'sqrt(eps)'
        FiniteDifferenceType: 'forward'
      MaxFunctionEvaluations: '100*numberOfVariables'
               MaxIterations: 400
              ObjectiveLimit: -1.0000e+20
         OptimalityTolerance: 1.0000e-06
                   OutputFcn: []
                     PlotFcn: []
    SpecifyObjectiveGradient: 0
               StepTolerance: 1.0000e-06
                    TypicalX: 'ones(numberOfVariables,1)'

   Show options not used by current Algorithm ('quasi-newton')

Your Hessian is not symmetric. Resetting H=(H+H')/2.
Warning: You have passed FMINUNC options to QUADPROG. QUADPROG will use the common options and ignore the FMINUNC options that do not apply.
To avoid this warning, convert the FMINUNC options using OPTIMOPTIONS.
The interior-point-convex algorithm does not accept an initial point.
Ignoring X0.

Minimum found that satisfies the constraints.

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

<stopping criteria details>
S = 
    x: 0.5000
    y: -1.0000

fval = -2.0000
exitflag = 
    OptimalSolution

会发生什么?

您使用函数solve,函数solve决定调用quadprog函数来求解您的方程组。但是现在 quadprog 收到了 fminunc 的选项!所以当然 quadprog 无法管理这些选项,而是 select 一些默认选项。

您需要专门选择正确的求解器(在您的情况下 fminunc):

options_fminunc     = optimoptions(@fminunc, 'Algorithm', 'quasi-newton')
[S, fval, exitflag] = fminunc(nonlinprob, x0,'options', options_fminunc)
%                        ↑
%                 should be fminunc