%This m-file demonstrates the first optimization setup minimizing outcome %spread payments for the given CDO portfolio subject to a risk constraint %assuring the rating of a tranche, single-period default probability %constraints, and linear constraints on attachment points. clc clear; %Load data from file: load('Data_for_Step-up_CDO_I_Toolbox.mat'); tbpsg_export_to_workspace(toolboxstruc_arr); N_attach_points = 5; %Specify the set of values of upper bound on probability that the %cumulative collateral loss exceeds the tranche attachment point %at least once in periods 1,…, T). Columns correspond to credit rating %(BBB, A, AA, AAA) Param_Mult_Prob = [0.0281 0.0071 0.0036 0.0012]; %Specify the set of values of upper bound on single-period %default probability. Rows correspond to credit rating (BBB, A, AA, AAA), %and columns correspond to the single-periods Param_Single_Prob = [0.0053018868 0.0106037736 0.0159056604 0.0227981132 0.0281;... 0.0013396226 0.0026792453 0.0040188679 0.0057603774 0.0071;... 0.0006792453 0.0013584904 0.0020377358 0.0029207547 0.0036;... 0.0002264151 0.0004528302 0.0006792453 0.0009735849 0.0012]; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Optimization Problem 1 (Example 1,Case 1) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Generate fragments of the problem description common for all parameter %values within Optimization Problem 1 (Example 1,Case 1) str1 = sprintf('Problem: problem_example_1_case_1, type = minimize'); str2 = sprintf('Objective: objective_linear_sum_of_x_5, linearize = 0'); str3 = sprintf(' linear_sum_of_x_5(matrix_sum_of_x_5)'); str5 = sprintf(' prmulti_pen_5_periods(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)'); str6 = sprintf('Box: >= point_lowerbounds, <= point_upperbounds'); str7 = sprintf('Solver: VAN, precision = 9'); %Begin loop for Optimization Problem 1 (Example 1,Case 1) over parameter values for i=1:1:length(Param_Mult_Prob) %Generate parameter-specific fragment of the problem description str4 = sprintf('%s%.7f','Constraint: constraint_mult_prob, upper_bound = ',Param_Mult_Prob(i)); %Generate problem statement clear problem_statement; problem_statement = sprintf('%s\n', str1, str2, str3, str4, str5, str6, str7); %Uncomment the following line to open the problem in Toolbox Window: %tbpsg_toolbox(problem_statement,toolboxstruc_arr); %Optimize the problem [solution_str, outargstruc_arr] = tbpsg_run(problem_statement, toolboxstruc_arr); %Extract optimal solution point_variables = tbpsg_optimal_point_vars(solution_str, outargstruc_arr); loc = tbpsg_optimal_point_data(solution_str, outargstruc_arr); Points_Problem_1(:,i) = loc'; Sum_Attach_Points_Problem_1(i) = tbpsg_objective(solution_str, outargstruc_arr); Multiple_Probabilities_Problem_1(i) = tbpsg_constraints_data(solution_str, outargstruc_arr); toolboxstruc_arr(size(toolboxstruc_arr,2)+1) = tbpsg_point_pack(['point_opt_point_Problem_1_' int2str(i)],loc,point_variables); Constr_period1_Problem_1(i) = tbpsg_function_value(' pr_pen_period1(0.0, matrix_10000_1)', ['point_opt_point_Problem_1_' int2str(i)], toolboxstruc_arr); Constr_period2_Problem_1(i) = tbpsg_function_value(' prmulti_pen_period2(0.0,matrix_10000_1,matrix_10000_2)', ['point_opt_point_Problem_1_' int2str(i)], toolboxstruc_arr); Constr_period3_Problem_1(i) = tbpsg_function_value(' prmulti_pen_period3(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3)', ['point_opt_point_Problem_1_' int2str(i)], toolboxstruc_arr); Constr_period4_Problem_1(i) = tbpsg_function_value(' prmulti_pen_period4(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4)', ['point_opt_point_Problem_1_' int2str(i)], toolboxstruc_arr); Constr_period5_Problem_1(i) = tbpsg_function_value(' prmulti_pen_period5(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)', ['point_opt_point_Problem_1_' int2str(i)], toolboxstruc_arr); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Optimization Problem 2 (Example 1,Case 2) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Generate fragments of the problem description common for all parameter %values within Optimization Problem 2 (Example 1,Case 2) str1 = sprintf('Problem: problem_example_1_case_2, type = minimize'); str2 = sprintf('Objective: objective_linear_sum_of_x_5, linearize = 0'); str3 = sprintf(' linear_sum_of_x_5(matrix_sum_of_x_5)'); str5 = sprintf(' prmulti_pen_5_periods(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)'); str6 = sprintf('Constraint: constraint_x1_x2, lower_bound = 0, upper_bound = 0, linearize = 0'); str7 = sprintf(' linear_x1_x2(matrix_x1_x2)'); str8 = sprintf('Constraint: constraint_x2_x3, lower_bound = 0, upper_bound = 0, linearize = 0'); str9 = sprintf(' linear_x2_x3(matrix_x2_x3)'); str10 = sprintf('Constraint: constraint_x3_x4, lower_bound = 0, upper_bound = 0, linearize = 0'); str11 = sprintf(' linear_x3_x4(matrix_x3_x4)'); str12 = sprintf('Constraint: constraint_x4_x5, lower_bound = 0, upper_bound = 0, linearize = 0'); str13 = sprintf(' linear_x4_x5(matrix_x4_x5)'); str14 = sprintf('Box: >= point_lowerbounds, <= point_upperbounds'); str15 = sprintf('Solver: VAN, precision = 9'); %Begin loop for Optimization Problem 2 (Example 1,Case 2) over parameter values for i=1:1:length(Param_Mult_Prob) %Generate parameter-specific fragment of the problem description str4 = sprintf('%s%.7f','Constraint: constraint_mult_prob, upper_bound = ',Param_Mult_Prob(i)); %Generate problem statement clear problem_statement; problem_statement = sprintf('%s\n', str1, str2, str3, str4, str5, str6, str7,... str8, str9, str10, str11, str12, str13, str14,str15); %Uncomment the following line to open the problem in Toolbox Window: %tbpsg_toolbox(problem_statement,toolboxstruc_arr); %Optimize the problem [solution_str, outargstruc_arr] = tbpsg_run(problem_statement, toolboxstruc_arr); point_variables = tbpsg_optimal_point_vars(solution_str, outargstruc_arr); loc = tbpsg_optimal_point_data(solution_str, outargstruc_arr); Points_Problem_2(:,i) = loc'; Sum_Attach_Points_Problem_2(i) = tbpsg_objective(solution_str, outargstruc_arr); constr_data = tbpsg_constraints_data(solution_str, outargstruc_arr); Multiple_Probabilities_Problem_2(i) = constr_data(1); toolboxstruc_arr(size(toolboxstruc_arr,2)+1) = tbpsg_point_pack(['point_opt_point_Problem_2_' int2str(i)],loc,point_variables); Constr_period1_Problem_2(i) = tbpsg_function_value('pr_pen_period1(0.0, matrix_10000_1)', ['point_opt_point_Problem_2_' int2str(i)], toolboxstruc_arr); Constr_period2_Problem_2(i) = tbpsg_function_value('prmulti_pen_period2(0.0,matrix_10000_1,matrix_10000_2)', ['point_opt_point_Problem_2_' int2str(i)], toolboxstruc_arr); Constr_period3_Problem_2(i) = tbpsg_function_value('prmulti_pen_period3(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3)', ['point_opt_point_Problem_2_' int2str(i)], toolboxstruc_arr); Constr_period4_Problem_2(i) = tbpsg_function_value('prmulti_pen_period4(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4)', ['point_opt_point_Problem_2_' int2str(i)], toolboxstruc_arr); Constr_period5_Problem_2(i) = tbpsg_function_value('prmulti_pen_period5(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)', ['point_opt_point_Problem_2_' int2str(i)], toolboxstruc_arr); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Optimization Problem 3 (Example 2) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Generate fragments of the problem description common for all parameter %values within Optimization Problem 3 (Example 2) str1 = sprintf('Problem: problem_example_2, type = minimize'); str2 = sprintf('Objective: objective_problem_3'); str3 = sprintf(' 0.966736489*pm_pen_g_period_1(0.0, matrix_10000_1)'); str4 = sprintf(' +0.903492046*pm_pen_g_period_2(0.0, matrix_10000_2)'); str5 = sprintf(' +0.84438509*pm_pen_g_period_3(0.0, matrix_10000_3)'); str6 = sprintf(' +0.789144944*pm_pen_g_period_4(0.0, matrix_10000_4)'); str7 = sprintf(' +0.737518639*pm_pen_g_period_5(0.0, matrix_10000_5)'); str9 = sprintf(' pr_pen_period1(0.0, matrix_10000_1)'); str11 = sprintf(' prmulti_pen_period2(0.0,matrix_10000_1,matrix_10000_2)'); str13 = sprintf(' prmulti_pen_period3(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3)'); str15 = sprintf(' prmulti_pen_period4(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4)'); str17 = sprintf(' prmulti_pen_period5(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)'); str18 = sprintf('Box: >= point_lowerbounds, <= point_upperbounds'); str19 = sprintf('Solver: VAN, precision = 9'); %Begin loop for Optimization Problem 3 (Example 2) over parameter values for i=1:1:size(Param_Single_Prob,1) %Generate parameter-specific fragments of the problem description str8 = sprintf('%s%.10f','Constraint: constraint_period1, upper_bound = ',Param_Single_Prob(i,1)); str10 = sprintf('%s%.10f','Constraint: constraint_period2, upper_bound = ',Param_Single_Prob(i,2)); str12 = sprintf('%s%.10f','Constraint: constraint_period3, upper_bound = ',Param_Single_Prob(i,3)); str14 = sprintf('%s%.10f','Constraint: constraint_period4, upper_bound = ',Param_Single_Prob(i,4)); str16 = sprintf('%s%.10f','Constraint: constraint_period5, upper_bound = ',Param_Single_Prob(i,5)); %Generate problem statement clear problem_statement; problem_statement = sprintf('%s\n', str1, str2, str3, str4, str5, str6, str7,... str8, str9, str10, str11, str12, str13, str14, str15, str16, str17, str18, str19); %Uncomment the following line to open the problem in Toolbox Window: %tbpsg_toolbox(problem_statement,toolboxstruc_arr); %Optimize the problem [solution_str, outargstruc_arr] = tbpsg_run(problem_statement, toolboxstruc_arr); %Extract optimal solution point_variables = tbpsg_optimal_point_vars(solution_str, outargstruc_arr); loc = tbpsg_optimal_point_data(solution_str, outargstruc_arr); Points_Problem_3(:,i)= loc'; Obj_Problem_3(i) = tbpsg_objective(solution_str, outargstruc_arr); toolboxstruc_arr(size(toolboxstruc_arr,2)+1) = tbpsg_point_pack(['point_opt_point_Problem_3_' int2str(i)],loc,point_variables); Constr_period1_Problem_3(i) = tbpsg_function_value('pr_pen_period1(0.0, matrix_10000_1)', ['point_opt_point_Problem_3_' int2str(i)], toolboxstruc_arr); Constr_period2_Problem_3(i) = tbpsg_function_value('prmulti_pen_period2(0.0,matrix_10000_1,matrix_10000_2)', ['point_opt_point_Problem_3_' int2str(i)], toolboxstruc_arr); Constr_period3_Problem_3(i) = tbpsg_function_value('prmulti_pen_period3(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3)', ['point_opt_point_Problem_3_' int2str(i)], toolboxstruc_arr); Constr_period4_Problem_3(i) = tbpsg_function_value('prmulti_pen_period4(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4)', ['point_opt_point_Problem_3_' int2str(i)], toolboxstruc_arr); Constr_period5_Problem_3(i) = tbpsg_function_value('prmulti_pen_period5(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)', ['point_opt_point_Problem_3_' int2str(i)], toolboxstruc_arr); Multiple_Probabilities_Problem_3(i) = Constr_period5_Problem_3(i); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Optimization Problem 4 (Example 3, case 1) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Generate fragments of the problem description common for all parameter %values within Optimization Problem 4 (Example 3, case 1) str1 = sprintf('Problem: problem_example_3_case_1, type = minimize'); str2 = sprintf('Objective: objective_problem_4'); str3 = sprintf('0.966736489*pm_pen_g_period_1(0.0, matrix_10000_1)'); str4 = sprintf('+0.903492046*pm_pen_g_period_2(0.0, matrix_10000_2)'); str5 = sprintf('+0.84438509*pm_pen_g_period_3(0.0, matrix_10000_3)'); str6 = sprintf('+0.789144944*pm_pen_g_period_4(0.0, matrix_10000_4)'); str7 = sprintf('+0.737518639*pm_pen_g_period_5(0.0, matrix_10000_5)'); str9 = sprintf('prmulti_pen_5_periods(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)'); str10 = sprintf('Box: >= point_lowerbounds, <= point_upperbounds'); str11 = sprintf('Solver: VAN, precision = 9'); %Begin loop for Optimization Problem 4 (Example 3,Case 1) over parameter values for i=1:1:length(Param_Mult_Prob) %Generate parameter-specific fragment of the problem description str8 = sprintf('%s%.7f','Constraint: constraint_mult_prob, upper_bound = ',Param_Mult_Prob(i)); %Generate problem statement clear problem_statement; problem_statement = sprintf('%s\n', str1, str2, str3, str4, str5, str6, str7,... str8, str9, str10, str11); %Uncomment the following line to open the problem in Toolbox Window: %tbpsg_toolbox(problem_statement,toolboxstruc_arr); %Optimize the problem [solution_str, outargstruc_arr] = tbpsg_run(problem_statement, toolboxstruc_arr); %Extract optimal solution point_variables = tbpsg_optimal_point_vars(solution_str, outargstruc_arr); loc = tbpsg_optimal_point_data(solution_str, outargstruc_arr); Points_Problem_4(:,i)= loc'; Obj_Problem_4(i) = tbpsg_objective(solution_str, outargstruc_arr); constr_data = tbpsg_constraints_data(solution_str, outargstruc_arr); Multiple_Probabilities_Problem_4(i) = constr_data(1); toolboxstruc_arr(size(toolboxstruc_arr,2)+1) = tbpsg_point_pack(['point_opt_point_Problem_4_' int2str(i)],loc,point_variables); Constr_period1_Problem_4(i) = tbpsg_function_value('pr_pen_period1(0.0, matrix_10000_1)', ['point_opt_point_Problem_4_' int2str(i)], toolboxstruc_arr); Constr_period2_Problem_4(i) = tbpsg_function_value('prmulti_pen_period2(0.0,matrix_10000_1,matrix_10000_2)', ['point_opt_point_Problem_4_' int2str(i)], toolboxstruc_arr); Constr_period3_Problem_4(i) = tbpsg_function_value('prmulti_pen_period3(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3)', ['point_opt_point_Problem_4_' int2str(i)], toolboxstruc_arr); Constr_period4_Problem_4(i) = tbpsg_function_value('prmulti_pen_period4(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4)', ['point_opt_point_Problem_4_' int2str(i)], toolboxstruc_arr); Constr_period5_Problem_4(i) = tbpsg_function_value('prmulti_pen_period5(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)', ['point_opt_point_Problem_4_' int2str(i)], toolboxstruc_arr); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Optimization Problem 5 (Example 3, case 2) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Generate fragments of the problem description common for all parameter %values within Optimization Problem 5 (Example 3, case 2) str1 = sprintf('Problem: problem_example_3_case_2, type = minimize'); str2 = sprintf('Objective: objective_problem_5'); str3 = sprintf('0.966736489*pm_pen_g_period_1(0.0, matrix_10000_1)'); str4 = sprintf('+0.903492046*pm_pen_g_period_2(0.0, matrix_10000_2)'); str5 = sprintf('+0.84438509*pm_pen_g_period_3(0.0, matrix_10000_3)'); str6 = sprintf('+0.789144944*pm_pen_g_period_4(0.0, matrix_10000_4)'); str7 = sprintf('+0.737518639*pm_pen_g_period_5(0.0, matrix_10000_5)'); str9 = sprintf('prmulti_pen_5_periods(0.00000000,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)'); str10 = sprintf('Constraint: constraint_x1_x2, lower_bound = 0, upper_bound = 0, linearize = 0'); str11 = sprintf('linear_x1_x2(matrix_x1_x2)'); str12 = sprintf('Constraint: constraint_x2_x3, lower_bound = 0, upper_bound = 0, linearize = 0'); str13 = sprintf('linear_x2_x3(matrix_x2_x3)'); str14 = sprintf('Constraint: constraint_x3_x4, lower_bound = 0, upper_bound = 0, linearize = 0'); str15 = sprintf('linear_x3_x4(matrix_x3_x4)'); str16 = sprintf('Constraint: constraint_x4_x5, lower_bound = 0, upper_bound = 0, linearize = 0'); str17 = sprintf('linear_x4_x5(matrix_x4_x5)'); str18 = sprintf('Box: >= point_lowerbounds, <= point_upperbounds'); str19 = sprintf('Solver: VAN, precision = 9'); %Begin loop for Optimization Problem 5 (Example 3,Case 2) over parameter values for i=1:1:length(Param_Mult_Prob) %Generate parameter-specific fragment of the problem description str8 = sprintf('%s%.7f','Constraint: constraint_mult_prob, upper_bound = ',Param_Mult_Prob(i)); %Generate problem statement clear problem_statement; problem_statement = sprintf('%s\n', str1, str2, str3, str4, str5, str6, str7,... str8, str9, str10, str11, str12, str13, str14, str15, str16, str17, str18, str19); %Uncomment the following line to open the problem in Toolbox Window: %tbpsg_toolbox(problem_statement,toolboxstruc_arr); %Optimize the problem [solution_str, outargstruc_arr] = tbpsg_run(problem_statement, toolboxstruc_arr); %Extract optimal solution point_variables = tbpsg_optimal_point_vars(solution_str, outargstruc_arr); loc = tbpsg_optimal_point_data(solution_str, outargstruc_arr); Points_Problem_5(:,i)= loc'; Obj_Problem_5(i) = tbpsg_objective(solution_str, outargstruc_arr); constr_data = tbpsg_constraints_data(solution_str, outargstruc_arr); Multiple_Probabilities_Problem_5(i) = constr_data(1); toolboxstruc_arr(size(toolboxstruc_arr,2)+1) = tbpsg_point_pack(['point_opt_point_Problem_5_' int2str(i)],loc,point_variables); Constr_period1_Problem_5(i) = tbpsg_function_value('pr_pen_period1(0.0, matrix_10000_1)', ['point_opt_point_Problem_5_' int2str(i)], toolboxstruc_arr); Constr_period2_Problem_5(i) = tbpsg_function_value('prmulti_pen_period2(0.0,matrix_10000_1,matrix_10000_2)', ['point_opt_point_Problem_5_' int2str(i)], toolboxstruc_arr); Constr_period3_Problem_5(i) = tbpsg_function_value('prmulti_pen_period3(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3)', ['point_opt_point_Problem_5_' int2str(i)], toolboxstruc_arr); Constr_period4_Problem_5(i) = tbpsg_function_value('prmulti_pen_period4(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4)', ['point_opt_point_Problem_5_' int2str(i)], toolboxstruc_arr); Constr_period5_Problem_5(i) = tbpsg_function_value('prmulti_pen_period5(0.0,matrix_10000_1,matrix_10000_2,matrix_10000_3,matrix_10000_4,matrix_10000_5)', ['point_opt_point_Problem_5_' int2str(i)], toolboxstruc_arr); end warning('on', 'all'); str_ = ['BBB ' 'A ' 'AA ' 'AAA ']; ratings = strread(str_, '%s'); clear str_; str_ = ['Attachment_Point_1 ' 'Attachment_Point_2 ' 'Attachment_Point_3 ' 'Attachment_Point_4 ' 'Attachment_Point_5 ' ]; attach_points_names = strread(str_, '%s'); attach_points_names = strrep(attach_points_names, '_', ' '); clear str_; str_ = ['Attach._Point_1 ' 'Attach._Point_2 ' 'Attach._Point_3 ' 'Attach._Point_4 ' 'Attach._Point_5 ' ]; attach_points_names_graph = strread(str_, '%s'); attach_points_names_graph = strrep(attach_points_names_graph, '_', ' '); clear str_; str_ = ['Problem_1 ' 'Problem_2 ' 'Problem_3 ' 'Problem_4 ' 'Problem_5 ' ]; problems_names = strread(str_, '%s'); problems_names = strrep(problems_names, '_', ' '); clear str_; str_ = ['Linear_Objective_(Problem_1) ' 'Linear_Objective_(Problem_2) ' ... 'Partial_Moment_Objective_(Problem_3) ' 'Partial_Moment_Objective_(Problem_4) '... 'Partial_Moment_Objective_(Problem_5) ']; objectives_names = strread(str_, '%s'); objectives_names = strrep(objectives_names, '_', ' '); clear str_; str_ = ['period_t=1 ' 'period_t=2 ' 'period_t=3 ' 'period_t=4 ' 'period_t=5 ']; period_names = strread(str_, '%s'); period_names = strrep(period_names, '_', ' '); clear str_; % display and save tables with results of calculations outfilename = 'Step-up_CDO_I_Output_Short.txt'; fid = fopen(outfilename, 'w'); fprintf('Table 1. Example 1, Case 1: Attachment Points vs. Rating\n'); fprintf(fid, 'Table 1. Example 1, Case 1: Attachment Points vs. Rating\n'); fprintf('Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); fprintf(fid, 'Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s',ratings{i}); fprintf(fid,'%5s',ratings{i}); for j=1:1:N_attach_points fprintf('%16f',Points_Problem_1(j,i)); fprintf(fid,'%16f',Points_Problem_1(j,i)); end fprintf('\n'); fprintf(fid,'\n'); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 2. Example 1, Case 2: Attachment Points vs. Rating\n'); fprintf(fid,'Table 2. Example 1, Case 2: Attachment Points vs. Rating\n'); fprintf('Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); fprintf(fid,'Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s',ratings{i}); fprintf(fid,'%5s',ratings{i}); for j=1:1:N_attach_points fprintf('%16f',Points_Problem_2(j,i)); fprintf(fid,'%16f',Points_Problem_2(j,i)); end fprintf('\n'); fprintf(fid,'\n'); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 3. Example 2: Attachment Points vs. Rating\n'); fprintf(fid,'Table 3. Example 2: Attachment Points vs. Rating\n'); fprintf('Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); fprintf(fid,'Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s',ratings{i}); fprintf(fid,'%5s',ratings{i}); for j=1:1:N_attach_points fprintf('%16f',Points_Problem_3(j,i)); fprintf(fid,'%16f',Points_Problem_3(j,i)); end fprintf('\n'); fprintf(fid,'\n'); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 4. Example 3, Case 1: Attachment Points vs. Rating\n'); fprintf(fid,'Table 4. Example 3, Case 1: Attachment Points vs. Rating\n'); fprintf('Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); fprintf(fid,'Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s',ratings{i}); fprintf(fid,'%5s',ratings{i}); for j=1:1:N_attach_points fprintf('%16f',Points_Problem_4(j,i)); fprintf(fid,'%16f',Points_Problem_4(j,i)); end fprintf('\n'); fprintf(fid,'\n'); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 5. Example 3, Case 2: Attachment Points vs. Rating\n'); fprintf(fid,'Table 5. Example 3, Case 2: Attachment Points vs. Rating\n'); fprintf('Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); fprintf(fid,'Rating Attach.Point 1 Attach.Point 2 Attach.Point 3 Attach.Point 4 Attach.Point 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s',ratings{i}); fprintf(fid,'%5s',ratings{i}); for j=1:1:N_attach_points fprintf('%16f',Points_Problem_5(j,i)); fprintf(fid,'%16f',Points_Problem_5(j,i)); end fprintf('\n'); fprintf(fid,'\n'); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 6. Comparison of Attachment Points: Example 1, Case 1 vs. Example 3, Case 1\n'); fprintf(fid,'Table 6. Comparison of Attachment Points: Example 1, Case 1 vs. Example 3, Case 1\n'); fprintf('Rating Attachment Points Example 1,Case 1 Example 3,Case 1 Discrepancy\n'); fprintf(fid,'Rating Attachment Points Example 1,Case 1 Example 3,Case 1 Discrepancy\n'); for i=1:1:length(Param_Mult_Prob) for j=1:1:N_attach_points fprintf('%5s%21s%16f%17f%17f%s',ratings{i}, attach_points_names{j},... Points_Problem_1(j,i), Points_Problem_4(j,i),... 100*abs(Points_Problem_4(j,i)-Points_Problem_1(j,i))/Points_Problem_1(j,i),'%'); fprintf(fid,'%5s%21s%16f%17f%17f%s',ratings{i}, attach_points_names{j},... Points_Problem_1(j,i), Points_Problem_4(j,i),... 100*abs(Points_Problem_4(j,i)-Points_Problem_1(j,i))/Points_Problem_1(j,i),'%'); fprintf('\n'); fprintf(fid,'\n'); end end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 7. Comparison of Attachment Points: Example 1, Case 2 vs. Example 3, Case 2\n'); fprintf(fid,'Table 7. Comparison of Attachment Points: Example 1, Case 2 vs. Example 3, Case 2\n'); fprintf('Rating Attachment Points Example 1,Case 2 Example 3,Case 2 Discrepancy\n'); fprintf(fid,'Rating Attachment Points Example 1,Case 2 Example 3,Case 2 Discrepancy\n'); for i=1:1:length(Param_Mult_Prob) for j=1:1:N_attach_points fprintf('%5s%21s%16f%17f%17f%s',ratings{i}, attach_points_names{j},... Points_Problem_2(j,i), Points_Problem_5(j,i),... 100*abs(Points_Problem_5(j,i)-Points_Problem_2(j,i))/Points_Problem_2(j,i),'%'); fprintf(fid,'%5s%21s%16f%17f%17f%s',ratings{i}, attach_points_names{j},... Points_Problem_2(j,i), Points_Problem_5(j,i),... 100*abs(Points_Problem_5(j,i)-Points_Problem_2(j,i))/Points_Problem_2(j,i),'%'); fprintf('\n'); fprintf(fid,'\n'); end end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 8. Default Probabilities of CDO Tranche vs. Ratings for Problems 1 - 5\n'); fprintf(fid,'Table 8. Default Probabilities of CDO Tranche vs. Ratings for Problems 1 - 5\n'); fprintf('Rating Problem 1 Problem 2 Problem 3 Problem 4 Problem 5\n'); fprintf(fid,'Rating Problem 1 Problem 2 Problem 3 Problem 4 Problem 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s%11f%11f%11f%11f%11f\n',ratings{i},Multiple_Probabilities_Problem_1(i),... Multiple_Probabilities_Problem_2(i), Multiple_Probabilities_Problem_3(i),... Multiple_Probabilities_Problem_4(i), Multiple_Probabilities_Problem_5(i)); fprintf(fid,'%5s%11f%11f%11f%11f%11f\n',ratings{i},Multiple_Probabilities_Problem_1(i),... Multiple_Probabilities_Problem_2(i), Multiple_Probabilities_Problem_3(i),... Multiple_Probabilities_Problem_4(i), Multiple_Probabilities_Problem_5(i)); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 9. Single-Period Default Probabilities in Problem 1\n'); fprintf(fid,'Table 9. Single-Period Default Probabilities in Problem 1\n'); fprintf('Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); fprintf(fid,'Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_1(i),... Constr_period2_Problem_1(i)-Constr_period1_Problem_1(i),... Constr_period3_Problem_1(i)-Constr_period2_Problem_1(i),... Constr_period4_Problem_1(i)-Constr_period3_Problem_1(i),... Constr_period5_Problem_1(i)-Constr_period4_Problem_1(i)); fprintf(fid,'%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_1(i),... Constr_period2_Problem_1(i)-Constr_period1_Problem_1(i),... Constr_period3_Problem_1(i)-Constr_period2_Problem_1(i),... Constr_period4_Problem_1(i)-Constr_period3_Problem_1(i),... Constr_period5_Problem_1(i)-Constr_period4_Problem_1(i)); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 10. Single-Period Default Probabilities in Problem 2\n'); fprintf(fid,'Table 10. Single-Period Default Probabilities in Problem 2\n'); fprintf('Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); fprintf(fid,'Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_2(i),... Constr_period2_Problem_2(i)-Constr_period1_Problem_2(i),... Constr_period3_Problem_2(i)-Constr_period2_Problem_2(i),... Constr_period4_Problem_2(i)-Constr_period3_Problem_2(i),... Constr_period5_Problem_2(i)-Constr_period4_Problem_2(i)); fprintf(fid,'%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_2(i),... Constr_period2_Problem_2(i)-Constr_period1_Problem_2(i),... Constr_period3_Problem_2(i)-Constr_period2_Problem_2(i),... Constr_period4_Problem_2(i)-Constr_period3_Problem_2(i),... Constr_period5_Problem_2(i)-Constr_period4_Problem_2(i)); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 11. Single-Period Default Probabilities in Problem 3\n'); fprintf(fid,'Table 11. Single-Period Default Probabilities in Problem 3\n'); fprintf('Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); fprintf(fid,'Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_3(i),... Constr_period2_Problem_3(i)-Constr_period1_Problem_3(i),... Constr_period3_Problem_3(i)-Constr_period2_Problem_3(i),... Constr_period4_Problem_3(i)-Constr_period3_Problem_3(i),... Constr_period5_Problem_3(i)-Constr_period4_Problem_3(i)); fprintf(fid,'%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_3(i),... Constr_period2_Problem_3(i)-Constr_period1_Problem_3(i),... Constr_period3_Problem_3(i)-Constr_period2_Problem_3(i),... Constr_period4_Problem_3(i)-Constr_period3_Problem_3(i),... Constr_period5_Problem_3(i)-Constr_period4_Problem_3(i)); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 12. Single-Period Default Probabilities in Problem 4\n'); fprintf(fid,'Table 12. Single-Period Default Probabilities in Problem 4\n'); fprintf('Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); fprintf(fid,'Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_3(i),... Constr_period2_Problem_4(i)-Constr_period1_Problem_4(i),... Constr_period3_Problem_4(i)-Constr_period2_Problem_4(i),... Constr_period4_Problem_4(i)-Constr_period3_Problem_4(i),... Constr_period5_Problem_4(i)-Constr_period4_Problem_4(i)); fprintf(fid,'%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_3(i),... Constr_period2_Problem_4(i)-Constr_period1_Problem_4(i),... Constr_period3_Problem_4(i)-Constr_period2_Problem_4(i),... Constr_period4_Problem_4(i)-Constr_period3_Problem_4(i),... Constr_period5_Problem_4(i)-Constr_period4_Problem_4(i)); end fprintf('\n'); fprintf(fid,'\n'); fprintf('Table 13. Single-Period Default Probabilities in Problem 5\n'); fprintf(fid,'Table 13. Single-Period Default Probabilities in Problem 5\n'); fprintf('Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); fprintf(fid,'Rating Period 1 Period 2 Period 3 Period 4 Period 5\n'); for i=1:1:length(Param_Mult_Prob) fprintf('%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_3(i),... Constr_period2_Problem_5(i)-Constr_period1_Problem_5(i),... Constr_period3_Problem_5(i)-Constr_period2_Problem_5(i),... Constr_period4_Problem_5(i)-Constr_period3_Problem_5(i),... Constr_period5_Problem_5(i)-Constr_period4_Problem_5(i)); fprintf(fid,'%5s%11f%10f%10f%10f%10f\n',ratings{i},Constr_period1_Problem_3(i),... Constr_period2_Problem_5(i)-Constr_period1_Problem_5(i),... Constr_period3_Problem_5(i)-Constr_period2_Problem_5(i),... Constr_period4_Problem_5(i)-Constr_period3_Problem_5(i),... Constr_period5_Problem_5(i)-Constr_period4_Problem_5(i)); end fprintf('\n'); fprintf(fid,'\n'); % display Attachment Points for Example 1, Case 1 figure bar(Points_Problem_1,'group'); set(gca,'XTick',1:1:length(attach_points_names_graph)); hAxes = gca; set(hAxes, 'XTickLabel', attach_points_names_graph); grid on; legend(ratings, 'Location', 'NorthWest'); %xlabel('Names of Attachment Points'); ylabel('Values of Attachment Points'); title('Attachment Points for the Optimal Solution of Problem 1 '); % display Attachment Points for Example 1, Case 2 figure bar(Points_Problem_2,'group'); set(gca,'XTick',1:1:length(attach_points_names_graph)); hAxes = gca; set(hAxes, 'XTickLabel', attach_points_names_graph); grid on; legend(ratings, 'Location', 'EastOutside'); %xlabel('Names of Attachment Points'); ylabel('Values of Attachment Points'); title('Attachment Points for the Optimal Solution of Problem 2 '); % display Attachment Points for Example 2 figure bar(Points_Problem_3,'group'); set(gca,'XTick',1:1:length(attach_points_names_graph)); hAxes = gca; set(hAxes, 'XTickLabel', attach_points_names_graph); grid on; legend(ratings, 'Location', 'NorthWest'); %xlabel('Names of Attachment Points'); ylabel('Values of Attachment Points'); title('Attachment Points for the Optimal Solution of Problem 3 '); % display Attachment Points for Example 3, Case 1 figure bar(Points_Problem_4,'group'); set(gca,'XTick',1:1:length(attach_points_names_graph)); hAxes = gca; set(hAxes, 'XTickLabel', attach_points_names_graph); grid on; legend(ratings, 'Location', 'NorthWest'); %xlabel('Names of Attachment Points'); ylabel('Values of Attachment Points'); title('Attachment Points for the Optimal Solution of Problem 4 '); % display Attachment Points for Example 3, Case 2 figure bar(Points_Problem_5,'group'); set(gca,'XTick',1:1:length(attach_points_names_graph)); hAxes = gca; set(hAxes, 'XTickLabel', attach_points_names_graph); grid on; legend(ratings, 'Location', 'EastOutside'); %xlabel('Names of Attachment Points'); ylabel('Values of Attachment Points'); title('Attachment Points for the Optimal Solution of Problem 5 '); % display Default Probabilities of CDO Tranche vs. Ratings Y = [Multiple_Probabilities_Problem_1' Multiple_Probabilities_Problem_2'... Multiple_Probabilities_Problem_3' Multiple_Probabilities_Problem_4' Multiple_Probabilities_Problem_5']; figure bar(Y,'group'); set(gca,'XTick',1:1:length(ratings)); hAxes = gca; set(hAxes, 'XTickLabel', ratings); grid on; legend(problems_names, 'Location', 'EastOutside'); xlabel('Ratings'); ylabel('Default Probabilities of CDO Tranche'); title('Default Probabilities of CDO Tranche vs. Ratings '); clear Y; % display optimal linear objective values obtained in Problem 1, Problem 2, % and optimal partial moment functions objective values obtained in % Problem 3, Problem 4, and Problem 5 Y = [Sum_Attach_Points_Problem_1' Sum_Attach_Points_Problem_2'... Obj_Problem_3' Obj_Problem_4' Obj_Problem_5']; figure plot(Y); set(gca,'XTick',1:1:length(ratings)); hAxes = gca; set(hAxes, 'XTickLabel', ratings); grid on; legend(objectives_names, 'Location', 'EastOutside'); %xlabel('Names of Attachment Points'); ylabel('Credit Ratings'); title('Optimal Objective Values '); title('Default Probabilities of CDO Tranche vs. Ratings '); clear Y; % display dependence of single-period default probabilities for a tranche at % period t = 1,…, 5, vs. ratings for Problem 1 Y = [Constr_period1_Problem_1' Constr_period2_Problem_1'-Constr_period1_Problem_1'... Constr_period3_Problem_1'-Constr_period2_Problem_1'... Constr_period4_Problem_1'-Constr_period3_Problem_1'... Constr_period5_Problem_1'-Constr_period4_Problem_1']; figure bar(Y,'group'); set(gca,'XTick',1:1:length(ratings)); hAxes = gca; set(hAxes, 'XTickLabel', ratings); grid on; legend(period_names, 'Location', 'EastOutside'); xlabel('Ratings'); ylabel('Single-Period Default Probabilities'); title('Single-Period Default Probabilities vs. Ratings for Problem 1 '); clear Y; % display dependence of single-period default probabilities for a tranche at % period t = 1,…, 5, vs. ratings for Problem 2 Y = [Constr_period1_Problem_2' Constr_period2_Problem_2'-Constr_period1_Problem_2'... Constr_period3_Problem_2'-Constr_period2_Problem_2'... Constr_period4_Problem_2'-Constr_period3_Problem_2'... Constr_period5_Problem_2'-Constr_period4_Problem_2']; figure bar(Y,'group'); set(gca,'XTick',1:1:length(ratings)); hAxes = gca; set(hAxes, 'XTickLabel', ratings); grid on; legend(period_names, 'Location', 'EastOutside'); xlabel('Ratings'); ylabel('Single-Period Default Probabilities'); title('Single-Period Default Probabilities vs. ratings for Problem 2 '); clear Y; % display dependence of single-period default probabilities for a tranche at % period t = 1,…, 5, vs. ratings for Problem 3 Y = [Constr_period1_Problem_3' Constr_period2_Problem_3'-Constr_period1_Problem_3'... Constr_period3_Problem_3'-Constr_period2_Problem_3'... Constr_period4_Problem_3'-Constr_period3_Problem_3'... Constr_period5_Problem_3'-Constr_period4_Problem_3']; figure bar(Y,'group'); set(gca,'XTick',1:1:length(ratings)); hAxes = gca; set(hAxes, 'XTickLabel', ratings); grid on; legend(period_names, 'Location', 'EastOutside'); xlabel('Ratings'); ylabel('Single-Period Default Probabilities'); title('Single-Period Default Probabilities vs. ratings for Problem 3 '); clear Y; % display dependence of single-period default probabilities for a tranche at % period t = 1,…, 5, vs. ratings for Problem 4 Y = [Constr_period1_Problem_4' Constr_period2_Problem_4'-Constr_period1_Problem_4'... Constr_period3_Problem_4'-Constr_period2_Problem_4'... Constr_period4_Problem_4'-Constr_period3_Problem_4'... Constr_period5_Problem_4'-Constr_period4_Problem_4']; figure bar(Y,'group'); set(gca,'XTick',1:1:length(ratings)); hAxes = gca; set(hAxes, 'XTickLabel', ratings); grid on; legend(period_names, 'Location', 'EastOutside'); xlabel('Ratings'); ylabel('Single-Period Default Probabilities'); title('Single-Period Default Probabilities vs. ratings for Problem 4 '); clear Y; % display dependence of single-period default probabilities for a tranche at % period t = 1,…, 5, vs. ratings for Problem 5 Y = [Constr_period1_Problem_5' Constr_period2_Problem_5'-Constr_period1_Problem_5'... Constr_period3_Problem_5'-Constr_period2_Problem_5'... Constr_period4_Problem_5'-Constr_period3_Problem_5'... Constr_period5_Problem_5'-Constr_period4_Problem_5']; figure bar(Y,'group'); set(gca,'XTick',1:1:length(ratings)); hAxes = gca; set(hAxes, 'XTickLabel', ratings); grid on; legend(period_names, 'Location', 'EastOutside'); xlabel('Ratings'); ylabel('Single-Period Default Probabilities'); title('Single-Period Default Probabilities vs. ratings for Problem 5 '); clear Y; %=======================================================================| %American Optimal Decisions, Inc. Copyright | %Copyright ©American Optimal Decisions, Inc. 2007-2016. | %American Optimal Decisions (AOD) retains copyrights to this material. | % | %Permission to reproduce this document and to prepare derivative works | %from this document for internal use is granted, provided the copyright | %and “No Warranty” statements are included with all reproductions | %and derivative works. | % | %For information regarding external or commercial use of copyrighted | %materials owned by AOD, contact AOD at support@aorda.com. | %=======================================================================|