Documentation

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

collapse all

Create Default Options

Create default options for the fmincon solver.

options = optimoptions('fmincon')
options = 

  fmincon options:

   Options used by current Algorithm ('interior-point'):
   (Other available algorithms: 'active-set', 'sqp', 'trust-region-reflective')

   Set properties:
     No options set.

   Default properties:
                    Algorithm: 'interior-point'
               CheckGradients: 0
          ConstraintTolerance: 1.0000e-06
                      Display: 'final'
     FiniteDifferenceStepSize: 'sqrt(eps)'
         FiniteDifferenceType: 'forward'
         HessianApproximation: 'bfgs'
                   HessianFcn: []
           HessianMultiplyFcn: []
                  HonorBounds: 1
       MaxFunctionEvaluations: 3000
                MaxIterations: 1000
               ObjectiveLimit: -1.0000e+20
          OptimalityTolerance: 1.0000e-06
                    OutputFcn: []
                      PlotFcn: []
                 ScaleProblem: 0
    SpecifyConstraintGradient: 0
     SpecifyObjectiveGradient: 0
                StepTolerance: 1.0000e-10
          SubproblemAlgorithm: 'factorization'
                     TypicalX: 'ones(numberOfVariables,1)'
                  UseParallel: 0

   Options not used by current Algorithm ('interior-point')
   Default properties:
    FunctionTolerance: 1.0000e-06


Create Nondefault Options

Create nondefault options for the fmincon solver.

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

  fmincon options:

   Options used by current Algorithm ('sqp'):
   (Other available algorithms: 'active-set', 'interior-point', 'trust-region-reflective')

   Set properties:
                    Algorithm: 'sqp'
                MaxIterations: 1500

   Default properties:
               CheckGradients: 0
          ConstraintTolerance: 1.0000e-06
                      Display: 'final'
     FiniteDifferenceStepSize: 'sqrt(eps)'
         FiniteDifferenceType: 'forward'
       MaxFunctionEvaluations: '100*numberOfVariables'
               ObjectiveLimit: -1.0000e+20
          OptimalityTolerance: 1.0000e-06
                    OutputFcn: []
                      PlotFcn: []
                 ScaleProblem: 0
    SpecifyConstraintGradient: 0
     SpecifyObjectiveGradient: 0
                StepTolerance: 1.0000e-06
                     TypicalX: 'ones(numberOfVariables,1)'
                  UseParallel: 0

   Options not used by current Algorithm ('sqp')
   Default properties:
       FunctionTolerance: 1.0000e-06
    HessianApproximation: 'not applicable'
              HessianFcn: []
      HessianMultiplyFcn: []
             HonorBounds: 1
     SubproblemAlgorithm: 'factorization'


Update Options

Update existing options with new values.

Create options for the lsqnonlin solver.

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

  lsqnonlin options:

   Options used by current Algorithm ('levenberg-marquardt'):
   (Other available algorithms: 'trust-region-reflective')

   Set properties:
                   Algorithm: 'levenberg-marquardt'
      MaxFunctionEvaluations: 1500

   Default properties:
              CheckGradients: 0
                     Display: 'final'
    FiniteDifferenceStepSize: 'sqrt(eps)'
        FiniteDifferenceType: 'forward'
           FunctionTolerance: 1.0000e-06
               MaxIterations: 400
                   OutputFcn: []
                     PlotFcn: []
    SpecifyObjectiveGradient: 0
               StepTolerance: 1.0000e-06
                    TypicalX: 'ones(numberOfVariables,1)'
                 UseParallel: 0

   Options not used by current Algorithm ('levenberg-marquardt')
   Default properties:
    JacobianMultiplyFcn: []
    OptimalityTolerance: 1.0000e-06
    SubproblemAlgorithm: 'factorization'


Increase MaxFunctionEvaluations to 2000.

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

  lsqnonlin options:

   Options used by current Algorithm ('levenberg-marquardt'):
   (Other available algorithms: 'trust-region-reflective')

   Set properties:
                   Algorithm: 'levenberg-marquardt'
      MaxFunctionEvaluations: 2000

   Default properties:
              CheckGradients: 0
                     Display: 'final'
    FiniteDifferenceStepSize: 'sqrt(eps)'
        FiniteDifferenceType: 'forward'
           FunctionTolerance: 1.0000e-06
               MaxIterations: 400
                   OutputFcn: []
                     PlotFcn: []
    SpecifyObjectiveGradient: 0
               StepTolerance: 1.0000e-06
                    TypicalX: 'ones(numberOfVariables,1)'
                 UseParallel: 0

   Options not used by current Algorithm ('levenberg-marquardt')
   Default properties:
    JacobianMultiplyFcn: []
    OptimalityTolerance: 1.0000e-06
    SubproblemAlgorithm: 'factorization'


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',...
    'MaxFunctionEvaluations',1500)
options = 

  lsqnonlin options:

   Options used by current Algorithm ('levenberg-marquardt'):
   (Other available algorithms: 'trust-region-reflective')

   Set properties:
                   Algorithm: 'levenberg-marquardt'
      MaxFunctionEvaluations: 1500

   Default properties:
              CheckGradients: 0
                     Display: 'final'
    FiniteDifferenceStepSize: 'sqrt(eps)'
        FiniteDifferenceType: 'forward'
           FunctionTolerance: 1.0000e-06
               MaxIterations: 400
                   OutputFcn: []
                     PlotFcn: []
    SpecifyObjectiveGradient: 0
               StepTolerance: 1.0000e-06
                    TypicalX: 'ones(numberOfVariables,1)'
                 UseParallel: 0

   Options not used by current Algorithm ('levenberg-marquardt')
   Default properties:
    JacobianMultiplyFcn: []
    OptimalityTolerance: 1.0000e-06
    SubproblemAlgorithm: 'factorization'


Increase MaxFunctionEvaluations to 2000 by using dot notation.

options.MaxFunctionEvaluations = 2000
options = 

  lsqnonlin options:

   Options used by current Algorithm ('levenberg-marquardt'):
   (Other available algorithms: 'trust-region-reflective')

   Set properties:
                   Algorithm: 'levenberg-marquardt'
      MaxFunctionEvaluations: 2000

   Default properties:
              CheckGradients: 0
                     Display: 'final'
    FiniteDifferenceStepSize: 'sqrt(eps)'
        FiniteDifferenceType: 'forward'
           FunctionTolerance: 1.0000e-06
               MaxIterations: 400
                   OutputFcn: []
                     PlotFcn: []
    SpecifyObjectiveGradient: 0
               StepTolerance: 1.0000e-06
                    TypicalX: 'ones(numberOfVariables,1)'
                 UseParallel: 0

   Options not used by current Algorithm ('levenberg-marquardt')
   Default properties:
    JacobianMultiplyFcn: []
    OptimalityTolerance: 1.0000e-06
    SubproblemAlgorithm: 'factorization'


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','MaxIterations',1500)
oldoptions = 

  fmincon options:

   Options used by current Algorithm ('sqp'):
   (Other available algorithms: 'active-set', 'interior-point', 'trust-region-reflective')

   Set properties:
                    Algorithm: 'sqp'
                MaxIterations: 1500

   Default properties:
               CheckGradients: 0
          ConstraintTolerance: 1.0000e-06
                      Display: 'final'
     FiniteDifferenceStepSize: 'sqrt(eps)'
         FiniteDifferenceType: 'forward'
       MaxFunctionEvaluations: '100*numberOfVariables'
               ObjectiveLimit: -1.0000e+20
          OptimalityTolerance: 1.0000e-06
                    OutputFcn: []
                      PlotFcn: []
                 ScaleProblem: 0
    SpecifyConstraintGradient: 0
     SpecifyObjectiveGradient: 0
                StepTolerance: 1.0000e-06
                     TypicalX: 'ones(numberOfVariables,1)'
                  UseParallel: 0

   Options not used by current Algorithm ('sqp')
   Default properties:
       FunctionTolerance: 1.0000e-06
    HessianApproximation: 'not applicable'
              HessianFcn: []
      HessianMultiplyFcn: []
             HonorBounds: 1
     SubproblemAlgorithm: 'factorization'


Transfer the applicable options to the fminunc solver.

options = optimoptions(@fminunc,oldoptions)
options = 

  fminunc options:

   Options used by current Algorithm ('trust-region'):
   (Other available algorithms: 'quasi-newton')

   Set properties:
              CheckGradients: 0
        FiniteDifferenceType: 'forward'
           FunctionTolerance: 1.0000e-06
                  HessianFcn: []
          HessianMultiplyFcn: []
               MaxIterations: 1500
         OptimalityTolerance: 1.0000e-06
                     PlotFcn: []
    SpecifyObjectiveGradient: 0
               StepTolerance: 1.0000e-06
         SubproblemAlgorithm: 'factorization'

   Default properties:
                   Algorithm: 'trust-region'
                     Display: 'final'
    FiniteDifferenceStepSize: 'sqrt(eps)'
      MaxFunctionEvaluations: '100*numberOfVariables'
                   OutputFcn: []
                    TypicalX: 'ones(numberOfVariables,1)'

   Options not used by current Algorithm ('trust-region')
   Default properties:
    ObjectiveLimit: -1.0000e+20


Input Arguments

collapse all

SolverName — Solver namecharacter vector or function handle

Solver name, specified as a character vector 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','FunctionTolerance',1e-10) sets fmincon options to have iterative display, and to have a FunctionTolerance of 1e-10.

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

Output Arguments

collapse all

options — Options objectoptions object

Options object, returned as the options for the SolverName solver.

Alternative Functionality

App

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

    Note:   The Optimization app warns that it will be removed in a future release.

Introduced in R2013a

Was this topic helpful?