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')
options = 

  fmincon options:

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

   Set by user:
     No options set by user.

   Default:
                 Algorithm: 'interior-point'
    AlwaysHonorConstraints: 'bounds'
           DerivativeCheck: 'off'
               Diagnostics: 'off'
             DiffMaxChange: Inf
             DiffMinChange: 0
                   Display: 'final'
            FinDiffRelStep: 'sqrt(eps)'
               FinDiffType: 'forward'
               FunValCheck: 'off'
                GradConstr: 'off'
                   GradObj: 'off'
                   HessFcn: []
                   Hessian: 'bfgs'
                  HessMult: []
          InitBarrierParam: 0.1000
     InitTrustRegionRadius: 'sqrt(numberOfVariables)'
               MaxFunEvals: 3000
                   MaxIter: 1000
             MaxProjCGIter: '2*(numberOfVariables-numberOfEqualities)'
            ObjectiveLimit: -1.0000e+20
                 OutputFcn: []
                  PlotFcns: []
              ScaleProblem: 'none'
       SubproblemAlgorithm: 'ldl-factorization'
                    TolCon: 1.0000e-06
                    TolFun: 1.0000e-06
                 TolProjCG: 0.0100
              TolProjCGAbs: 1.0000e-10
                      TolX: 1.0000e-10
                  TypicalX: 'ones(numberOfVariables,1)'
               UseParallel: 0

   Options not used by current Algorithm ('interior-point')
   Default:
               HessPattern: 'sparse(ones(numberOfVariables))'
                MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
                MaxSQPIter: '10*max(numberOfVariables,numberOfInequalities...'
          PrecondBandWidth: 0
            RelLineSrchBnd: []
    RelLineSrchBndDuration: 1
                 TolConSQP: 1.0000e-06
                    TolPCG: 0.1000


Create Nondefault Options

Create nondefault options for the fmincon solver.

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

  fmincon options:

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

   Set by user:
    Algorithm: 'sqp'
      MaxIter: 1500

   Default:
    DerivativeCheck: 'off'
        Diagnostics: 'off'
      DiffMaxChange: Inf
      DiffMinChange: 0
            Display: 'final'
     FinDiffRelStep: 'sqrt(eps)'
        FinDiffType: 'forward'
        FunValCheck: 'off'
         GradConstr: 'off'
            GradObj: 'off'
        MaxFunEvals: '100*numberOfVariables'
     ObjectiveLimit: -1.0000e+20
          OutputFcn: []
           PlotFcns: []
       ScaleProblem: 'none'
             TolCon: 1.0000e-06
             TolFun: 1.0000e-06
               TolX: 1.0000e-06
           TypicalX: 'ones(numberOfVariables,1)'
        UseParallel: 0

   Options not used by current Algorithm ('sqp')
   Default:
    AlwaysHonorConstraints: 'bounds'
                   HessFcn: []
                  HessMult: []
               HessPattern: 'sparse(ones(numberOfVariables))'
                   Hessian: 'not applicable'
          InitBarrierParam: 0.1000
     InitTrustRegionRadius: 'sqrt(numberOfVariables)'
                MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
             MaxProjCGIter: '2*(numberOfVariables-numberOfEqualities)'
                MaxSQPIter: '10*max(numberOfVariables,numberOfInequalities...'
          PrecondBandWidth: 0
            RelLineSrchBnd: []
    RelLineSrchBndDuration: 1
       SubproblemAlgorithm: 'ldl-factorization'
                 TolConSQP: 1.0000e-06
                    TolPCG: 0.1000
                 TolProjCG: 0.0100
              TolProjCGAbs: 1.0000e-10


Update Options

Update existing options with new values.

Create options for the lsqnonlin solver.

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

  lsqnonlin options:

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

   Set by user:
      Algorithm: 'levenberg-marquardt'
    MaxFunEvals: 1500

   Default:
    DerivativeCheck: 'off'
        Diagnostics: 'off'
      DiffMaxChange: Inf
      DiffMinChange: 0
            Display: 'final'
     FinDiffRelStep: 'sqrt(eps)'
        FinDiffType: 'forward'
        FunValCheck: 'off'
        InitDamping: 0.0100
           Jacobian: 'off'
            MaxIter: 400
          OutputFcn: []
           PlotFcns: []
       ScaleProblem: 'none'
             TolFun: 1.0000e-06
               TolX: 1.0000e-06
           TypicalX: 'ones(numberOfVariables,1)'

   Options not used by current Algorithm ('levenberg-marquardt')
   Default:
           JacobMult: []
        JacobPattern: 'sparse(ones(Jrows,Jcols))'
          MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
    PrecondBandWidth: Inf
              TolPCG: 0.1000


Increase MaxFunEvals to 2000.

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

  lsqnonlin options:

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

   Set by user:
      Algorithm: 'levenberg-marquardt'
    MaxFunEvals: 2000

   Default:
    DerivativeCheck: 'off'
        Diagnostics: 'off'
      DiffMaxChange: Inf
      DiffMinChange: 0
            Display: 'final'
     FinDiffRelStep: 'sqrt(eps)'
        FinDiffType: 'forward'
        FunValCheck: 'off'
        InitDamping: 0.0100
           Jacobian: 'off'
            MaxIter: 400
          OutputFcn: []
           PlotFcns: []
       ScaleProblem: 'none'
             TolFun: 1.0000e-06
               TolX: 1.0000e-06
           TypicalX: 'ones(numberOfVariables,1)'

   Options not used by current Algorithm ('levenberg-marquardt')
   Default:
           JacobMult: []
        JacobPattern: 'sparse(ones(Jrows,Jcols))'
          MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
    PrecondBandWidth: Inf
              TolPCG: 0.1000


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)
options = 

  lsqnonlin options:

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

   Set by user:
      Algorithm: 'levenberg-marquardt'
    MaxFunEvals: 1500

   Default:
    DerivativeCheck: 'off'
        Diagnostics: 'off'
      DiffMaxChange: Inf
      DiffMinChange: 0
            Display: 'final'
     FinDiffRelStep: 'sqrt(eps)'
        FinDiffType: 'forward'
        FunValCheck: 'off'
        InitDamping: 0.0100
           Jacobian: 'off'
            MaxIter: 400
          OutputFcn: []
           PlotFcns: []
       ScaleProblem: 'none'
             TolFun: 1.0000e-06
               TolX: 1.0000e-06
           TypicalX: 'ones(numberOfVariables,1)'

   Options not used by current Algorithm ('levenberg-marquardt')
   Default:
           JacobMult: []
        JacobPattern: 'sparse(ones(Jrows,Jcols))'
          MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
    PrecondBandWidth: Inf
              TolPCG: 0.1000


Increase MaxFunEvals to 2000 by using dot notation.

options.MaxFunEvals = 2000
options = 

  lsqnonlin options:

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

   Set by user:
      Algorithm: 'levenberg-marquardt'
    MaxFunEvals: 2000

   Default:
    DerivativeCheck: 'off'
        Diagnostics: 'off'
      DiffMaxChange: Inf
      DiffMinChange: 0
            Display: 'final'
     FinDiffRelStep: 'sqrt(eps)'
        FinDiffType: 'forward'
        FunValCheck: 'off'
        InitDamping: 0.0100
           Jacobian: 'off'
            MaxIter: 400
          OutputFcn: []
           PlotFcns: []
       ScaleProblem: 'none'
             TolFun: 1.0000e-06
               TolX: 1.0000e-06
           TypicalX: 'ones(numberOfVariables,1)'

   Options not used by current Algorithm ('levenberg-marquardt')
   Default:
           JacobMult: []
        JacobPattern: 'sparse(ones(Jrows,Jcols))'
          MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
    PrecondBandWidth: Inf
              TolPCG: 0.1000


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)
oldoptions = 

  fmincon options:

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

   Set by user:
    Algorithm: 'sqp'
      MaxIter: 1500

   Default:
    DerivativeCheck: 'off'
        Diagnostics: 'off'
      DiffMaxChange: Inf
      DiffMinChange: 0
            Display: 'final'
     FinDiffRelStep: 'sqrt(eps)'
        FinDiffType: 'forward'
        FunValCheck: 'off'
         GradConstr: 'off'
            GradObj: 'off'
        MaxFunEvals: '100*numberOfVariables'
     ObjectiveLimit: -1.0000e+20
          OutputFcn: []
           PlotFcns: []
       ScaleProblem: 'none'
             TolCon: 1.0000e-06
             TolFun: 1.0000e-06
               TolX: 1.0000e-06
           TypicalX: 'ones(numberOfVariables,1)'
        UseParallel: 0

   Options not used by current Algorithm ('sqp')
   Default:
    AlwaysHonorConstraints: 'bounds'
                   HessFcn: []
                  HessMult: []
               HessPattern: 'sparse(ones(numberOfVariables))'
                   Hessian: 'not applicable'
          InitBarrierParam: 0.1000
     InitTrustRegionRadius: 'sqrt(numberOfVariables)'
                MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
             MaxProjCGIter: '2*(numberOfVariables-numberOfEqualities)'
                MaxSQPIter: '10*max(numberOfVariables,numberOfInequalities...'
          PrecondBandWidth: 0
            RelLineSrchBnd: []
    RelLineSrchBndDuration: 1
       SubproblemAlgorithm: 'ldl-factorization'
                 TolConSQP: 1.0000e-06
                    TolPCG: 0.1000
                 TolProjCG: 0.0100
              TolProjCGAbs: 1.0000e-10


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 by user:
    MaxIter: 1500

   Default:
           Algorithm: 'trust-region'
     DerivativeCheck: 'off'
         Diagnostics: 'off'
       DiffMaxChange: Inf
       DiffMinChange: 0
             Display: 'final'
      FinDiffRelStep: 'sqrt(eps)'
         FinDiffType: 'forward'
         FunValCheck: 'off'
             GradObj: 'off'
             Hessian: 'off'
            HessMult: []
         HessPattern: 'sparse(ones(numberOfVariables))'
         MaxFunEvals: '100*numberOfVariables'
          MaxPCGIter: 'max(1,floor(numberOfVariables/2))'
           OutputFcn: []
            PlotFcns: []
    PrecondBandWidth: 0
              TolFun: 1.0000e-06
              TolPCG: 0.1000
                TolX: 1.0000e-06
            TypicalX: 'ones(numberOfVariables,1)'

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


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, consult the options table for your solver:

Output Arguments

expand 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).

See Also

|

Was this topic helpful?