Figure 1. Problem in PSG Toolbox Window
Case study Portfolio Optimization with Second Orders Stochastic Dominance Constraints (see Formal Problem Statement) in MATLAB Environment is solved with tbpsg_run PSG function.
Main MATLAB code is in file CS_SSD_Portfolio_Optimization_Toolbox.m.
Data are saved in file SSD_Portfolio_Optimization_data_Toolbox.mat:
• | Scenarios of rates of returns (matrix_sde) used in (CS.1), (CS.2) and matrix for budget constraint (matrix_budget) used in (CS.3) (in toolboxstruc_arr structure). |
• | Benchmark portfolio rates of returns used in (CS.2) (in benchmark_sd variable). |
• | Calculated upper bounds for constraints (CS.2) (in ubound_sd variable ). |
Let us describe the main operations. To run case study you need to do the following main steps:
In file CS_SSD_Portfolio_Optimization_Toolbox.m:
clc;
clear;
Load problem data:
load('.\SSD_Portfolio_Optimization_data_Toolbox.mat');
Save variables from structure toolboxstruc_arr to Workspace:
tbpsg_export_to_workspace(toolboxstruc_arr);
J=size(toolboxstruc_arr(1).data.data,1); % A number of scenarios
I=size(toolboxstruc_arr(1).data.data,2); % A number of variables
Find redundant constraints:
ic=[];
for j=2:J
for j1=1:j-1
if ubound_sd(j)>=ubound_sd(j1) && benchmark_sd(j)<=benchmark_sd(j1), ic=[ic,j]; break, end
if ubound_sd(j)<=ubound_sd(j1) && benchmark_sd(j)>=benchmark_sd(j1), ic=[ic,j1]; end
end
end
ubound_sd_loc=ubound_sd;
benchmark_sd_loc=benchmark_sd;
ubound_sd_loc(ic) = [];
benchmark_sd_loc(ic) = [];
Create problem statement:
problem_head=['maximize', char(10),...
' linear(matrix_sde)', char(10),...
'Constraint: = 1', char(10),...
' linear(matrix_budget)'];
problem_newc='';
problem_newc=[problem_newc ...
'MultiConstraint: <= vector_ub',char(10),...
' pm_pen(vector_th, matrix_sde)',char(10)];
problem_box=[ 'Box: >=0, <=1',char(10),...
'Solver: precision = 9'];
problem_statement=[problem_head,char(10), problem_newc, problem_box];
disp(sprintf('Number of non-redundand constraints %g',size(ic,2)));
clear problem_head problem_newc problem_box j j1 ic;
Pack vector with upper bounds in constraints to PSG Toolbox structure:
toolboxstruc_arr(3) = tbpsg_vector_pack('vector_ub', ubound_sd_loc);
Pack vector with parameters of pm_pen function to PSG Toolbox structure:
toolboxstruc_arr(4) = tbpsg_vector_pack('vector_th', -benchmark_sd_loc);
% Uncomment the following line to open the problem in Toolbox Window:
% tbpsg_toolbox(problem_statement,toolboxstruc_arr);
Optimize problem:
[solution_SSD, outargstruc_SSD] = tbpsg_run(problem_statement, toolboxstruc_arr);
Display main results:
disp(' '); disp(' ')
disp(' Report ')
disp(' ')
disp('Solution_SSD ')
dx = strfind(solution_SSD, 'Constraint:');
disp(solution_SSD(1:dx(1)-1));
clear dx;
Optimal_point = tbpsg_optimal_point_data(solution_SSD, outargstruc_SSD)';
disp('Optimal point:');
for i=1:I; disp(['x', int2str(i),' = ' num2str(Optimal_point(i),7)]);
end
clear i; disp(' ')
Problem: problem_ssd, solution_status = optimal
Timing: Data_loading_time = 0.51, Preprocessing_time = 0.02, Solving_time = 0.96
Variables: optimal_point = point_problem_ssd
Objective: objective = 1.865255596763E-02 Gap: = -2.740863092043E-16
x1 = 0
x2 = 0
x3 = 0
x4 = 0.02911967
x5 = 0
x6 = 0
x7 = 0
x8 = 0
x9 = 0
x10 = 0
x11 = 0
x12 = 0
x13 = 0
x14 = 0
x15 = 0
x16 = 0
x17 = 0
x18 = 0
x19 = 0
x20 = 0
x21 = 0.2616667
x22 = 0
x23 = 0
x24 = 0
x25 = 0
x26 = 0
x27 = 0
x28 = 0
x29 = 0
x30 = 0
x31 = 0
x32 = 0
x33 = 0
x34 = 0
x35 = 0
x36 = 0
x37 = 0
x38 = 0
x39 = 0
x40 = 0
x41 = 0
x42 = 0
x43 = 0
x44 = 0
x45 = 0.2527069
x46 = 0
x47 = 0
x48 = 0
x49 = 0
x50 = 0
x51 = 0
x52 = 0
x53 = 0
x54 = 0
x55 = 0
x56 = 0.3583057
x57 = 0
x58 = 0.07687519
x59 = 0
x60 = 0
x61 = 0
x62 = 0
x63 = 0
x64 = 0
x65 = 0
x66 = 0
x67 = 0
x68 = 0
x69 = 0
x70 = 0
x71 = 0
x72 = 0
x73 = 0
x74 = 0
x75 = 0
x76 = 0.02132584
Figure 1. Problem in PSG Toolbox Window