【发布时间】:2020-01-06 18:16:40
【问题描述】:
我想在 Matlab 的优化工具箱中使用不同的求解器(例如 quadprog、fmincon、fminunc)/使用 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
【问题讨论】:
-
当我使用
optimoptions设置算法时,MATLAB 重置算法没有任何问题。你能提供一个minimum reproducible example吗?
标签: matlab optimization mathematical-optimization