The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

79 lines
2.5 KiB

2 months ago
  1. /* GAP, Generalized Assignment Problem */
  2. /* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
  3. /* The Generalized Assignment Problem (GAP) is to assign a set of jobs
  4. to a set of agents subject to the constraints that each job must be
  5. assigned exactly to one agent and the total resources consumed by all
  6. jobs assigned to an agent must not exceed the agent's capacity. */
  7. param m, integer, > 0;
  8. /* number of agents */
  9. param n, integer, > 0;
  10. /* number of jobs */
  11. set I := 1..m;
  12. /* set of agents */
  13. set J := 1..n;
  14. /* set of jobs */
  15. param a{i in I, j in J}, >= 0;
  16. /* resource consumed in allocating job j to agent i */
  17. param b{i in I}, >= 0;
  18. /* resource capacity of agent i */
  19. param c{i in I, j in J}, >= 0;
  20. /* cost of allocating job j to agent i */
  21. var x{i in I, j in J}, binary;
  22. /* x[i,j] = 1 means job j is assigned to agent i */
  23. s.t. one{j in J}: sum{i in I} x[i,j] = 1;
  24. /* job j must be assigned exactly to one agent */
  25. s.t. lim{i in I}: sum{j in J} a[i,j] * x[i,j] <= b[i];
  26. /* total amount of resources consumed by all jobs assigned to agent i
  27. must not exceed the agent's capacity */
  28. minimize obj: sum{i in I, j in J} c[i,j] * x[i,j];
  29. /* the objective is to find cheapest assignment (note that gap can also
  30. be formulated as maximization problem) */
  31. data;
  32. /* These data correspond to the instance c515-1 (gap1) from:
  33. I.H. Osman, "Heuristics for the Generalised Assignment Problem:
  34. Simulated Annealing and Tabu Search Approaches", OR Spektrum, Volume
  35. 17, 211-225, 1995
  36. D. Cattrysse, M. Salomon and L.N. Van Wassenhove, "A set partitioning
  37. heuristic for the generalized assignment problem", European Journal
  38. of Operational Research, Volume 72, 167-174, 1994 */
  39. /* The optimal solution is 261 (minimization) or 336 (maximization) */
  40. param m := 5;
  41. param n := 15;
  42. param a : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 :=
  43. 1 8 15 14 23 8 16 8 25 9 17 25 15 10 8 24
  44. 2 15 7 23 22 11 11 12 10 17 16 7 16 10 18 22
  45. 3 21 20 6 22 24 10 24 9 21 14 11 14 11 19 16
  46. 4 20 11 8 14 9 5 6 19 19 7 6 6 13 9 18
  47. 5 8 13 13 13 10 20 25 16 16 17 10 10 5 12 23 ;
  48. param b := 1 36, 2 34, 3 38, 4 27, 5 33;
  49. param c : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 :=
  50. 1 17 21 22 18 24 15 20 18 19 18 16 22 24 24 16
  51. 2 23 16 21 16 17 16 19 25 18 21 17 15 25 17 24
  52. 3 16 20 16 25 24 16 17 19 19 18 20 16 17 21 24
  53. 4 19 19 22 22 20 16 19 17 21 19 25 23 25 25 25
  54. 5 18 19 15 15 21 25 16 16 23 15 22 17 19 22 24 ;
  55. end;