I want to solve the same basic nonlinear minimization using different solvers(e.g. quadprog
, fmincon
, fminunc
)/algorithms with solve
function in Matlab's Optimization Toolbox.
Here's what's happening:
I try setting the solver and algorithm through an structure using optimoptions
function. It goes like this:
options = optimoptions(@fminunc, 'Algorithm', 'quasi-newton')
[S, fval, exitflag] = solve(nonlinprob, x0,'options', options)
but the function apparently only uses the quadprog
solver with interior-point-convex algorithm no matter what. It seems to ignore the different options I'm setting. I'm running Matlab r2018b.
The code section brings the optimization problem being handled with example solver and algorithm chosen and what the solve function call is returning
The function is overwriting the options, but I need to force it to do it in different ways. How can I accomplish that?
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
. Can you provide a minimum reproducible example? – tmcg0