[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] inf as RHS of constraint
From: |
glpk xypron |
Subject: |
Re: [Help-glpk] inf as RHS of constraint |
Date: |
Tue, 18 Jan 2011 17:49:54 +0100 |
Hello Kevin, hello Andrew,
> > Which version of GLPK have you been using? GLPK 4.45 should support
> > inf and infinity.
>
the following patch should resolve the issue.
Best regards
Xypron
--- glpk-4.45\src\glpcpx.c 2010-12-05 10:00:00.000000000 +0100
+++ glpk-4.45\src\glpcpx.c 2011-01-18 15:46:36.426163500 +0100
@@ -523,8 +523,9 @@
*
* <row name> ::= <empty> | <symbolic name> :
* <row sense> ::= < | <= | =< | > | >= | => | =
+* <infinity> ::= infinity | inf
* <right-hand side> ::= <numeric constant> | + <numeric constant> |
-* - <numeric constant>
+* - <numeric constant> | + <infinity> | - <infinity>
* <constraint> ::= <row name> <linear form> <row sense>
* <right-hand side>
* <subject to> ::= subject to | such that | st | s.t. | st.
@@ -575,9 +576,20 @@
s = -1.0, scan_token(csa);
else
s = +1.0;
- if (csa->token != T_NUMBER)
- error(csa, "missing right-hand side\n");
- glp_set_row_bnds(csa->P, i, type, s * csa->value, s * csa->value);
+ if (csa->token == T_NUMBER)
+ { glp_set_row_bnds(csa->P, i, type, s * csa->value, s * csa->value);
+ } else if (the_same(csa->image, "infinity") ||
+ the_same(csa->image, "inf"))
+ { if ( s > 0 && type != GLP_UP )
+ { error(csa, "invalid use of `inf' as lower bound\n");
+ } else if ( s < 0 && type != GLP_LO )
+ { error(csa, "invalid use of `-inf' as upper bound\n");
+ } else
+ { glp_set_row_bnds(csa->P, i, type, s * DBL_MAX, s * DBL_MAX );
+ }
+ } else
+ { error(csa, "missing right-hand side\n");
+ }
/* the rest of the current line must be empty */
if (!(csa->c == '\n' || csa->c == XEOF))
error(csa, "invalid symbol(s) beyond right-hand side\n");
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone