If I want to solve a problem like P2:
P2 : Q(y) = {max u∈U min x bT x : Gx ≥ h - Ey - Mu, Lu<=g, x ∈ Sx}.
Where u are binary variables, x are continuous variables, including x1,x2,x3
Consider P2. which is identical to:
Q(y)= max u,x(z)
s.t. z<= min { bT x : Gx ≥ h - Ey – Mu, x ∈ Sx }% The right-hand sides are (LP)
Lu<=g
Let π be the vector of dual variables to the second-stage decision problem. Using KKT conditions, P2 is equivalent to the following:
max bT x (1)
s.t. Gx ≥ h - Ey - Mu (2)
GT π ≤ b
(3)
(Gx - h + Ey + Mu)iπi = 0, ∀i (4)
(b - GT π)jxj = 0, ∀j (5)
x ∈ Sx, π ≥ 0.
(6)
u ∈ U, Lu<=g (7)
1) If I try to solve P2 using Yalmip in this way:
f= bT x;
F=[constraints(1), constraints(2),……, constraints(7)];
[k,details]=kkt(F,f,u);
optimize([details.dual>=0,details.dualeq>=0,k,F],-f)
2) Or I want to using bi-level to solve the problem:
OO= bT x;
CO=[ constraints(7)];
OI= bT x;
CI=[constraints(1), constraints(2),……, constraints(6)];
solvebilevel(CO, -OO, CI, OI, [x1,x2,x3]); However, x1, x2, x3 have different dimensions, so I cannot put them together like [x1,x2,x3].
I know there are many mistakes in my approach .But what are the main mistakes, and how can I correct them?
where the inner is LP, and the outer is the 0-1 programming problem. And I think my model is not very difficult. It can be solved with kkt, bi-level or strong duality. What's the main problem with my code? How do I handle it?
Or my thoughts are wrong, and I should write Benders decomposition algorithm(or CC&G) to deal with such problems.
Yeah, and I made the following corrections:
OO=z;
CO=[];
%Attack cost constraint
CO=[CO,sum(sum(X_e))<=attack_budget,z<=sum(ls_n);];
%If the line is not connected, it cannot be attacked,namely X_e(C==L)=0
CO=[CO,X_e(C==L)==0];
ops = sdpsettings('verbose',2);
solvesdp([k,CO,boundingbox([CI,CO]),details.dual<=1e4],-OO)
But there are still problems. Both kkt and bi-level took a lot of time, and they didn't work out.
Found heuristic solution: objective -259.0000000
Explored 0 nodes (0 simplex iterations) in 0.07 secondsThread count was 4 (of 4 available processors)
Solution count 1: -259
Optimal solution found (tolerance 1.00e-04)Best objective -2.590000000000e+02, best bound -2.590000000000e+02, gap 0.0000%
ans =
struct with fields:
yalmiptime: 2.2871 solvertime: 0.1369 info: 'Successfully solved (GUROBI-GUROBI)' problem: 0