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.

43 lines
1.4 KiB

4 weeks ago
  1. /* MVCP, Minimum Vertex Cover Problem */
  2. /* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
  3. /* The Minimum Vertex Cover Problem in a network G = (V, E), where V
  4. is a set of nodes, E is a set of arcs, is to find a subset V' within
  5. V such that each edge (i,j) in E has at least one its endpoint in V'
  6. and which minimizes the sum of node weights w(i) over V'.
  7. Reference:
  8. Garey, M.R., and Johnson, D.S. (1979), Computers and Intractability:
  9. A guide to the theory of NP-completeness [Graph Theory, Covering and
  10. Partitioning, Minimum Vertex Cover, GT1]. */
  11. set E, dimen 2;
  12. /* set of edges */
  13. set V := (setof{(i,j) in E} i) union (setof{(i,j) in E} j);
  14. /* set of nodes */
  15. param w{i in V}, >= 0, default 1;
  16. /* w[i] is weight of vertex i */
  17. var x{i in V}, binary;
  18. /* x[i] = 1 means that node i is included into V' */
  19. s.t. cov{(i,j) in E}: x[i] + x[j] >= 1;
  20. /* each edge (i,j) must have node i or j (or both) in V' */
  21. minimize z: sum{i in V} w[i] * x[i];
  22. /* we need to minimize the sum of node weights over V' */
  23. data;
  24. /* These data correspond to an example from [Papadimitriou]. */
  25. /* Optimal solution is 6 (greedy heuristic gives 13) */
  26. set E := a1 b1, b1 c1, a1 b2, b2 c2, a2 b3, b3 c3, a2 b4, b4 c4, a3 b5,
  27. b5 c5, a3 b6, b6 c6, a4 b1, a4 b2, a4 b3, a5 b4, a5 b5, a5 b6,
  28. a6 b1, a6 b2, a6 b3, a6 b4, a7 b2, a7 b3, a7 b4, a7 b5, a7 b6;
  29. end;