필터 지우기
필터 지우기

Portfolio Optimization MIQCP with SOC Constraint

조회 수: 2 (최근 30일)
Sekar
Sekar 2023년 6월 4일
답변: Aman Banthia 2023년 8월 23일
I want to solve Portfolio Optimization problem using Benders Decomposition method, but the code is still error and I am confused to fix it because the model form is MIQCP with SOC Constraint. Does anyone can help?

답변 (1개)

Aman Banthia
Aman Banthia 2023년 8월 23일
Hello Sekar,
I understand that you are having errors while implementing the MALAB Code you have written.
Variable ‘z’ is not defined before using in line 47 of ‘PO_BD.m’. Assign it to the desired value and try to run the code again.
In my opinion the following code might also help you as well
clc;
tic
% Load data
Data = readtable("INPUT DATA - SEKAR.xlsx", 'ReadRowNames', true);
data = [Data.UNVR Data.ADMR Data.INKP Data.ARGO Data.SMAR Data.TFCO Data.TPIA];
[rData, cData] = size(data);
% Calculate returns
returns = diff(data) ./ data(1:end-1, :);
% Calculate mean returns
meanReturns = mean(returns);
% Calculate covariance matrix
covMatrix = cov(returns);
% Define parameters
a = 0.15 * ones(cData, 1);
b = 0.85 * ones(cData, 1);
l = zeros(cData, 1);
rho = 0.0001;
% Create optimization problems
masterProblem = optimproblem;
subProblem = cell(cData, 1);
% Define decision variables
x = optimvar('x', cData, 'LowerBound', l, 'UpperBound', b);
y = optimvar('y', cData, 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1);
t = optimvar('t', 'LowerBound', -inf, 'UpperBound', 0);
% Define master problem constraints
masterProblem.Constraints.cons1 = t <= 0;
masterProblem.Constraints.cons2 = a .* y <= x;
masterProblem.Constraints.cons3 = x <= b .* y;
% Solve subproblems and add optimality cuts to master problem
for i = 1:cData
subProblem{i} = optimproblem;
subProblem{i}.Objective = -t;
subProblem{i}.Constraints.cons1 = sum(x) <= 1;
subProblem{i}.Constraints.cons2 = -meanReturns * x <= -rho;
subProblem{i}.Constraints.cons3 = t + norm(chol(covMatrix) * x, 2) <= 0;
subProblem{i}.Constraints.cons4 = a(i) * y(i) <= x(i);
subProblem{i}.Constraints.cons5 = x(i) <= b(i) * y(i);
subObjective = subProblem{i}.Objective;
masterProblem.Constraints.(['cons2_' num2str(i)]) = [x(i); y(i)] >= subObjective;
end
% Solve master problem
[xSol, fval] = solve(masterProblem);
% Calculate portfolio returns
portfolioReturns = returns * xSol.x;
fprintf('Optimal portfolio:\n');
disp(xSol.x);
fprintf('Objective value: %f\n', fval);
toc
Hope the above solution helps you.
Thanks,
Aman Banthia

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by