I'm intending to conduct an optimization but I get an error which I cannot find the cause to. The compiler complains about servicetime, startlimit and endlimit not being invalid. In particular the compiler complains in the constraint TimeConstraint that there is no value for servicetime['ORIGINS'].
The constraint in question is:
subject to TimeConstraint {k in H}: sum{i in UNI, j in UNI} servicetime[i]*x[i,j,k] <= 1440;
where:
set ORIGINS;
set DESTINATIONS;
set UNI;
param servicetime{UNI} integer > 0;
var x{UNI,UNI, H} binary;
param startlimit{UNI};
param endlimit{UNI};
the .dat file is:
set ORIGINS := 1 2 3 4 5 6 7;
set DESTINATIONS := 8 9 10 11 12 13 14;
set UNI = ORIGINS union DESTINATIONS;
param: startlimit endlimit servicetime:=
1 0 1440 360
2 0 1440 360
3 0 1440 360
4 0 1440 360
5 0 1440 360
6 0 1440 120
7 0 1440 120
8 0 1440 360
9 0 1440 360
10 0 1440 360
11 0 1440 360
12 0 1440 360
13 0 1440 120
14 0 1440 120;
I cannot see how this does not work. To me this looks accurate. Hope someone can shed some light into this! Regards,
AMPL data format doesn't permit expressions, so ORIGINS
, union
and DESTINATIONS
are interpreted literally as strings rather than a set expression ORIGINS union DESTINATIONS
in the data statement
set UNI = ORIGINS union DESTINATIONS;
You can fix this by initializing the set in the declaration in the model file:
set ORIGINS;
set DESTINATIONS;
set UNI = ORIGINS union DESTINATIONS;
param servicetime{UNI} integer > 0;
...