【问题标题】:matlab optimization toolbox "solve" function. How to change solver?matlab优化工具箱“求解”功能。如何更改求解器?
【发布时间】:2020-01-06 18:16:40
【问题描述】:

我想在 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

【问题讨论】:

标签: matlab optimization mathematical-optimization


【解决方案1】:

会发生什么?

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-06
    • 1970-01-01
    • 1970-01-01
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多