Choosing and Controlling the Solver for PortfolioMAD Optimizations

When solving portfolio optimizations for a PortfolioMAD object, you are solving nonlinear optimization problems with either nonlinear objective or nonlinear constraints. You can use 'TrustRegionCP' (default) or 'ExtendedCP' 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' and 'ExtendedCP' SolverTypes

The 'TrustRegionCP' and 'ExtendedCP' 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 = PortfolioMAD;
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
          MasterSolverOptions: [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 master solver algorithm to 'interior-point', with no display, use setSolver to modify 'MasterSolverOptions':

p = PortfolioMAD;
options = optimoptions('linprog','Algorithm','interior-point','Display','off');
p = setSolver(p,'TrustRegionCP','MasterSolverOptions',options);
display(p.solverType)
display(p.solverOptions)
display(p.solverOptions.MasterSolverOptions.Algorithm)
display(p.solverOptions.MasterSolverOptions.Display)
trustregioncp
                MaxIterations: 1000
         AbsoluteGapTolerance: 1.0000e-07
         RelativeGapTolerance: 1.0000e-05
       NonlinearScalingFactor: 1000
       ObjectiveScalingFactor: 1000
          MasterSolverOptions: [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 PortfolioMAD object uses the 'sqp' algorithm as the default. For details about fmincon and constrained nonlinear optimization algorithms and options, see Constrained Nonlinear Optimization Algorithms (Optimization Toolbox).

To modify fmincon options for MAD portfolio optimizations, use setSolver to set the hidden properties solverType and solverOptions to specify and control the solver. Since these solver properties are hidden, you cannot set them using the PortfolioMAD object. The default for the fmincon solver is the 'sqb' algorithm and no displayed output, so you do not need to use setSolver to specify the 'sqp' algorithm for fmincon.

p = PortfolioMAD;
p = setSolver(p, 'fmincon');
display(p.solverOptions.Algorithm);
display(p.solverOptions.Display);
sqp
off

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 displayed output, use setSolver with:

p = PortfolioMAD;
p = setSolver(p, 'fmincon', 'Algorithm', 'active-set', 'Display', 'final');
display(p.solverOptions);
fmincon options:

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

   Set properties:
                    Algorithm: 'active-set'
                      Display: 'final'

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

Alternatively, the setSolver function accepts an optimoptions object as the second argument. For example, you can change the algorithm to 'active-set' with no displayed output as follows:

p = PortfolioMAD;
options = optimoptions('fmincon', 'Algorithm', 'active-set', 'Display', 'off');
p = setSolver(p, 'fmincon', options);
display(p.solverOptions.Algorithm);
display(p.solverOptions.Display);
active-set
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 PortfolioMAD object. The MINLP solver is used when any one, or any combination of 'Conditional' BoundType, MinNumAssets, or MaxNumAssets constraints are active, 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 PortfolioMAD object where 'Conditional' BoundType, MinNumAssets, or MaxNumAssets constraints are active, the mixed integer nonlinear programming (MINLP) solver is automatically used.

Solver Guidelines for PortfolioMAD Objects

The following table provides guidelines for using setSolver and setSolverMINLP.

PortfolioMAD ProblemPortfolioMAD FunctionType of Optimization ProblemMain Solver Helper Solver
PortfolioMAD 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', or 'fmincon' using setSolver

'linprog' using setSolver

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

'linprog' using setSolver

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

Nonlinear or linear objective with linear constraints

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

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

Not applicable
PortfolioMAD with active 'Conditional' BoundType, MinNumAssets, and MaxNumAssetsestimateFrontierByRiskThe 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.
PortfolioMAD with active 'Conditional' BoundType, MinNumAssets, and MaxNumAssetsestimateFrontierByReturnThe 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
PortfolioMAD with active 'Conditional' BoundType, MinNumAssets, and MaxNumAssetsestimateFrontierLimitsThe 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