bug-glpk
[Top][All Lists]
Advanced

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

[Bug-glpk] Re: Code with No Effect


From: Andrew Makhorin
Subject: [Bug-glpk] Re: Code with No Effect
Date: Wed, 12 Nov 2003 19:47:19 +0300

>In looking over the code for glpk, I have found that there are
>several instances of array arguments of the form:
>    [lp, exp]
>where "exp" is some expression.
>
>In C, the ',' operator evaluates the argument to its left (in this
>case "lp", but discards the result.  This means that the above
>expression is eqivalent to
>   [exp]
>
>For an example of what I am talking about, look at
>    source/glplpx6a.c
>around line 2431 (I am looking at the source from the version 4.1
>tarball).
>
>While it is easy enough to remove (or ignore) these, it makes me wonder
>what the original author was intending -- I assume this is not meant
>to be a 2-d array reference of the form
>    [lp][exp]
>as the code is functional as is (at least it seems to find solutions
>to the problems I have posed it).

Thank you very much for your report! In fact, the following two lines in
glplpx6a.c:

2431: dS_j = cbar[lp, posx[j] - m];

2445: dR_i = cbar[lp, posx[i] - m];

must actually be

2431: dS_j = cbar[posx[j] - m];

2445: dR_i = cbar[posx[i] - m];

This is a kind of typo (I suspect that earlier there was something like
lp->posx) which, however, being a valid C expression is not recognized
by the compiler. Fortunately, evaluation of e1, e2, ..., en gives en, so
the result in both cases above (the reduced cost of non-basic structural
variable xS[j] or non-basic auxiliary variable xR[i]) is correct.






reply via email to

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