examples/todd.mod
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 06 Dec 2010 13:09:21 +0100
changeset 1 c445c931472f
permissions -rw-r--r--
Import glpk-4.45

- Generated files and doc/notes are removed
alpar@1
     1
/* TODD, a class of hard instances of zero-one knapsack problems */
alpar@1
     2
alpar@1
     3
/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
alpar@1
     4
alpar@1
     5
/* Chvatal describes a class of instances of zero-one knapsack problems
alpar@1
     6
   due to Todd. He shows that a wide class of algorithms - including all
alpar@1
     7
   based on branch and bound or dynamic programming - find it difficult
alpar@1
     8
   to solve problems in the Todd class. More exactly, the time required
alpar@1
     9
   by these algorithms to solve instances of problems that belong to the
alpar@1
    10
   Todd class grows as an exponential function of the problem size.
alpar@1
    11
alpar@1
    12
   Reference:
alpar@1
    13
   Chvatal V. (1980), Hard knapsack problems, Op. Res. 28, 1402-1411. */
alpar@1
    14
alpar@1
    15
param n > 0 integer;
alpar@1
    16
alpar@1
    17
param log2_n := log(n) / log(2);
alpar@1
    18
alpar@1
    19
param k := floor(log2_n);
alpar@1
    20
alpar@1
    21
param a{j in 1..n} := 2 ** (k + n + 1) + 2 ** (k + n + 1 - j) + 1;
alpar@1
    22
alpar@1
    23
param b := 0.5 * floor(sum{j in 1..n} a[j]);
alpar@1
    24
alpar@1
    25
var x{1..n} binary;
alpar@1
    26
alpar@1
    27
maximize obj: sum{j in 1..n} a[j] * x[j];
alpar@1
    28
alpar@1
    29
s.t. cap: sum{j in 1..n} a[j] * x[j] <= b;
alpar@1
    30
alpar@1
    31
data;
alpar@1
    32
alpar@1
    33
param n := 15;
alpar@1
    34
/* change this parameter to choose a particular instance */
alpar@1
    35
alpar@1
    36
end;