'Cplex model, no Dvar values, in vehicle routing
int NStations1= ...;
int Nstations2=...;
range Stations1= 1..NStations1;
range Stations2= 1..Nstations2;
int demand1[Stations1]=...;
int demand2[Stations2]=...;
int distance[Stations1][Stations2]=...;
int AvailTime=...;
int Capacity=...;
dvar float+ x[Stations1][Stations2];
dvar float+ f[Stations1][Stations2];
minimize sum(i in Stations1) sum(j in Stations2) x[i][j]*distance[i][j];
subject to
{
forall (i in Stations1) sum(j in Stations2) (f[j][i]-f[i][j]) <= demand1[i];
forall (i in Stations1) sum(j in Stations2) x[i][j] == 1 ;
forall (i in Stations1) sum(j in Stations2) x[j][i] == 1;
forall (i in Stations1, j in Stations2)
{0<= f[i][j];
f[i][j] <= x[i][j]*Capacity;}
Data: NStations1=4; Nstations2=4;
demand1=[5 , 3, 4, 7];
demand2=[5 , 3, 4, 7];
distance=[ [ 9 2 7 4 ]
[ 2 5 3 3 ]
[ 8 4 13 8 ]
[ 7 3 4 3 ]
];
AvailTime=3600;
Capacity= 30;
Question:
I don't get values for my dvar, f while I got values for this parameter before adding the last constraint, but I need a capacity constraint ? How to solve this
Solution 1:[1]
I get
x = [[0
0 0 1]
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]];
f = [[0 0 0 0]
[0 0 0 0]
[0 0 0 0]
[0 0 0 0]];
if I run your model in the IDE with CPLEX 22.1
and if I turn your objective into
minimize staticLex(sum(i in Stations1) sum(j in Stations2) x[i][j]*distance[i][j],-sum(i in Stations1,j in Stations2) f[i][j]);
then I get
x = [[0
0 0 1]
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]];
f = [[0 0 0 30]
[30 0 0 0]
[0 30 0 0]
[0 0 30 0]];
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
