Documentation Center

  • Trials
  • Product Updates

optimoptions

Create optimization options

Syntax

  • options = optimoptions(SolverName) example
  • options = optimoptions(SolverName,Name,Value) example
  • options = optimoptions(oldoptions,Name,Value) example
  • options = optimoptions(SolverName,oldoptions) example

Description

example

options = optimoptions(SolverName) returns a set of default options for the SolverName solver.

example

options = optimoptions(SolverName,Name,Value) returns options with the named parameters altered with the specified values.

example

options = optimoptions(oldoptions,Name,Value) returns a copy of oldoptions with the named parameters altered with the specified values.

example

options = optimoptions(SolverName,oldoptions) returns default options for the SolverName solver, and copies the applicable options in oldoptions to options.

Examples

expand all

Create Default Options

Create default options for the fmincon solver.

options = optimoptions('fmincon')

Create Nondefault Options

Create nondefault options for the fmincon solver.

options = optimoptions(@fmincon,'Algorithm','sqp','MaxIter',1500)

Update Options

Update existing options with new values.

Create options for the lsqnonlin solver.

oldoptions = optimoptions(@lsqnonlin,'Algorithm','levenberg-marquardt','MaxFunEvals',1500)

Increase MaxFunEvals to 2000.

options = optimoptions(oldoptions,'MaxFunEvals',2000)

Use Dot Notation to Update Options

Update existing options with new values by using dot notation.

Create options for the lsqnonlin solver.

options = optimoptions(@lsqnonlin,'Algorithm','levenberg-marquardt','MaxFunEvals',1500)

Increase MaxFunEvals to 2000 by using dot notation.

options.MaxFunEvals = 2000

Copy Options to Another Solver

Transfer nondefault options for the fmincon solver to options for the fminunc solver.

Create nondefault options for the fmincon solver.

oldoptions = optimoptions(@fmincon,'Algorithm','sqp','MaxIter',1500)

Transfer the applicable options to the fminunc solver.

options = optimoptions(@fminunc,oldoptions)

Input Arguments

expand all

SolverName — Solver namestring or function handle

Solver name, specified as a string or function handle.

Example: 'fmincon'

Example: @fmincon

Data Types: char | function_handle

oldoptions — Optionsoptions created using optimoptions

Options, specified as an options object. The optimoptions function creates options objects.

Example: oldoptions = optimoptions(@fminunc)

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: optimoptions(@fmincon,'Display','iter','TolFun',1e-10) sets fmincon options to have iterative display, and to have a TolFun tolerance of 1e-10.

For relevant name-value pairs, look at the options table for your solver:

Output Arguments

expand all

options — Options objectoptions object

Options object, containing options for the SolverName solver.

Alternative Functionality

App

You can set and modify options using the Optimization app (optimtool).

See Also

|

Was this topic helpful?