On 13-Sep-2007, [EMAIL PROTECTED] wrote:
| If one of the variables in the lb and ub constraints are set to be the
| same, the calculation will be wrong or complain about unable to set
| the constraints.
| Here is an example:
| s=-1;
| c=[10,6,4]';
| a=[1,1,1;...
| 10,4,5;...
| 2,2,6];
| b=[100,600,300]';
| ctype=['U','U','U']';
| lb=[50 0,0]';
| ub=[500, 0, 300]';
| vartype=['C','C','C']';
| param.msglev=3;
| param.lpsolver=1;
| param.save=1;
| [xmin,fmin,status,extra]=glpk(c,a,b,lb,ub,ctype,vartype,s,param)
| -----------------------------------------------
|
| This bug exist in the glpkmex, where the defining type of variables did
| not considered lb[i] == ub[i].
| //-- Define type of the structural variables
| if (! freeLB[i] && ! freeUB[i])
| lpx_set_col_bnds (lp, i+1, LPX_DB, lb[i], ub[i]); // if lb[i]
| == ub[i], then status of LPX_DB, will be incorrect
|
| Change it to //-- Define type of the structural variables
| if (! freeLB[i] && ! freeUB[i])
| if (lb[i] != ub[i]) lpx_set_col_bnds (lp, i+1, LPX_DB,
| lb[i], ub[i]);
| else lpx_set_col_bnds (lp, i+1, LPX_FX,
| lb[i], ub[i]);
| will solve the problem.
I checked in the following change for Octave.
Thanks,
jwe
src/ChangeLog:
2007-09-13 John W. Eaton <[EMAIL PROTECTED]>
* DLD-FUNCTIONS/__glpk__.cc (glpk): Pass LPX_FX, not LB_DB, to
lpx_set_col_bnds when lb[i] == ub[i].
From: Zhi Wang <[EMAIL PROTECTED]>.
Index: src/DLD-FUNCTIONS/__glpk__.cc
===================================================================
RCS file: /cvs/octave/src/DLD-FUNCTIONS/__glpk__.cc,v
retrieving revision 1.23
diff -u -u -r1.23 __glpk__.cc
--- src/DLD-FUNCTIONS/__glpk__.cc 26 Jul 2007 18:44:07 -0000 1.23
+++ src/DLD-FUNCTIONS/__glpk__.cc 13 Sep 2007 21:05:08 -0000
@@ -196,7 +196,12 @@
{
//-- Define type of the structural variables
if (! freeLB[i] && ! freeUB[i])
- lpx_set_col_bnds (lp, i+1, LPX_DB, lb[i], ub[i]);
+ {
+ if (lb[i] != ub[i])
+ lpx_set_col_bnds (lp, i+1, LPX_DB, lb[i], ub[i]);
+ else
+ lpx_set_col_bnds (lp, i+1, LPX_FX, lb[i], ub[i]);
+ }
else
{
if (! freeLB[i] && freeUB[i])
_______________________________________________
Bug-glpk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-glpk