0

I am new to Cplex IBM ILOG CPLEX Optimization Studio and I am currently programming a Cumulative VRP model (ref: DOI: 10.5772/5812) like the following:

enter image description here

This is my code:

{string} CIUDADES = ...;
 int READY_TIME[CIUDADES] = ...;
 int DUE_TIME[CIUDADES] = ...;
 int SERVICETIME[CIUDADES] = ...;
 int DISTANCIA[CIUDADES, CIUDADES] = ...;
 int CLIENTES=11;
 int Penalizacion = 10;
 int DEMANDAS[CIUDADES] = ...;
 int NROCIUDADES[CIUDADES] = ...;
int PESO_VACIO = 6350;
int PESO_LLENO = 3650;
int VELOCIDAD_MINIMA = 20;
int VELOCIDAD_MAXIMA = 90;
int UMBRAL_RETRASO = 300;
int aux = 0;
int CARGAT = sum(ci in CIUDADES) DEMANDAS[ci];
int vehiculos =1;

//DV
dvar int X[CIUDADES,CIUDADES] in 0..1;
dvar int Y[CIUDADES, CIUDADES] in 0..(CARGAT+PESO_VACIO);

minimize
    sum(ci in CIUDADES) 
        sum(cj in CIUDADES)
          DISTANCIA[ci,cj]*Y[ci,cj];

subject to {
    restriccion1: 
            sum(ci in CIUDADES) 
                X["Kingston_upon_Hull",ci]==1;  

    restriccion2: 
            sum(ci in CIUDADES) 
                X[ci,"Kingston_upon_Hull"]==1;

    forall(cj in CIUDADES) {
    restriccion3: 
            sum(ci in CIUDADES: ci!=cj) 
                (X[ci,cj])==1;
}

    forall(ci in CIUDADES) {
    restriccion4: 
            sum(cj in CIUDADES: ci!=cj) 
                (X[ci,cj])==1;
}   

forall(ci in CIUDADES) {
    restriccion5: 
            ((sum(cj in CIUDADES: ci!=cj) 
                (Y[cj,ci]))
                -
            (sum(cj in CIUDADES: ci!=cj) 
                (Y[ci,cj])))
            == DEMANDAS[ci];

}   

forall(ci in CIUDADES) {
    restriccion6:
     Y[ci,"Kingston_upon_Hull"]== PESO_VACIO*X[ci,"Kingston_upon_Hull"];
}   

forall(ci in CIUDADES, cj in CIUDADES) {
    restriccion7:
     Y[ci,cj] <= ((77777777)-DEMANDAS[ci])*X[ci,cj];

}

forall(ci in CIUDADES, cj in CIUDADES) {
    restriccion8:
     Y[ci,cj] >= ((PESO_VACIO)-DEMANDAS[cj])*X[ci,cj];
}

forall(ci in CIUDADES) {
    restriccion9:
     Y["Kingston_upon_Hull",ci]== (PESO_VACIO+CARGAT)*X["Kingston_upon_Hull",ci];
}
}

But compiling using CPLEX I get the following result:

/ solution (feasible relaxed sum of infeasibilities) with objective 5671
// Quality Incumbent solution:
// MILP objective                                 6.6464998100e+09
// MILP solution norm |x| (Total, Max)            1.02485e+05  1.20210e+04
// MILP solution error (Ax=b) (Total, Max)        0.00000e+00  0.00000e+00
// MILP x bound error (Total, Max)                0.00000e+00  0.00000e+00
// MILP x integrality error (Total, Max)          0.00000e+00  0.00000e+00
// MILP slack bound error (Total, Max)            5.67100e+03  5.67100e+03
Y = [[0
             0 0 0 0 0 0 0 0 0 12021]
             [0 0 10186 0 0 0 0 0 0 0 0]
             [0 0 0 9372 0 0 0 0 0 0 0]
             [0 0 0 0 0 0 0 0 8752 0 0]
             [0 10907 0 0 0 0 0 0 0 0 0]
             [0 0 0 0 11218 0 0 0 0 0 0]
             [6350 0 0 0 0 0 0 0 0 0 0]
             [0 0 0 0 0 0 6863 0 0 0 0]
             [0 0 0 0 0 0 0 0 0 7989 0]
             [0 0 0 0 0 0 0 7431 0 0 0]
             [0 0 0 0 0 11385 0 0 0 0 0]];
X = [[0 0 0 0 0 0 0 0 0 0 1]
             [0 0 1 0 0 0 0 0 0 0 0]
             [0 0 0 1 0 0 0 0 0 0 0]
             [0 0 0 0 0 0 0 0 1 0 0]
             [0 1 0 0 0 0 0 0 0 0 0]
             [0 0 0 0 1 0 0 0 0 0 0]
             [1 0 0 0 0 0 0 0 0 0 0]
             [0 0 0 0 0 0 1 0 0 0 0]
             [0 0 0 0 0 0 0 0 0 1 0]
             [0 0 0 0 0 0 0 1 0 0 0]
             [0 0 0 0 0 1 0 0 0 0 0]];

and compiling through cmd in windows with oplrun -p folder and I get the following:

Version identifier: 12.10.0.0 | 2019-11-26 | 843d4de2ae    
Infeasibility row 'restriccion1':  0  = 1.
Presolve time = 0.02 sec. (0.76 ticks)  

My program makes an assignment to variables Xij and Yij, but does not optimize the target function. Where would I have the error? your help would be appreciated.

Thanks!

GMs
  • 47
  • 5

1 Answers1

0

In the IDE you get a relaxation because your model is not feasible and with command line you only get a tiny message.

If you want to see the relaxation with the command line then do oplrun -relax

Very simple example.

Let us go on with

https://www.linkedin.com/pulse/what-optimization-how-can-help-you-do-more-less-zoo-buses-fleischer/

and address a new concern : infeasibility!

Let us suppose we have a new challenge : use less than 7 buses overall.

Then we write

int nbKids=300;
float costBus40=500;
float costBus30=400;

dvar int+ nbBus40;
dvar int+ nbBus30;

minimize
 costBus40*nbBus40  +nbBus30*costBus30;

subject to
{
 ctAllKidsNeedToGo:
     40*nbBus40+nbBus30*30>=nbKids;

 ctMaxTotalBuses:
     nbBus30+nbBus40<=7;
}

ctAllKidsNeedToGo and ctMaxTotalBuses are labels for the constraints.

But then the problem gets infeasible since even with 7 buses with 40 seats you can take only 280=7*40 kids which is less than 300 kids.

When we launch this model, we get a conflict

which means we have a conflict within those 2 constraints and a relaxation, which means that if we relax 7 buses to 8 buses then we have a feasible solution.

This is not very useful for this tiny example but for real models this can be key.

For more see Relaxing infeasible models in the IDE Tutorials in CPLEX documentation

NB:

You can also get that info through flow control in scripting:

int nbKids=300;
float costBus40=500;
float costBus30=400;

dvar int+ nbBus40;
dvar int+ nbBus30;

minimize
 costBus40*nbBus40  +nbBus30*costBus30;

subject to
{
 ctAllKidsNeedToGo:
     40*nbBus40+nbBus30*30>=nbKids;

 ctMaxTotalBuses:
     nbBus30+nbBus40<=7;
}

main
{
thisOplModel.generate();
if (!cplex.solve())
{
writeln(thisOplModel.printRelaxation());
writeln(thisOplModel.printConflict());
}
}

gives

ctMaxTotalBuses
    relax [-Infinity,7] to [-Infinity,8] value is -Infinity

ctAllKidsNeedToGo
  is in conflict
ctMaxTotalBuses
  is in conflict
halfer
  • 19,824
  • 17
  • 99
  • 186
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15