Quantcast

Documentation Center

  • Trial Software
  • Product Updates

setSolver

Class: PortfolioMAD

Choose main solver and solver options for MAD portfolio optimization

Syntax

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

Description

obj = setSolver(obj,solverType) chooses the solver for MAD 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

Use dot notation to choose the solver and specify associated solver options.

obj = obj.setSolver(solverType, varargin);

Input Arguments

obj

MAD portfolio object [PortfolioMAD].

solverType

Solver to use for MAD portfolio optimization [string]. The supported solverType is:

  • 'fmincon'

Use optimoptions to specify further options for MAD portfolio optimization.

Default: 'fmincon' using the 'sqb' algorithm and 'GradObj' set to 'on'

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.

    Note:  

    • For the default solver 'fmincon', PortfolioMAD, by default, sets the algorithm to 'sqp' and turns the display off. While all variations of fmincon from Optimization Toolbox are accepted, use of 'sqp' and 'active-set' algorithms for fmincon are recommended and the use of 'interior-point' and 'trust-region-reflective' algorithms are not recommended for MAD portfolio optimization.

    • All fmincon options are supported either as name-value pair arguments or using an optimoptions object.

    • optimoptions is the default and recommended method to set solver options, however optimset is also supported. For details about fmincon and constrained nonlinear optimization algorithms and options, see Constrained Nonlinear Optimization Algorithms.

Output Arguments

obj

Updated MAD portfolio object [PortfolioMAD].

Attributes

Accesspublic
Staticfalse
Hiddenfalse

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

Examples

expand all

Set Solver Type as 'fmincon'

Use 'fmincon' as the solverType.

p = PortfolioMAD;
p = p.setSolver('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|'sqp'| and to turn on the display.

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

Set Solver Type as 'fmincon' and Use an optimoptions Structure 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 = PortfolioMAD;
options = optimoptions('fmincon', 'Algorithm', 'trust-region-reflective', 'Display', 'off');
p = p.setSolver('fmincon', options);
display(p.solverOptions.Algorithm);
display(p.solverOptions.Display);
trust-region-reflective
off

Set the Solver Type as 'fmincon' and Use an optimoptions Structure to Set the Algorithm and Use of Gradients

Use 'fmincon' as the solverType and use an optimoptions object to set the algorithm to 'active-set' and to set the gradients flag 'on' for 'GradObj' and turn off the display.

p = PortfolioMAD;
options = optimoptions('fmincon','algorithm','active-set','display','off','gradobj','on');
p = p.setSolver('fmincon',options);
p = p.setSolver('fmincon', options);
display(p.solverOptions.Algorithm);
display(p.solverOptions.Display);
active-set
off

References

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.

See Also

| | |

Was this topic helpful?