Main Content

Choosing and Controlling the Solver for PortfolioCVaR Optimizations

When solving portfolio optimizations for a PortfolioCVaR object, you are solving nonlinear optimization problems with either nonlinear objective or nonlinear constraints. You can use 'TrustRegionCP' (default), 'ExtendedCP', or 'cuttingplane' solvers that implement Kelley’s cutting plane method (see Kelley [45] at Portfolio Optimization). Alternatively, you can use fmincon and all variations of fmincon from Optimization Toolbox™ are supported. When using fmincon as the solverType, 'sqp' is the default algorithm for fmincon.

Using 'TrustRegionCP', 'ExtendedCP', and 'cuttingplane' SolverTypes

The 'TrustRegionCP', 'ExtendedCP', and 'cuttingplane' solvers have options to control the number iterations and stopping tolerances. Moreover, these solvers use linprog as the master solver, and all linprog options are supported using optimoptions structures. All these options are set using setSolver.

For example, you can use setSolver to increase the number of iterations for 'TrustRegionCP':

p = PortfolioCVaR;
p = setSolver(p, 'TrustRegionCP', 'MaxIterations', 2000);
display(p.solverType)
display(p.solverOptions)
trustregioncp
                MaxIterations: 2000
         AbsoluteGapTolerance: 1.0000e-07
         RelativeGapTolerance: 1.0000e-05
       NonlinearScalingFactor: 1000
       ObjectiveScalingFactor: 1000
          MainSolverOptions: [1×1 optim.options.Linprog]
                      Display: 'off'
                CutGeneration: 'basic'
     MaxIterationsInactiveCut: 30
           ActiveCutTolerance: 1.0000e-07
                  ShrinkRatio: 0.7500
    TrustRegionStartIteration: 2
                   DeltaLimit: 1

To change the main solver algorithm to 'interior-point', with no display, use setSolver to modify 'MainSolverOptions':

p = PortfolioCVaR;
options = optimoptions('linprog','Algorithm','interior-point','Display','off');
p = setSolver(p,'TrustRegionCP','MainSolverOptions',options);
display(p.solverType)
display(p.solverOptions)
display(p.solverOptions.MainSolverOptions.Algorithm)
display(p.solverOptions.MainSolverOptions.Display)
trustregioncp
                MaxIterations: 1000
         AbsoluteGapTolerance: 1.0000e-07
         RelativeGapTolerance: 1.0000e-05
       NonlinearScalingFactor: 1000
       ObjectiveScalingFactor: 1000
          MaainSolverOptions: [1×1 optim.options.Linprog]
                      Display: 'off'
                CutGeneration: 'basic'
     MaxIterationsInactiveCut: 30
           ActiveCutTolerance: 1.0000e-07
                  ShrinkRatio: 0.7500
    TrustRegionStartIteration: 2
                   DeltaLimit: 1

interior-point
off

Using 'fmincon' SolverType

Unlike Optimization Toolbox which uses the interior-point algorithm as the default algorithm for fmincon, the portfolio optimization for a PortfolioCVaR object uses the sqp algorithm. For details about fmincon and constrained nonlinear optimization algorithms and options, see Constrained Nonlinear Optimization Algorithms.

To modify fmincon options for CVaR portfolio optimizations, use setSolver to set the hidden properties solverType and solverOptions to specify and control the solver. (Note that you can see the default options by creating a dummy PortfolioCVaR object, using p = PortfolioCVaR and then type p.solverOptions.) Since these solver properties are hidden, you cannot set them using the PortfolioCVaR object. The default for the fmincon solver is to use the sqp algorithm objective function, gradients turned on, and no displayed output, so you do not need to use setSolver to specify the sqp algorithm.

p = PortfolioCVaR;
p = setSolver(p, 'fmincon');
display(p.solverOptions)
fmincon options:

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

   Set properties:
                    Algorithm: 'sqp'
          ConstraintTolerance: 1.0000e-08
                      Display: 'off'
          OptimalityTolerance: 1.0000e-08
    SpecifyConstraintGradient: 1
     SpecifyObjectiveGradient: 1
                StepTolerance: 1.0000e-08

   Default properties:
     FiniteDifferenceStepSize: 'sqrt(eps)'
         FiniteDifferenceType: 'forward'
       MaxFunctionEvaluations: '100*numberOfVariables'
                MaxIterations: 400
               ObjectiveLimit: -1.0000e+20
                    OutputFcn: []
                      PlotFcn: []
                 ScaleProblem: 0
                     TypicalX: 'ones(numberOfVariables,1)'
                  UseParallel: 0 

If you want to specify additional options associated with the fmincon solver, setSolver accepts these options as name-value pair arguments. For example, if you want to use fmincon with the 'active-set' algorithm and with no displayed output, use setSolver with:

p = PortfolioCVaR;
p = setSolver(p, 'fmincon','Algorithm','active-set','Display','off');
display(p.solverOptions.Algorithm)
display(p.solverOptions.Display)
active-set
off

Alternatively, setSolver accepts an optimoptions object from Optimization Toolbox as the second argument. For example, you can change the algorithm to 'trust-region-reflective' with no displayed output as follows:

p = PortfolioCVaR;
options = optimoptions('fmincon','Algorithm','trust-region-reflective', 'Display', 'off');
p = setSolver(p, 'fmincon', options);
display(p.solverOptions.Algorithm)
display(p.solverOptions.Display)
trust-region-reflective
off

Using the Mixed Integer Nonlinear Programming (MINLP) Solver

The mixed integer nonlinear programming (MINLP) solver, configured using setSolverMINLP, enables you to specify associated solver options for portfolio optimization for a PortfolioCVaR object. The MINLP solver is used when any one, or any combination of 'Conditional' BoundType, MinNumAssets, or MaxNumAssets constraints are active. In this case, the portfolio problem is formulated by adding NumAssets binary variables, where 0 indicates not invested, and 1 is invested. For more information on using 'Conditional' BoundType, see setBounds. For more information on specifying MinNumAssets and MaxNumAssets, see setMinMaxNumAssets.

When using the estimate functions with a PortfolioCVaR object where 'Conditional' BoundType, MinNumAssets, or MaxNumAssets constraints are active, the mixed integer nonlinear programming (MINLP) solver is automatically used.

Solver Guidelines for PortfolioCVaR Objects

The following table provides guidelines for using setSolver and setSolverMINLP.

PortfolioCVaR ProblemPortfolioCVaR FunctionType of Optimization ProblemMain Solver Helper Solver
PortfolioCVaR without active 'Conditional' BoundType, MinNumAssets, and MaxNumAssetsestimateFrontierByRiskOptimizing a portfolio for a certain risk level introduces a nonlinear constraint. Therefore, this problem has a linear objective with linear and nonlinear constraints.'TrustRegionCP', 'ExtendedCP', 'fmincon', or 'cuttingplane' using setSolver

'linprog' using setSolver

PortfolioCVaR without active 'Conditional' BoundType, MinNumAssets, and MaxNumAssetsestimateFrontierByReturnNonlinear objective with linear constraints'TrustRegionCP', 'ExtendedCP', 'fmincon', or 'cuttingplane' using setSolver

'linprog' using setSolver

PortfolioCVaR without active 'Conditional' BoundType, MinNumAssets, and MaxNumAssetsestimateFrontierLimits

Nonlinear or linear objective with linear constraints

For ‘min’: nonlinear objective, 'TrustRegionCP', 'ExtendedCP', 'fmincon', or 'cuttingplane' using setSolver

For ‘max’: linear objective, 'linprog' using setSolver

Not applicable
PortfolioCVaR with active 'Conditional' BoundType, MinNumAssets, MaxNumAssets, or conditional budget constraintsestimateFrontierByRiskThe problem is formulated by introducing NumAssets binary variables to indicate whether the corresponding asset is invested or not. Therefore, it requires a mixed integer nonlinear programming solver. Three types of MINLP solvers are offered, see setSolverMINLP.Mixed integer nonlinear programming solver (MINLP) using setSolverMINLP'fmincon' is used when the estimate functions reduce the problem into NLP. This solver is configured through setSolver.
PortfolioCVaR with active 'Conditional' BoundType, MinNumAssets, MaxNumAssets, or conditional budget constraintsestimateFrontierByReturnThe problem is formulated by introducing NumAssets binary variables to indicate whether the corresponding asset is invested or not. Therefore, it requires a mixed integer nonlinear programming solver. Three types of MINLP solvers are offered, see setSolverMINLP.Mixed integer nonlinear programming solver (MINLP) using setSolverMINLP'fmincon' is used when the estimate functions reduce the problem into NLP. This solver is configured through setSolver
PortfolioCVaR with active 'Conditional' BoundType, MinNumAssets, MaxNumAssets, or conditional budget constraintsestimateFrontierLimitsThe problem is formulated by introducing NumAssets binary variables to indicate whether the corresponding asset is invested or not. Therefore, it requires a mixed integer nonlinear programming solver. Three types of MINLP solvers are offered, see setSolverMINLP.Mixed integer nonlinear programming solver (MINLP) using setSolverMINLP'fmincon' is used when the estimate functions reduce the problem into NLP. This solver is configured through setSolver

See Also

| | | | | | | | | |

Related Examples

More About

External Websites