summaryrefslogtreecommitdiff
path: root/glpk-5.0/examples/todd.mod
diff options
context:
space:
mode:
authorPasha <pasha@member.fsf.org>2023-01-27 00:54:07 +0000
committerPasha <pasha@member.fsf.org>2023-01-27 00:54:07 +0000
commitef800d4ffafdbde7d7a172ad73bd984b1695c138 (patch)
tree920cc189130f1e98f252283fce94851443641a6d /glpk-5.0/examples/todd.mod
parentec4ae3c2b5cb0e83fb667f14f832ea94f68ef075 (diff)
downloadoneapi-ef800d4ffafdbde7d7a172ad73bd984b1695c138.tar.gz
oneapi-ef800d4ffafdbde7d7a172ad73bd984b1695c138.tar.bz2
simplex-glpk with modified glpk for fpgaHEADmaster
Diffstat (limited to 'glpk-5.0/examples/todd.mod')
-rw-r--r--glpk-5.0/examples/todd.mod36
1 files changed, 36 insertions, 0 deletions
diff --git a/glpk-5.0/examples/todd.mod b/glpk-5.0/examples/todd.mod
new file mode 100644
index 0000000..c0ef44b
--- /dev/null
+++ b/glpk-5.0/examples/todd.mod
@@ -0,0 +1,36 @@
+/* TODD, a class of hard instances of zero-one knapsack problems */
+
+/* Written in GNU MathProg by Andrew Makhorin <mao@gnu.org> */
+
+/* Chvatal describes a class of instances of zero-one knapsack problems
+ due to Todd. He shows that a wide class of algorithms - including all
+ based on branch and bound or dynamic programming - find it difficult
+ to solve problems in the Todd class. More exactly, the time required
+ by these algorithms to solve instances of problems that belong to the
+ Todd class grows as an exponential function of the problem size.
+
+ Reference:
+ Chvatal V. (1980), Hard knapsack problems, Op. Res. 28, 1402-1411. */
+
+param n > 0 integer;
+
+param log2_n := log(n) / log(2);
+
+param k := floor(log2_n);
+
+param a{j in 1..n} := 2 ** (k + n + 1) + 2 ** (k + n + 1 - j) + 1;
+
+param b := 0.5 * floor(sum{j in 1..n} a[j]);
+
+var x{1..n} binary;
+
+maximize obj: sum{j in 1..n} a[j] * x[j];
+
+s.t. cap: sum{j in 1..n} a[j] * x[j] <= b;
+
+data;
+
+param n := 15;
+/* change this parameter to choose a particular instance */
+
+end;