Mixed-Integer Linear Programming problem

15 visualizaciones (últimos 30 días)
NICOLO' DUCCINI
NICOLO' DUCCINI el 9 de Nov. de 2020
Editada: NICOLO' DUCCINI el 13 de Nov. de 2020
Hello,
i have to solve the following MILP problem on MATLAB:
I have tried to solve it in this way, but there is something wrong because the are not solutions according to the solver but there should be 2 vectors with 4 solutions each. Can anyone help me?
q = 4
n = length(tickers)
cvx_begin
cvx_solver sdpt3
variables x(n) y(n) binary;
maximize (sum(sum(rho*x)))
sum(y) == q;
sum(x) == 1;
sum(x) <= y';
cvx_end
x, y

Respuestas (1)

Pranav Verma
Pranav Verma el 12 de Nov. de 2020
Hi Nicolo'
You can use the MILP solver in MATLAB to solve the problem you have mentioned. The MILP solver solves:
So make sure that you convert your problem from maximize to minimize and accordingly change the signs in the constraints and convert them to A.x <= b.
You can make use of optimproblem to create the optimization problem.
Thanks
  1 comentario
NICOLO' DUCCINI
NICOLO' DUCCINI el 12 de Nov. de 2020
Editada: NICOLO' DUCCINI el 13 de Nov. de 2020
Thank You for your answer!
I tried to modify the code in this way:
prob = optimproblem('ObjectiveSense','max')
x = optimvar('x',n,'Type','integer','LowerBound',0,'UpperBound',1);
y = optimvar('y',n,'Type','integer','LowerBound',0,'UpperBound',1);
prob.Objective = optimexpr(rho*x);
cons1 = sum(y) == q;
cons2 = sum(x) == 1;
cons3 = x <= y'*ones(30,1);
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
prob.Constraints.cons3 = cons3;
sol = solve(prob)
sol.x
sol.y
But I did't obtain an appropriate result, maybe because there are some constraint problem, do you have some suggestion ?

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by