Good morning,
I have a file that contains two models, in which
one solution is used to solve another problem using named problems. In
one model I solve the linear relaxation and, based on the results
obtained, the other problem is solved with "option relax_integrality 0".
When I solve each instance separately, the linear relaxation works
fine, but in the loop the solver CPLEX can't find the right answers for
the linear relaxation, finding negative values for variables that
suppose to be positive, resulting in infeasible solutions. Can anyone
help me with this problem?
I've tried initialize the variables in the
beggining of the loop but it didn't work. I also tried reset data but
also didn't work.
Thank you.
Best regards,
Fernanda
minimize A: sum{j in J, h in T}(Ci[j]*I[j,h] + Ci[j]*Ineg[j,h]);
s.t. rest1{j in J, h in 1..tf}: I[j,h] = I[j,h-1] + q[j,h] - D[j,h] + Ineg[j,h] - Ineg[j,h-1];
s.t. rest2{h in 2..tf}: sum{j in J}w[j,h]*Sm[j] + sum{j in J}q[j,h]*p[j] <= K[h];
s.t. rest3{h in 2..tf,j in J}: q[j,h]*p[j] <= K[h]*w[j,h];
s.t. rest4{i in J,j in J:i<>j}: r[j] >= r[i] + setup[i,j]*w[i,1] + p[i]*q[i,1] - M*(1-y[i,j]);
s.t. rest5{i in J,j in J:i<>j}: y[i,j] + y[j,i]=1;
s.t. rest6{j in J}: r[j] + p[j]*q[j,1] <= K[1]*w[j,1];
s.t. rest7{j in J, t in T}: w[j,t]<=M*q[j,t];
problem Manne: r, I, Ineg, q, w, y, A, rest1, rest2, rest3, rest4, rest5, rest6, rest7;
option relax_integrality 0;
minimize B: sum{j in J, h in T} (Ci[j]*I[j,h] + Ci[j]*Ineg[j,h]);
s.t. rest11{j in J, h in 1..tf}: I[j,h] = I[j,h-1] + q[j,h] - D[j,h] + Ineg[j,h] - Ineg[j,h-1];
s.t. rest21: sum{i in J, j in J,s in S:i<>j}z[j,i,s]*setup[j,i] + sum{i in J}q[i,1]*p[i] <= K[1];
s.t. rest31{h in 2..tf}: sum{i in J}w[i,h]*Sm[i] + sum{i in J}q[i,h]*p[i] <= K[h];
s.t. rest41{h in 2..tf,j in J}: q[j,h]*p[j] <= K[h]*w[j,h];
s.t. rest51{j in J}: q[j,1]*p[j] <= K[1]*sum{s in S}x[j,s];
s.t. rest61{s in S}:sum{j in J}x[j,s] = 1;
s.t. rest71{i in J,j in J,s in 2..n:i<>j}: z[j,i,s]>= x[j,s-1] + x[i,s] - 1;
problem WarmStart: I, Ineg, q, w, x, z, B, rest11, rest21, rest31, rest41, rest51, rest61, rest71;
option relax_integrality 1;
for{val in 1..8}{
let n:= Cj[val];
for{class in 1..1}{
for{v in 1..3}{
for{j in J}{
for{t in T}{
let I[j,t]:= 0;
let Ineg[j,t]:= 0;
let q[j,t]:= 0;
let w[j,t]:= 0;
let D[j,t]:= 0;
}
let r[j]:= 0;
let Ci[j]:= 0;
let p[j]:= 0;
let Sm[j]:= 0;
for{i in J:i<>j}{
let y[i,j]:= 0;
let setup[i,j]:= 0;
}
for{s in S}{
let x[j,s]:= 0;
}
for{i in J:i<>j}{
for{s in S}{
let z[i,j,s]:= 0;
}
}
}
for{i in 1..n}{
read Ci[i] < ("./Dados/h"& class & n & v &".txt");
read p[i] < ("./Dados/p"& class & n & v &".txt");
for{j in 1..n}{
read setup[i,j] < ("./Dados/setup"& class & n & v &".txt");
}
for{h in 1..tf}{
read D[i,h] < ("./Dados/D"& class & n & v &".txt");
}
}
reset M;
let M:= sum{j in J} p[j]*D[j,1] + sum{j in J} max{i in J} (setup[i,j]);
let {j in J}Sm[j]:=(sum{i in J}setup[j,i])/max{k in J}k; #Setup medio
fix {i in J} I[i,0]:=0;
fix {i in J} q[i,0]:=0;
fix {i in J} Ineg[i,0]:=0;
solve WarmStart;
let {i in J, j in J, s in S:i<>j} z[i,j,s].relax := 1;
let {i in J, s in S} x[i,s].relax := 1;
solve Manne;
}
}
}