Originally posted by: kalleman
Mod
//Data
int NumberOfCustomers = ...; //i
int NumberOfTimePeriods = ...; //t //in days?
int NumberOfVehicleTypes = ...; //j
range Customers = 1..NumberOfCustomers; //Vdistance
range TimePeriods = 1..NumberOfTimePeriods; //VtimePeriods
range VehicleTypes = 1..NumberOfVehicleTypes; //VvehicleTypes
float Quantity [Customers] [TimePeriods] = ...; //quantity to be delivered to customer i in period t
float MaxDistance [VehicleTypes] = ...; //maximum distance that can be travelled in a period by a vehicle of type j
float Capacity [VehicleTypes] = ...; //maximum capacity of a vehicle of type j
float FixCostOwnCar [VehicleTypes] = ...; //fixed cost associated with owning a vehicle of type j for T periods
float VariableCostOwnCar [VehicleTypes] = ...; //variable cost (per unit of distance travelled) of an owned car of type j
//float DistanceMatrix [Customers] [TimePeriods] = ...;
float Distance [Customers] = ...;
//decisionVars
dvar int+ OwnCar [VehicleTypes]; //number of own cars
dvar int+ OwnCarInUse [VehicleTypes] [TimePeriods]; //number of owned cars of type j that are used for delivery in period t
dvar float+ DistanceTravelledOwnCar [VehicleTypes] [TimePeriods]; //distance travelled by owned car in period t (by type j)
dvar float+ ExpDistance [TimePeriods]; //expected distance travelled in period t
dvar int Binary[Customers] [TimePeriods] in 0..1;
//Objective Function
minimize
(sum (j in VehicleTypes) (FixCostOwnCar [j] * OwnCar [j]) + sum (j in VehicleTypes, t in TimePeriods) (VariableCostOwnCar [j] * DistanceTravelledOwnCar [j] [t]));
//constraints
subject to {
forall (j in VehicleTypes, t in TimePeriods) csNumberOwnedCars: OwnCarInUse [j] [t] <= OwnCar [j];
forall (t in TimePeriods) csTotalSupply: sum (j in VehicleTypes) ((OwnCarInUse [j] [t]) * MaxDistance [j]) >= ExpDistance [t] ;
forall (t in TimePeriods) csSufficientCap: sum (j in VehicleTypes) (OwnCarInUse [j] [t] * Capacity [j]) >= sum (i in Customers) Quantity [i] [t];
forall (i in Customers, t in TimePeriods) testCS: (Quantity [i] [t] >=0.01) => Binary[i] [t] == 1;
forall (t in TimePeriods) csExpDis: 2 * sum (i in Customers) Distance [i] * Binary[i] [t] == ExpDistance [t];
}
dat
NumberOfCustomers = 3;
NumberOfTimePeriods = 3;
NumberOfVehicleTypes = 1;
MaxDistance = [500];
Capacity = [5000];
FixCostOwnCar = [60000];
VariableCostOwnCar = [0.8];
Distance = [3, 6, 2];
Quantity = [[0,10,10]
[10, 10, 0]
[0, 0,0]];
#DecisionOptimization#OPLusingCPLEXOptimizer