bug-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-glpk] patch for glpk 4.0


From: Andrew Makhorin
Subject: [Bug-glpk] patch for glpk 4.0
Date: Sun, 11 May 2003 22:16:51 +0400

Here is the patch for glpk 4.0 (see below) to fix three bugs in the
MathProg translator.

The bugs are:
 - conditional set expression is incorrectly parsed;
 - dimen attribute is not set by default if a set is used recursively
   in its own declaration;
 - logical expression ... in if ... then ... else ... doesn't work.

The bugs were detected due to the bug report provided by Giles
<address@hidden>.

To patch glpk 4.0 do the following:

1. Unzip and untar the distribution file glpk-4.0.

2. Snip out the patch from the e-mail along the marker lines and put it
   into the file 'patch' in the same directory where glpk-4.0 is placed.

3. Run the command

      patch -p0 -r glpk-4.0 < patch

4. Rename (if you wish) the directory glpk-4.0 to glpk-4.0.1 and then
   compile and install the package in the usual way.

(For details about patching see the GNU Diffutils documentation.)

snip here ==============================================================
diff -a -r -u glpk-4.0/source/glpmpl1.c glpk-4.0.1/source/glpmpl1.c
--- glpk-4.0/source/glpmpl1.c   Tue May  6 12:00:00 2003
+++ glpk-4.0.1/source/glpmpl1.c Sun May 11 12:00:00 2003
@@ -891,6 +891,10 @@
             set = (SET *)node->link;
             name = set->name;
             dim = set->dim;
+            /* if a set object is referenced in its own declaration and
+               the dimen attribute is not specified yet, use dimen 1 by
+               default */
+            if (set->dimen == 0) set->dimen = 1;
             break;
          case A_PARAMETER:
             /* model parameter */
@@ -1805,7 +1809,7 @@
          error(mpl, "expressions following then and else have different"
             " dimensions %d and %d, respectively", y->dim, z->dim);
 skip: /* generate pseudo-code to perform branching */
-      code = make_ternary(mpl, O_FORK, x, y, z, y->type, 0);
+      code = make_ternary(mpl, O_FORK, x, y, z, y->type, y->dim);
       return code;
 }
 
diff -a -r -u glpk-4.0/source/glpmpl3.c glpk-4.0.1/source/glpmpl3.c
--- glpk-4.0/source/glpmpl3.c   Tue May  6 12:00:00 2003
+++ glpk-4.0.1/source/glpmpl3.c Sun May 11 12:00:00 2003
@@ -3744,6 +3744,13 @@
                code->arg.arg.z == NULL ? 1.0 : eval_numeric(mpl,
                   code->arg.arg.z));
             break;
+         case O_FORK:
+            /* if-then-else */
+            if (eval_logical(mpl, code->arg.arg.x))
+               value = eval_elemset(mpl, code->arg.arg.y);
+            else
+               value = eval_elemset(mpl, code->arg.arg.z);
+            break;
          case O_SETOF:
             /* compute elemental set */
             {  struct iter_set_info _info, *info = &_info;
@@ -3896,6 +3903,13 @@
                /* perform the main check */
                value = (arelset_member(mpl, t0, tf, dt, j) == x);
             }
+            break;
+         case O_FORK:
+            /* check if given n-tuple is member of conditional set */
+            if (eval_logical(mpl, code->arg.arg.x))
+               value = is_member(mpl, code->arg.arg.y, tuple);
+            else
+               value = is_member(mpl, code->arg.arg.z, tuple);
             break;
          case O_SETOF:
             /* check if given n-tuple is member of computed set */
snip here ==============================================================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]