Advertisement
Guest User

Untitled

a guest
Mar 14th, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. ```
  2. # Sets
  3. set MACHINES;
  4. set WELLS;
  5. set DAYS; # Can be TIMES with a smaller measure rather than Days
  6. # Parameters
  7. param well_operation{WELLS}; # Required operation type for each well
  8. param machine_operation{MACHINES}; # Operation type of each machine
  9. param distance{WELLS, WELLS}; # Distance between wells
  10. param operating_cost{MACHINES}; # Operating cost per day for each machine
  11. param priority{WELLS}; # Priority of each well
  12.  
  13. # Decision variables
  14. var operates{MACHINES, WELLS, DAYS} binary; # operates[m, i, d] = 1 if machine m is at well i on day d
  15. var finished{WELLS, DAYS} binary; # finished[i, d] = 1 if well i operation is over on day d
  16. 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
  17. var works{MACHINES, DAYS} binary; # works[m, d] = 1 if machine m is operating on day d
  18.  
  19. subject to Travel_Consistency{m in MACHINES, i in WELLS, j in WELLS, d in DAYS}:
  20. travel[m, i, j, d] == 1 <==> operates[m, i, d] == 1;
  21. subject to Operation_Consistency{m in MACHINES, i in WELLS, d in DAYS}:
  22. operates[m, i, d] == 1 <==> works[m,i];
  23. # Less priority implies, higher priority wells have already been finished
  24. subject to Priorities{i in WELLS, j in WELLS: priority[i] < priority[j]}:
  25. finished[m, i, d] == 1 ==> finished[m,j,d] == 1;
  26. # TODO simplified version of problem req. Best solution would be to have a set of feasible combinations between Machines and Wells
  27. subject to Incompatibilities{m in MACHINES, i in WELLS: machine_operation[m] != well_operation[i]}:
  28. works[m,i] == 0;
  29.  
  30. # Defined variables
  31. var total_distance = sum{m in MACHINES, i in WELLS, j in WELLS, d in DAYS} distance[i, j] * travel[m, i, j, d];
  32. var total_renting_cost = sum{m in MACHINES, d in DAYS} operating_cost[m] * works[m, d];
  33.  
  34. minimize Total_Cost:
  35. total_distance + total_renting_cost;
  36. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement