Main Content

Set Optimization Options, Problem-Based

To tune your optimization solution process in the problem-based approach, set options using optimoptions and pass the options to solve:

options = optimoptions("fmincon",PlotFcn=@optimplotfvalconstr);
[sol,fval] = solve(prob,x0,Options=options);

You might wonder which solver to specify; optimoptions requires you to set a solver, but solve chooses the solver. Which solver should you set for your options?

To find the default solver that solve uses for a problem, use solvers.

default = solvers(prob)
default = 
"lsqnonlin"

If you want to use the default solver, you can specify options use the first output of solvers.

options = optimoptions(default,...);

To find all available solvers for a problem, view the second output of solvers.

[~,validsolvers] = solvers(prob)
validsolvers = 1x10 string
    "lsqnonlin"    "lsqcurvefit"    "fmincon"    "ga"    "patternsearch"    "surrogateopt"    "particleswarm"    "simulannealbnd"    "gamultiobj"    "paretosearch"

You can specify a nondefault solver for solve using the Solver name-value argument.

[sol,fval] = solve(prob,x0,Options=options,Solver="fmincon");

Note

To set options for the solvers that are available without an Optimization Toolbox™ license, use optimset. These solvers are fminbnd, fminsearch, fzero, and lsqnonneg.

The remaining considerations for setting options are the same as in the solver-based approach. For details, see Set Optimization Options.

See Also

| |

Related Topics