%% Configure MINLP Solver and Options When Using a PortfolioMAD Object
% Configure the MINLP solver for a 12 asset portfolio that is using semicontinuous and cardinality constraints.

load CAPMuniverse
p = PortfolioMAD('AssetList',Assets(1:12));
p = simulateNormalScenariosByData(p, Data(:,1:12), 20000 ,'missingdata',true);

% When working with a PortfolioMAD object, the setMinMaxNumAssets function enables you to set up the limits on the number of assets invested. The following example specifies that a minimum of five assets and a maximum of 10 assets should be invested using setMinMaxNumAssets and the investments should be greater than 4% and less than 45% using setBounds.

p = setMinMaxNumAssets(p, 5, 10);  
p = setBounds(p, 0.04, 0.45, 'BoundType', 'conditional');  

% Three different MINLP solvers (OuterApproximation, ExtendedCP, TrustRegionCP) use the cutting plane method. Use the setSolverMINLP function to configure the OuterApproximation solver and options.

pint = setSolverMINLP(p,'OuterApproximation', 'NonlinearScalingFactor', 1e4, 'Display', 'iter', 'CutGeneration', 'basic');
pint.solverTypeMINLP
pint.solverOptionsMINLP

% You can also configure the options for intlinprog,which is the Master solver for mixed integer linear programming problems in the MINLP solver.

pint = setSolverMINLP(p,'OuterApproximation', 'IntMasterSolverOptions', optimoptions('intlinprog','Display','off'));
pint.solverOptionsMINLP.IntMasterSolverOptions

%
% Copyright 2018 The MathWorks, Inc.