Documentation Center

  • 評価版
  • 製品アップデート

setSolver

Class: Portfolio

Choose main solver and specify associated solver options for portfolio optimization

Syntax

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

Description

obj = setSolver(obj,solverType) chooses the solver for 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, a structure created by optimoptions.

Tips

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

obj = obj.setSolver(solverType, varargin);

Input Arguments

obj

Portfolio object [Portfolio].

solverType

Solver to use for portfolio optimization [string]. The default solver for the Portfolio object is 'lcprog' with the control variables 'maxiter', 'tiebreak', 'tolpiv'.

Default: 'lcprog'

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, optimoptions is the default and recommended method to set solver options, however optimset is also supported.

    Note:   The default solver for the Portfolio object is 'lcprog'. The Portfolio object can also use 'quadprog', which has several different options that can be set with optimoptions. Unlike Optimization Toolbox software which uses the trust-region-reflective algorithm as the default algorithm for quadprog, the portfolio optimization tools use the interior-point-convex algorithm. For more information about quadprog and quadratic programming algorithms and options, see Quadratic Programming Algorithms.

Output Arguments

obj

Updated Portfolio object [Portfolio].

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

If you use the quadprog function as the solverType, the default is the interior-point-convex version of quadprog.

load CAPMuniverse
p = Portfolio('AssetList',Assets(1:12));
p = p.setDefaultConstraints;
p = p.setSolver('quadprog');
display(p.solverType);
quadprog

You can switch back to lcprog with:

p = p.setSolver('lcprog');
display(p.solverType);
lcprog

See Also

| |

Was this topic helpful?