Main Content

Troubleshooting CVaR Portfolio Optimization Results

PortfolioCVaR Object Destroyed When Modifying

If a PortfolioCVaR object is destroyed when modifying, remember to pass an existing object into the PortfolioCVaR object if you want to modify it, otherwise it creates a new object. See Creating the PortfolioCVaR Object for details.

Matrix Incompatibility and "Non-Conformable" Errors

If you get matrix incompatibility or "non-conformable" errors, the representation of data in the tools follows a specific set of basic rules described in Conventions for Representation of Data.

CVaR Portfolio Optimization Warns About “Max Iterations”

If the 'cuttingplane' solver displays the following warning:

Warning: Max iterations reached. Consider modifying the solver options, or using fmincon. 
> In @PortfolioCVaR\private\cvar_cuttingplane_solver at 255
  In @PortfolioCVaR\private\cvar_optim_min_risk at 85
  In PortfolioCVaR.estimateFrontier at 69
this warning indicates that some of the reported efficient portfolios may not be accurate enough.

This warning is usually related to portfolios in the lower-left end of the efficient frontier. The cutting plane solver may have gotten very close to the solution, but there may be too many portfolios with very similar risks and returns in that neighborhood, and the solver runs out of iterations before reaching the desired accuracy.

To correct this problem, you can use setSolver to make any of these changes:

  • Increase the maximum number of iterations ('MaxIter').

  • Relax the stopping tolerances ('AbsTol' and/or 'RelTol').

  • Use a different main solver algorithm ('MainSolverOptions').

  • Alternatively, you can try the 'fmincon' solver.

When the default maximum number of iterations of the 'cuttingplane' solver is reached, the solver usually needs many more iterations to reach the accuracy required by the default stopping tolerances. You may want to combine increasing the number of iterations (e.g., multiply by 5) with relaxing the stopping tolerances (for example, multiply by 10 or 100). Since the CVaR is a stochastic optimization problem, the accuracy of the solution is relative to the scenario sample, so a looser stopping tolerance may be acceptable. Keep in mind that the solution time may increase significantly when you increase the number of iterations. For example, doubling the number of iterations more than doubles the solution time. Sometimes using a different main solver (for example, switching to 'interior-point' if you are using the default 'simplex') can get the 'cuttingplane' solver to converge without changing the maximum number of iterations.

Alternatively, the 'fmincon' solver may be faster than the 'cuttingplane' solver for problems where cutting plane reaches the maximum number of iterations.

CVaR Portfolio Optimization Errors with “Could Not Solve” Message

If the 'cuttingplane' solver generates the following error:

Error using cvar_cuttingplane_solver (line 251)
Could not solve the problem. Consider modifying the solver options, or using fmincon.

Error in cvar_optim_by_return (line 100)
		[x,~,~,exitflag] = cvar_cuttingplane_solver(...

Error in PortfolioCVaR/estimateFrontier (line 80)
	pwgt = cvar_optim_by_return(obj, r(2:end-1), obj.NumAssets, ...
this error means that the master solver failed to solve one of the master problems. The error may be due to numerical instability or other problem-specific situation.

To correct this problem, you can use setSolver to make any of these changes:

  • Modify the main solver options ('MainSolverOptions'), for example, change the algorithm ('Algorithm') or the termination tolerance ('TolFun').

  • Alternatively, you can try the 'fmincon' solver.

Missing Data Estimation Fails

If asset return data has missing or NaN values, the simulateNormalScenariosByData function with the 'missingdata' flag set to true may fail with either too many iterations or a singular covariance. To correct this problem, consider this:

  • If you have asset return data with no missing or NaN values, you can compute a covariance matrix that may be singular without difficulties. If you have missing or NaN values in your data, the supported missing data feature requires that your covariance matrix must be positive-definite, that is, nonsingular.

  • simulateNormalScenariosByData uses default settings for the missing data estimation procedure that might not be appropriate for all problems.

In either case, you might want to estimate the moments of asset returns separately with either the ECM estimation functions such as ecmnmle or with your own functions.

cvar_optim_transform Errors

If you obtain optimization errors such as:

Error using cvar_optim_transform (line 276)
Portfolio set appears to be either empty or unbounded. Check constraints.

Error in PortfolioCVaR/estimateFrontier (line 64)
	[AI, bI, AE, bE, lB, uB, f0, f, x0] = cvar_optim_transform(obj);
Error using cvar_optim_transform (line 281)
Cannot obtain finite lower bounds for specified portfolio set.

Error in PortfolioCVaR/estimateFrontier (line 64)
	[AI, bI, AE, bE, lB, uB, f0, f, x0] = cvar_optim_transform(obj);
Since the portfolio optimization tools require a bounded portfolio set, these errors (and similar errors) can occur if your portfolio set is either empty and, if nonempty, unbounded. Specifically, the portfolio optimization algorithm requires that your portfolio set have at least a finite lower bound. The best way to deal with these problems is to use the validation functions in Validate the CVaR Portfolio Problem. Specifically, use estimateBounds to examine your portfolio set, and use checkFeasibility to ensure that your initial portfolio is either feasible and, if infeasible, that you have sufficient turnover to get from your initial portfolio to the portfolio set.


To correct this problem, try solving your problem with larger values for turnover and gradually reduce to the value that you want.

Efficient Portfolios Do Not Make Sense

If you obtain efficient portfolios that, do not seem to make sense, this can happen if you forget to set specific constraints or you set incorrect constraints. For example, if you allow portfolio weights to fall between 0 and 1 and do not set a budget constraint, you can get portfolios that are 100% invested in every asset. Although it may be hard to detect, the best thing to do is to review the constraints you have set with display of the PortfolioCVaR object. If you get portfolios with 100% invested in each asset, you can review the display of your object and quickly see that no budget constraint is set. Also, you can use estimateBounds and checkFeasibility to determine if the bounds for your portfolio set make sense and to determine if the portfolios you obtained are feasible relative to an independent formulation of your portfolio set.

See Also

| |

Related Examples

More About

External Websites