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