Negative variables in the linear relaxation

24 views
Skip to first unread message

fernandaf...@gmail.com

unread,
Aug 25, 2016, 9:02:05 AM8/25/16
to AMPL Modeling Language
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;
        }
    }
}

fernandaf...@gmail.com

unread,
Aug 25, 2016, 9:03:22 AM8/25/16
to AMPL Modeling Language
The options I'm using are:

option eexit -100000;
option display_precision 0;
option auxfiles rca;
option solver cplexamp;
option omit_zero_rows 1;
option cplex_options 'return_mipgap 3 timelimit=60 threads 1 integrality 3e-20 mipdisplay=4';
suffix absmipgap OUT;
suffix relmipgap OUT;
option presolve 0;

Victor Zverovich

unread,
Aug 26, 2016, 12:46:56 PM8/26/16
to am...@googlegroups.com
Make sure that the variables are included in the named problem you are trying to solve. Otherwise they will be fixed to their current values which may result in infeasible solution.

HTH,
Victor

            let {i in J} r[i].relax := 0;           
            
            solve Manne;
        }
    }
}

--
You received this message because you are subscribed to the Google Groups "AMPL Modeling Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ampl+uns...@googlegroups.com.
To post to this group, send email to am...@googlegroups.com.
Visit this group at https://groups.google.com/group/ampl.
For more options, visit https://groups.google.com/d/optout.

fernandaf...@gmail.com

unread,
Aug 26, 2016, 1:20:17 PM8/26/16
to AMPL Modeling Language
Thank you for the answer Victor, I just found my mistake. I can't use named problems for my specific problem because I don't want that the constraints that have common variables with the other problem be dropped. So, I have to use two files and use "commands" for call another problem. This way, it works perfectly.

Thanks for your answer!
Best regards,
Fernanda
Reply all
Reply to author
Forward
Message has been deleted
0 new messages