Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```
- # Sets
- set MACHINES;
- set WELLS;
- set DAYS; # Can be TIMES with a smaller measure rather than Days
- # Parameters
- param well_operation{WELLS}; # Required operation type for each well
- param machine_operation{MACHINES}; # Operation type of each machine
- param distance{WELLS, WELLS}; # Distance between wells
- param operating_cost{MACHINES}; # Operating cost per day for each machine
- param priority{WELLS}; # Priority of each well
- # Decision variables
- var operates{MACHINES, WELLS, DAYS} binary; # operates[m, i, d] = 1 if machine m is at well i on day d
- var finished{WELLS, DAYS} binary; # finished[i, d] = 1 if well i operation is over on day d
- var travel{MACHINES, WELLS, WELLS, DAYS} binary; # travel[m, i, j, d] = 1 if machine m travels from well i to well j on day d
- var works{MACHINES, DAYS} binary; # works[m, d] = 1 if machine m is operating on day d
- subject to Travel_Consistency{m in MACHINES, i in WELLS, j in WELLS, d in DAYS}:
- travel[m, i, j, d] == 1 <==> operates[m, i, d] == 1;
- subject to Operation_Consistency{m in MACHINES, i in WELLS, d in DAYS}:
- operates[m, i, d] == 1 <==> works[m,i];
- # Less priority implies, higher priority wells have already been finished
- subject to Priorities{i in WELLS, j in WELLS: priority[i] < priority[j]}:
- finished[m, i, d] == 1 ==> finished[m,j,d] == 1;
- # TODO simplified version of problem req. Best solution would be to have a set of feasible combinations between Machines and Wells
- subject to Incompatibilities{m in MACHINES, i in WELLS: machine_operation[m] != well_operation[i]}:
- works[m,i] == 0;
- # Defined variables
- var total_distance = sum{m in MACHINES, i in WELLS, j in WELLS, d in DAYS} distance[i, j] * travel[m, i, j, d];
- var total_renting_cost = sum{m in MACHINES, d in DAYS} operating_cost[m] * works[m, d];
- minimize Total_Cost:
- total_distance + total_renting_cost;
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement