setSolver

Class: PortfolioCVaR

Choose main solver and solver options for CVaR portfolio optimization

Syntax

obj = setSolver(obj,solverType)
obj = setSolver(obj,solverType,varargin)

Description

obj = setSolver(obj,solverType) chooses the solver for CVaR portfolio optimization.

obj = setSolver(obj,solverType,varargin) chooses the solver and specifies associated solver options with additional options specified by one or more Name,Value pair arguments or an optimoptions object.

After you specify a solver, the varargin argument accepts either name-value pair arguments to set options or, for the case of solvers from Optimization Toolbox™ software, an object created by optimoptions.

Tips

You can also use dot notation to choose the solver and specify associated solver options:

obj = obj.setSolver(solverType, varargin);

Input Arguments

obj

CVaR portfolio object [PortfolioCVaR].

solverType

Solver to use for CVaR portfolio optimization [string]. The supported solverType are:

  • 'fmincon'

  • 'cuttingplane'

Use optimoptions to specify further options for CVaR portfolio optimization.

Default: 'fmincon' using the 'sqp' algorithm

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.

'varargin'

Options to control the solver specified in solverType as name-value pair arguments or an optimoptions object. optimoptions is the default and recommended method to set solver options, however optimset is also supported.

    Note:  

    • For the default solver, 'fmincon', PortfolioCVaR by default sets the algorithm to 'sqp', uses objective function gradients, and turns the display off. All fmincon options are supported, either as name-value pair arguments or using an optimoptions object. For more information about fmincon and quadratic programming algorithms and options, see Quadratic Programming Algorithms.

    • For the cuttingplane solver, the following solver options are available as name-value pair arguments:

      • 'MaxIter'

      • 'AbsTol'

      • 'RelTol'

      • 'MasterSolverOptions'

'MaxIter '

Positive integer number for the maximum number of iterations.

Default: 1000

'AbsTol '

Positive scalar value for the absolute stopping tolerance.

Default: 1e-6

'RelTol '

Positive scalar for the relative stopping tolerance.

Default: 1e-5

'MasterSolverOptions'

optimoptions object for the options for the master solver linprog. For more information about linprog and linear programming algorithms and options, see Linear Programming Algorithms.

Default: optimoptions('linprog','Algorithm','Dual-Simplex','Display','off')

Output Arguments

obj

Updated CVaR portfolio object [PortfolioCVaR].

Attributes

Accesspublic
Staticfalse
Hiddenfalse

To learn about attributes of methods, see Method Attributes in the MATLAB® Object-Oriented Programming documentation.

Examples

expand all

Set the Solver Type as 'fmincon'

Use 'fmincon' as the solverType.

p = PortfolioCVaR;
p = setSolver(p, 'fmincon');
display(p.solverType);
fmincon

Set the Solver Type as 'fmincon' and Use Name-Value Pair Arguments to Set the Algorithm

Use 'fmincon' as the solverType and use name-value pair arguments to set the algorithm to|'trust-region-reflective'| and to turn off the display.

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

Set the Solver Type as 'fmincon' and Use an optimoptions Object to Set the Algorithm

Use 'fmincon' as the solverType and use an optimoptions object to set the algorithm to 'trust-region-reflective' and to turn off the display.

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

Set 'cuttingplane' as the Solver Type with Default Options

Use 'cuttingplane' as the solverType with default options.

p = PortfolioCVaR;
p = setSolver(p,'cuttingplane');
display(p.solverType);
cuttingplane

Set 'cuttingplane' as the Solver Type with Maximum Iterations

Use the Name-Value pair 'MaxIter' to set the maximum number of iterations to 1500.

p = PortfolioCVaR;
p = setSolver(p,'cuttingplane','MaxIter',1500);
display(p.solverType);
display(p.solverOptions);
cuttingplane
                MaxIter: 1500
                 AbsTol: 1.0000e-06
                 RelTol: 1.0000e-05
    MasterSolverOptions: [1x1 optim.options.Linprog]

Set 'cuttingplane' as the Solver Type and Change the Master Solver Option

For the master solver, continue using the dual-simplex algorithm with no display, but tighten its termination tolerance to 1e-8.

p = PortfolioCVaR;
options = optimoptions('linprog','Algorithm', 'Dual-Simplex', 'Display','off', 'TolFun',1e-8);
p = setSolver(p,'cuttingplane','MasterSolverOptions',options);
display(p.solverType)
display(p.solverOptions)
display(p.solverOptions.MasterSolverOptions.Algorithm)
display(p.solverOptions.MasterSolverOptions.Display)
display(p.solverOptions.MasterSolverOptions.TolFun)
cuttingplane
                MaxIter: 1000
                 AbsTol: 1.0000e-06
                 RelTol: 1.0000e-05
    MasterSolverOptions: [1x1 optim.options.Linprog]

dual-simplex
off

ans =

   1.0000e-08

For the master solver, use the interior-point algorithm with no display, and with a termination tolerance of 1e-7.

p = PortfolioCVaR;
options = optimoptions('linprog','Algorithm','interior-point','Display','off', 'TolFun',1e-7);
p = setSolver(p,'cuttingplane','MasterSolverOptions',options);
display(p.solverType)
display(p.solverOptions)
display(p.solverOptions.MasterSolverOptions.Algorithm)
display(p.solverOptions.MasterSolverOptions.Display)
display(p.solverOptions.MasterSolverOptions.TolFun)
cuttingplane
                MaxIter: 1000
                 AbsTol: 1.0000e-06
                 RelTol: 1.0000e-05
    MasterSolverOptions: [1x1 optim.options.Linprog]

interior-point
off

ans =

   1.0000e-07

Algorithms

One version of the CVaR portfolio optimization problem minimizes risk, measured as the CVaR of the portfolio, subject to a target return and other linear constraints on the portfolio. For the definition of the CVaR function, see Risk Proxy.

minimizexCVaRα(x)

subject to  y¯TxTargetReturn

Axb

Aeqx=beq

lbxub

Vector y¯ is the mean return vector (the column-wise mean of the scenario matrix Y), so that y¯Tx is the expected return of portfolio x. The first constraint says that the expected return must be at least as good as a target return.

An alternative version of the CVaR portfolio optimization problem maximizes the expected return of the portfolio, subject to a target risk and other linear constraints on the portfolio.

maximizexy¯Tx

subject to   CVaRα(x)CVaRLimit

Axb

Aeqx=beq

lbxub

The first constraint in this case says that the portfolio CVaR cannot exceed a given CVaR limit.

By default, the CVaR portfolio object uses fmincon to solve the CVaR portfolio optimization problems. For information about fmincon and quadratic programming algorithms and options, see Quadratic Programming Algorithms.

Alternatively, the CVaR portfolio optimization problems can be solved with 'cuttingplane', an implementation of Kelley's cutting-plane method. For more information, see Kelley [45] at Portfolio Optimization.

References

Kelley, J. E., "The Cutting-Plane Method for Solving Convex Programs," Journal of the Society for Industrial and Applied Mathematics, Vol. 8, No. 4, December 1960, pp. 703-712.

Rockafellar, R. T. and S. Uryasev, "Optimization of Conditional Value-at-Risk," Journal of Risk, Vol. 2, No. 3, Spring 2000, pp. 21–41.

Rockafellar, R. T. and S. Uryasev, "Conditional Value-at-Risk for General Loss Distributions," Journal of Banking and Finance, Vol. 26, 2002, pp. 1443–1471.

Was this topic helpful?