I'm working on a formulation related to the Concrete Delivery Problem. I implement the formulation in CPLEX but face some problems with the construct ion of subset of the sets. For example, I need to construct a set of all subsets of artificial nodes of the graph. What I do is the following:
int st=...;
{int} StartingLocation = asSet(1..st);
int ft=...;
{int} FinishingLocation = asSet(1..ft);
int m2=1; // amount of customer type 2
int m4=1; // amount of customer type 4
{int} Customer2_NOTdefinedCustomers_NONSingleSource = asSet(1..m2);
{int} Customer4_DefinedCustomers_NONsingleSource = asSet(m2..m4+m2);
// Number of actual Customer nodes
{int} Customers = Customer2_NOTdefinedCustomers_NONSingleSource union Customer4_DefinedCustomers_NONsingleSource ;
float Deadline[Customers]= ...; // deadline
float demand[Customers]= ...;
int TimeLag[Customers] = ...;
float DefaultLoadSize = ...;
float LoadPerTrip = ... ;
int definedORnot [Customers] = ...;
int NofArtificialCustomers = 0;
int maxNumber_ofDeliveries[x in Customers];
execute {
for( var l in Customers){
if (definedORnot == 1)
maxNumber_ofDeliveries[l] = Opl.ftoi(Opl.ceil(DefaultLoadSize/demand[l]));
else maxNumber_ofDeliveries[l] = Opl.ftoi(Opl.ceil(demand[l]/LoadPerTrip));
// calculating the number of artificial customer nodes
NofArtificialCustomers = NofArtificialCustomers + maxNumber_ofDeliveries[l];
}
}
int NoCustomers = card(Customers); // the number of Actual nodes for customers
{int} SetofArtCustomerNodes[i in 1..NoCustomers] = asSet(1..maxNumber_ofDeliveries[i]);
// CREATING THE ARTIFICIAL CUSTOMER NODES
tuple artificialnodes {int i ; int j;}
// B: the set of artificial customer nodes
{artificialnodes} Setof_ArtificialCustomers = {<i,j> | i in Customers, j in SetofArtCustomerNodes[i in Customers]};
int d = ...;
{int} Depots = asSet(m4+m2..d+m4+m2);
{int} SetofArtDepotNodes = asSet(1..NofArtificialCustomers);
// CREATING THE ARTIFICIAL DEPOT NODES
{artificialnodes} Setof_ArtificialDepots = {<i,j> | i in Depots, j in SetofArtDepotNodes};
int NoV = ...; // amount of vehicles
{int} Vehicles = asSet(1..NoV); // set of vehicles
// CREATING THE ARTIFICIAL STARTING LOCATION NODES
{artificialnodes} Setof_StartingLocations = {<i,j> | i in Vehicles, j in Customers: j==1};
// CREATING THE ARTIFICIAL FINISHING LOCATION NODES
{artificialnodes} Setof_FinishingLocations = {<i,j> | i in Vehicles, j in Customers: j==1};
{artificialnodes} N0 = Setof_StartingLocations union Setof_FinishingLocations union Setof_ArtificialDepots union Setof_ArtificialCustomers;
All subsets of a set in example https://github.com/AlexFleischerParis/howtowithopl/blob/master/powerset.mod
With your artificial nodes you can write
which gives