Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Constraints are not satisfied

    Posted 03/25/13 04:13 PM

    Originally posted by: SystemAdmin


    Hello,

    I've to solve a mathematical model for my master thesis.
    I'm not used to work with CPLEX, so I already had some problems with it.
    So far, my model is solvable. But I guess I might have made some mistakes in the formulation, since not all constraints are satisfied.

    Does someone see some formulation-mistakes?

    int i=...;
    int c=...;
    int d=...;
    int p=...;
    int f=...;

    range shift = 1..i; // possible shifts
    range periode=1..p; // periods in a week
    range vlucht=1..f;

    int w=...; // maximal number of weeks
    range cycle=1..c; //cycles
    range dag=1..d;
    range week=1..w;
    float vraagvlucht=...; //demand in workhours for flight f
    int teamgroottecycle=...; //teamsize in cycle c

    float kostshiftdag=...; //total cost(per employee) for shift i on day d
    float duurshift=...; //duration of shift i

    float buffer=...;
    int aanwezig1shiftperiode=...;// 1 if periode p contains shift i

    int ochtendshift = ...;//morningshift
    int dagshift = ...; //dayshift
    int avondshift=...;//eveningshift
    int nachtshift=...;//nightshift
    int beginvlucht=...;
    int eindevlucht=...;

    int ovluchtperiode=...;

    float fractieshift=...;

    int g = ...;
    range doel = 1..g;
    float gewichtdoel=...;
    int bep=...;
    range beperking = 1..bep;
    int rh3=...;

    dvar boolean xshiftdagweekcycle;
    dvar float yvluchtperiode;
    dvar boolean zshiftcycle;
    dvar int teamaantalcycle;//aantal team als beslissingsvariabele meegegeven
    dvar int objbeperking;

    minimize
    sum(i in shift, d in dag, w in week, c in cycle) kost[i][d]*fractie[i] * teamgrootte[c]* x[i][d][w][c] + gewicht[1]*sum(bep in beperking: bep <=15)objbep+gewicht[2]*sum(bep in beperking: 16<= bep <= 26)objbep +gewicht[3]*sum(bep in beperking: 27<= bep <= 40)objbep;

    subject to {

    forall (c in cycle)
    teamaantal[c] <= 8;
    (sum(i in shift, d in dag, w in week, c in cycle) (duur[i] * fractie[i] * x[i][d][w][c]*teamgrootte[c])) >= (sum(f in vlucht) vraag[f]);
    forall (p in periode)
    (sum ( i in shift, d in dag, w in week, c in cycle) fractie[i]* aanwezig1[i][p] * teamgrootte[c] * x[i][d][w][c]) >= (sum (f in vlucht: (f * (o[f][p])>0)) (y[f][p]));// CONSTRAINT 7
    forall(d in dag, c in cycle)
    sum(i in shift, w in week) x[i][d][w][c]<=teamaantal[c];
    forall (f in vlucht)
    (sum (p in periode: (begin[f]<= p <= einde[f])) y[f][p]) == (vraag[f]*2); //constraint 8
    forall ( d in dag, w in week, c in cycle)
    sum (i in shift) x[i][d][w][c] <=1;
    forall(d in dag:6<=d<=7, c in cycle)
    (sum(w in week, i in shift) x[i][d][w][c]) <= (0.5 * teamaantal[c]);//constraint2
    forall(c in cycle)
    (sum(i in shift, d in dag, w in week)x[i][d][w][c]*duur[i]*fractie[i])>=(36*teamaantal[c]);//constraint 3
    forall(c in cycle)
    (sum(i in shift, d in dag, w in week)x[i][d][w][c]*duur[i]*fractie[i])<= (38*teamaantal[c]); //constraint 3
    forall(i in shift, d in dag, w in week, c in cycle)
    x[i][d][w][c]<= z[i][c];//constraint 4
    forall(c in cycle)
    sum( i in shift: i<=ochtendshift)z[i][c]<=1; //constraint 5
    forall(c in cycle)
    sum( i in shift: ochtendshift < i <= dagshift)z[i][c]<=1; //constraint 5
    forall(c in cycle)
    sum( i in shift: dagshift < i <= avondshift)z[i][c]<=1; //constraint 5
    forall(c in cycle)
    sum( i in shift: avondshift< i<= nachtshift)z[i][c]<=1; //constraint 5
    forall(p in periode)
    (sum(i in shift, d in dag, w in week, c in cycle)(aanwezig1[i][p]*x[i][d][w][c]))>=1; // constraint 6
    forall (i in shift:i<= nachtshift, d in dag: d<=6, w in week, c in cycle)
    (x[i]d+1[w][c])<= 1-(sum(i in shift: avondshift < i <= nachtshift)x[i][d][w][c]); // nachtshift mag niet gevolgd worden door M,D,A
    forall (i in shift:i<= avondshift, w in week: w<= w-1, c in cycle)
    (x[i][1]w+1[c])<= 1-(sum(i in shift: avondshift < i <= nachtshift)x[i][7][w][c]);
    forall (i in shift: i<= dagshift, d in dag: d<=6, w in week, c in cycle)
    (x[i]d+1[w][c])<= 1-(sum(i in shift: dagshift < i <=avondshift) x[i][d][w][c]);
    forall (i in shift: i<= dagshift, w in week: w<=w-1, c in cycle)
    (x[i][1]w+1[c])<= 1- (sum(i in shift: dagshift < i <=avondshift)x[i][7][w][c]);
    forall (f in vlucht, p in periode)
    y[f][p]>=0;

    forall (bep in beperking)
    objbep>=0 ;

    }

    tuple someTuple{
    int shift;
    int dag;
    int week;
    int cycle;
    int value;
    }
    {someTuple} someSet = {<i,d,w,c, x[i][d][w][c]> | i in shift, d in dag, w in week, c in cycle};
    I really hope that someone can help me, as my deadline is soon!

    Regards,

    Aurelie
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Constraints are not satisfied

    Posted 03/26/13 04:04 AM
    Hi,

    can you attach the .mod and the .dat ?

    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Constraints are not satisfied

    Posted 03/26/13 05:00 AM

    Originally posted by: SystemAdmin


    Really hope you can help me!

    I left out some of the constraints (concerning the variable obj, but they have the value 0)

    Regards,

    Aurelie
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Constraints are not satisfied

    Posted 03/26/13 05:00 AM

    Originally posted by: SystemAdmin


    Here's my mod.-file
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Constraints are not satisfied

    Posted 03/26/13 07:11 AM

    Originally posted by: SystemAdmin


    Excel-file
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: Constraints are not satisfied

    Posted 03/26/13 08:50 AM
    Hi,

    which constraint is violated according to you?

    If I do asserts, I see that all asserts are ok.

    
    
    
    assert forall (c in cycle) teamaantal[c] <= 8;   
    
    assert forall (p in periode) (sum ( i in shift, d in dag, w in week, c in cycle) fractie[i]* aanwezig1[i][p] * teamgrootte[c] * x[i][d][w][c]) >= (sum (f in vlucht: (f * (o[f][p])>0)) (y[f][p]));
    // CONSTRAINT 7 
    
    assert forall(d in dag, c in cycle) sum(i in shift, w in week) x[i][d][w][c]<=teamaantal[c]; 
    
    assert forall (f in vlucht) abs( (sum (p in periode: (begin[f]<= p <= einde[f])) y[f][p]) - (vraag[f]*2))<=0.001; 
    //constraint 8 
    
    assert forall ( d in dag, w in week, c in cycle) sum (i in shift) x[i][d][w][c] <=1; 
    
    assert forall(d in dag:6<=d<=7, c in cycle) (sum(w in week, i in shift) x[i][d][w][c]) <= (0.5 * teamaantal[c]);
    //constraint2 
    
    assert forall(c in cycle) (sum(i in shift, d in dag, w in week)x[i][d][w][c]*duur[i]*fractie[i])>=(36*teamaantal[c]);
    //constraint 3 
    
    assert forall(c in cycle) (sum(i in shift, d in dag, w in week)x[i][d][w][c]*duur[i]*fractie[i])<= (38*teamaantal[c]); 
    //constraint 3 
    
    assert forall(i in shift, d in dag, w in week, c in cycle) x[i][d][w][c]<= z[i][c];
    //constraint 4 
    
    assert forall(c in cycle) sum( i in shift: i<=ochtendshift)z[i][c]<=1; 
    //constraint 5 
    
    assert forall(c in cycle) sum( i in shift: ochtendshift < i <= dagshift)z[i][c]<=1; 
    //constraint 5 
    
    assert forall(c in cycle) sum( i in shift: dagshift < i <= avondshift)z[i][c]<=1; 
    //constraint 5 
    
    assert forall(c in cycle) sum( i in shift: avondshift< i<= nachtshift)z[i][c]<=1; 
    //constraint 5 
    
    assert forall(p in periode) (sum(i in shift, d in dag, w in week, c in cycle)(aanwezig1[i][p]*x[i][d][w][c]))>=1; 
    // constraint 6 
    
    assert forall (i in shift:i<= nachtshift, d in dag: d<=6, w in week, c in cycle) (x[i][d+1][w][c])<= 1-(sum(i in shift: avondshift < i <= nachtshift)x[i][d][w][c]); 
    // nachtshift mag niet gevolgd worden door M,D,A 
    
    assert forall (i in shift:i<= avondshift, w in week: w<= w-1, c in cycle) (x[i][1][w+1][c])<= 1-(sum(i in shift: avondshift < i <= nachtshift)x[i][7][w][c]); 
    
    assert forall (i in shift: i<= dagshift, d in dag: d<=6, w in week, c in cycle) (x[i][d+1][w][c])<= 1-(sum(i in shift: dagshift < i <=avondshift) x[i][d][w][c]); 
    
    assert forall (i in shift: i<= dagshift, w in week: w<=w-1, c in cycle) (x[i][1][w+1][c])<= 1- (sum(i in shift: dagshift < i <=avondshift)x[i][7][w][c]); 
    
    assert forall (f in vlucht, p in periode) y[f][p]>=0;       
    
    assert forall (bep in beperking) obj[bep]>=0 ;
    


    regards
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: Constraints are not satisfied

    Posted 03/26/13 10:22 AM

    Originally posted by: SystemAdmin


    Constraint 7 and 8.

    I always get zero-values for y(f)(p)...

    Thanks!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: Constraints are not satisfied

    Posted 03/26/13 11:42 AM

    Originally posted by: SystemAdmin


    Many thanks for your help!
    I just found what I did wrong...
    I switched the columns and rows in my Excel-sheet,
    and now everything works!
    #DecisionOptimization
    #OPLusingCPLEXOptimizer