Portfolio Optimization MIQCP with SOC Constraint
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
arushi
le 3 Sep 2024
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 :
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 it helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!