31 #define MAX_LINE_WRITE_LEN 65536 40 if(primal.
dim() != nCols())
45 if(activity.
dim() != nRows())
52 for(c = 0; c < nCols() && primal[c] == 0; c++)
61 activity = colVector(c);
63 activity *= primal[c];
66 for(; c < nCols(); c++)
70 activity.
multAdd(primal[c], colVector(c));
79 if(dual.
dim() != nRows())
84 if(activity.
dim() != nCols())
91 for(r = 0; r < nRows() && dual[r] == 0; r++)
100 activity = rowVector(r);
105 for(; r < nRows(); r++)
109 activity.
multAdd(dual[r], rowVector(r));
119 for(
int i = 0; i < nCols(); ++i)
137 for(
int i = 0; i < nCols(); ++i)
154 #define LPF_MAX_LINE_LEN 8192 159 return (c ==
' ') || (c ==
'\t') || (c ==
'\n') || (c ==
'\r');
167 return ((*s >=
'0') && (*s <=
'9')) || (*s ==
'+') || (*s ==
'-') || (*s ==
'.');
179 return ((*s >=
'A') && (*s <=
'Z'))
180 || ((*s >=
'a') && (*s <=
'z'))
181 || (strchr(
"!\"#$%&()/,;?@_'`{}|~", *s) != 0);
189 return (*s ==
'<') || (*s ==
'>') || (*s ==
'=');
196 return ((s[0] ==
'-') || (s[0] ==
'+'))
197 && (tolower(s[1]) ==
'i')
198 && (tolower(s[2]) ==
'n')
199 && (tolower(s[3]) ==
'f');
206 return (tolower(s[0]) ==
'f')
207 && (tolower(s[1]) ==
'r')
208 && (tolower(s[2]) ==
'e')
209 && (tolower(s[3]) ==
'e');
226 bool has_digits =
false;
227 bool has_emptyexponent =
false;
228 bool has_dot =
false;
229 bool has_exponent =
false;
230 bool has_emptydivisor =
false;
233 if((*s ==
'+') || (*s ==
'-'))
237 while((*s >=
'0') && (*s <=
'9'))
250 while((*s >=
'0') && (*s <=
'9'))
258 if(tolower(*s) ==
'e')
261 has_emptyexponent =
true;
265 if((*s ==
'+') || (*s ==
'-'))
269 while((*s >=
'0') && (*s <=
'9'))
271 has_emptyexponent =
false;
280 has_emptydivisor =
true;
282 while((*s >=
'0') && (*s <=
'9'))
284 has_emptydivisor =
false;
288 if(has_dot || has_exponent || has_emptydivisor ||
289 (*s ==
'.') || (*s ==
'+') || (*s ==
'-') || (tolower(*s) ==
'e'))
291 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD03 Warning: In line " << lineno <<
292 ": malformed rational value in LP file\n";)
299 if(has_emptyexponent)
301 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD01 Warning: In line " << lineno <<
302 ": found empty exponent in LP file - check for forbidden variable names with initial 'e' or 'E'\n");
306 value = (*pos ==
'-') ? -1 : 1;
309 for(t = tmp; pos != s; pos++)
316 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD04 Warning: In line " << lineno <<
317 ": malformed rational value in LP file\n");
325 MSG_DEBUG(std::cout <<
"DLPFRD01 LPFreadValue = " << value << std::endl;)
344 assert(colnames != 0);
352 while((strchr(
"+-.<>= ", *s) == 0) && (*s !=
'\0'))
355 for(i = 0; pos != s; i++, pos++)
360 if((colidx = colnames->
number(name)) < 0)
364 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD02 Unknown variable \"" << name <<
"\" ";)
367 colidx = colnames->
num();
369 colset.
add(*emptycol);
373 MSG_DEBUG(std::cout <<
"DLPFRD03 LPFreadColName [" << name <<
"] = " << colidx << std::endl;)
390 if((*pos ==
'<') || (*pos ==
'>'))
395 MSG_DEBUG(std::cout <<
"DLPFRD04 LPFreadSense = " << static_cast<char>(sense) << std::endl;)
413 assert(keyword != 0);
415 for(i = 0, k = 0; keyword[i] !=
'\0'; i++, k++)
417 if(keyword[i] ==
'[')
422 while((tolower(pos[k]) == keyword[i]) && (pos[k] !=
'\0'))
428 while(keyword[i] !=
']')
435 if(keyword[i] != tolower(pos[k]))
446 MSG_DEBUG(std::cout <<
"DLPFRD05 LPFhasKeyword: " << keyword << std::endl;)
459 const char* s = strchr(pos,
':');
464 int dcolpos = int(s - pos);
470 for(end = dcolpos - 1; end >= 0; end--)
477 pos = &(pos[dcolpos + 1]);
482 for(srt = end - 1; srt >= 0; srt--)
489 assert(srt <= end && pos[srt] !=
' ');
495 for(i = srt; i <= end; i++)
503 pos = &(pos[dcolpos + 1]);
514 Rational sense = (*pos ==
'-') ? -1 : 1;
543 std::istream& p_input,
550 START, OBJECTIVE, CONSTRAINTS, BOUNDS, INTEGERS, BINARIES
571 bool finished =
false;
573 bool have_value =
true;
586 cnames =
new(cnames)
NameSet();
599 rnames =
new(rnames)
NameSet();
623 if(!p_input.getline(buf,
sizeof(buf)))
628 <<
" characters" << std::endl;)
632 MSG_ERROR(std::cerr <<
"ELPFRD07 No 'End' marker found" << std::endl;)
643 MSG_DEBUG(std::cout <<
"DLPFRD08 Reading line " << lineno
644 <<
" (pos=" << pos <<
")" << std::endl;)
647 if(0 != (s = strchr(buf,
'\\')))
664 else if(section == OBJECTIVE)
672 for(
int j = vec.
size() - 1; j >= 0; --j)
679 section = CONSTRAINTS;
682 else if(section == CONSTRAINTS &&
725 if(section == OBJECTIVE)
729 if(section == CONSTRAINTS)
738 for(k = 0; pos[i] !=
'\0'; i++)
749 for(i = 0, k = 0; tmp[i] !=
'\0'; i++)
751 while(((tmp[i] ==
'+') || (tmp[i] ==
'-')) && ((tmp[i + 1] ==
'+') || (tmp[i + 1] ==
'-')))
754 tmp[i] = (tmp[i] ==
'-') ?
'+' :
'-';
767 MSG_DEBUG(std::cout <<
"DLPFRD09 pos=" << pos << std::endl;)
770 while((pos != 0) && (*pos !=
'\0'))
808 vec.
add(colidx, val);
839 else if(sense ==
'>')
846 assert(sense ==
'=');
886 int n = vec.
pos(colidx);
890 vec.
add(colidx, val);
894 assert(vec.
index(n) == colidx);
903 assert(cnames->
has(colidx));
905 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD10 Duplicate index " 907 <<
" in line " << lineno
955 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD11 in Bounds section line " 956 << lineno <<
" ignored" << std::endl;)
965 else if(sense ==
'>')
969 assert(sense ==
'=');
994 else if(sense ==
'>')
998 assert(sense ==
'=');
1016 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD12 in Binary/General section line " << lineno <<
1017 " ignored" << std::endl;)
1021 if(section == BINARIES)
1023 if(cset.
lower(colidx) < 0)
1028 if(cset.
upper(colidx) > 1)
1035 p_intvars->
addIdx(colidx);
1041 MSG_ERROR(std::cerr <<
"ELPFRD13 This seems to be no LP format file" << std::endl;)
1053 assert(isConsistent());
1056 assert(isConsistent());
1059 assert(isConsistent());
1065 MSG_INFO2((*spxout), (*spxout) <<
"Finished reading " << lineno <<
" lines" << std::endl;)
1068 MSG_ERROR(std::cerr <<
"ELPFRD15 Syntax error in line " << lineno << std::endl;)
1097 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD01 Problem name : " << mps.
probName() << std::endl;)
1103 if(!strcmp(mps.
field0(),
"ROWS"))
1105 else if(!strncmp(mps.
field0(),
"OBJSEN", 6))
1107 else if(!strcmp(mps.
field0(),
"OBJNAME"))
1130 if(!strcmp(mps.
field1(),
"MIN"))
1132 else if(!strcmp(mps.
field1(),
"MAX"))
1141 if(!strcmp(mps.
field0(),
"ROWS"))
1143 else if(!strcmp(mps.
field0(),
"OBJNAME"))
1172 if(strcmp(mps.
field0(),
"ROWS"))
1196 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD02 Objective name : " << mps.
objName() << std::endl;)
1198 if(strcmp(mps.
field0(),
"COLUMNS"))
1268 if(strcmp(mps.
field0(),
"RHS"))
1271 if(colname[0] !=
'\0')
1286 if(strcmp(colname, mps.
field1()))
1289 if(colname[0] !=
'\0')
1291 col.setColVector(vec);
1299 int ncnames = cnames.
size();
1300 cnames.
add(colname);
1303 if(cnames.
size() <= ncnames)
1305 MSG_ERROR(std::cerr <<
"ERROR in COLUMNS: duplicate column name or not column-wise ordering" <<
1310 cnames.
add(colname);
1318 assert(cnames.
number(colname) == cset.
num());
1330 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD01 Warning: malformed rational value in MPS file\n");
1346 assert(mps.
field4() != 0);
1350 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD02 Warning: malformed rational value in MPS file\n");
1383 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD03 RHS name : " << rhsname << std::endl;);
1385 if(!strcmp(mps.
field0(),
"RANGES"))
1387 else if(!strcmp(mps.
field0(),
"BOUNDS"))
1389 else if(!strcmp(mps.
field0(),
"ENDATA"))
1403 if(*rhsname ==
'\0')
1406 if(strcmp(rhsname, mps.
field1()))
1408 if(strcmp(addname, mps.
field1()))
1412 MSG_INFO3((*spxout), (*spxout) <<
"IMPSRD07 RHS ignored : " << addname << std::endl);
1423 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD03 Warning: malformed rational value in MPS file\n");
1428 rset.
rhs_w(idx) = val;
1432 rset.
lhs_w(idx) = val;
1443 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD04 Warning: malformed rational value in MPS file\n");
1448 rset.
rhs_w(idx) = val;
1452 rset.
lhs_w(idx) = val;
1475 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD04 Range name : " << rngname << std::endl;);
1477 if(!strcmp(mps.
field0(),
"BOUNDS"))
1479 else if(!strcmp(mps.
field0(),
"ENDATA"))
1493 if(*rngname ==
'\0')
1508 if(!strcmp(rngname, mps.
field1()))
1516 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD05 Warning: malformed rational value in MPS file\n");
1522 assert(rset.
lhs(idx) == rset.
rhs(idx));
1524 if(
double(val) >= 0)
1525 rset.
rhs_w(idx) += val;
1527 rset.
lhs_w(idx) += val;
1554 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD06 Warning: malformed rational value in MPS file\n");
1560 assert(rset.
lhs(idx) == rset.
rhs(idx));
1562 if(
double(val) >= 0)
1563 rset.
rhs_w(idx) += val;
1565 rset.
lhs_w(idx) += val;
1605 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD05 Bound name : " << bndname << std::endl;)
1607 if(strcmp(mps.
field0(),
"ENDATA"))
1616 if((!strcmp(mps.
field1(),
"LO"))
1617 || (!strcmp(mps.
field1(),
"UP"))
1618 || (!strcmp(mps.
field1(),
"FX"))
1619 || (!strcmp(mps.
field1(),
"LI"))
1620 || (!strcmp(mps.
field1(),
"UI")))
1634 if(*bndname ==
'\0')
1641 if(!strcmp(bndname, mps.
field2()))
1649 else if(!strcmp(mps.
field4(),
"-Inf") || !strcmp(mps.
field4(),
"-inf"))
1651 else if(!strcmp(mps.
field4(),
"Inf") || !strcmp(mps.
field4(),
"inf")
1652 || !strcmp(mps.
field4(),
"+Inf") || !strcmp(mps.
field4(),
"+inf"))
1656 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD07 Warning: malformed rational value in MPS file line " 1663 if(mps.
field1()[1] ==
'I')
1670 if(oldbinvars.
pos(idx) < 0)
1688 if(mps.
field1()[1] ==
'X')
1743 #define INIT_COLS 1000 1744 #define INIT_NZOS 5000
1747 std::istream& p_input,
1763 cnames =
new(cnames)
NameSet();
1776 rnames =
new(rnames)
NameSet();
1810 addedRows(rset.
num());
1813 MPSreadCols(mps, rset, *rnames, cset, *cnames, p_intvars, spxout);
1834 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD06 Objective sense: " << ((mps.
objSense() ==
1841 addedCols(cset.
num());
1843 assert(isConsistent());
1873 int p_num_written_rows
1878 assert(p_idx < p_lp.
nRows());
1884 if(p_rnames->
has(key))
1885 return (*p_rnames)[key];
1888 spxSnprintf(p_buf, 16,
"C%d", p_num_written_rows);
1905 assert(p_idx < p_lp.
nCols());
1911 if(p_cnames->
has(key))
1912 return (*p_cnames)[key];
1923 #define NUM_ENTRIES_PER_LINE 5 1926 std::ostream& p_output,
1937 pos = p_output.tellp();
1939 for(
int j = 0; j < p_lp.
nCols(); ++j)
1947 p_output << coeff <<
" " <<
getColName(p_lp, j, p_cnames, name);
1961 "XLPSWR01 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n");
1964 pos = p_output.tellp();
1968 p_output <<
" - " << -coeff;
1970 p_output <<
" + " << coeff;
1972 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name);
1984 std::ostream& p_output,
1992 p_output << ((sense == SPxLPBase<Rational>::MINIMIZE) ?
"Minimize\n" :
"Maximize\n");
1993 p_output <<
" obj: ";
1997 svec.operator = (obj);
2008 std::ostream& p_output,
2018 pos = p_output.tellp();
2023 sidelen = (p_lhs == p_rhs
2028 if((
long long)(p_output.tellp()) - pos + sidelen + (
long long)100 >
MAX_LINE_WRITE_LEN)
2035 "XLPSWR02 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n");
2038 pos = p_output.tellp();
2043 p_output <<
" = " << p_rhs;
2044 else if(
double(p_lhs) <=
double(-
infinity))
2045 p_output <<
" <= " << p_rhs;
2048 assert(
double(p_rhs) >=
double(
infinity));
2049 p_output <<
" >= " << p_lhs;
2057 "XLPSWR03 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n");
2066 std::ostream& p_output,
2075 p_output <<
"Subject To\n";
2077 for(
int i = 0; i < p_lp.
nRows(); ++i)
2082 if(
double(lhs) > -
double(
infinity) &&
double(rhs) <
double(
infinity) && lhs != rhs)
2085 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_1 : ";
2088 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_2 : ";
2093 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
" : ";
2105 std::ostream& p_output,
2114 pos = p_output.tellp();
2116 p_output <<
"Bounds\n";
2118 for(
int j = 0; j < p_lp.
nCols(); ++j)
2125 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
" = " << upper <<
'\n';
2127 else if(
double(lower) > -
double(
infinity))
2129 if(
double(upper) <
double(
infinity))
2133 p_output <<
" " << lower <<
" <= " 2135 <<
" <= " << upper <<
'\n';
2137 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2138 <<
" <= " << upper <<
'\n';
2141 p_output <<
" " << lower <<
" <= " 2145 else if(
double(upper) <
double(
infinity))
2146 p_output <<
" -Inf <= " 2148 <<
" <= " << upper <<
'\n';
2150 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2157 "XLPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing LP file\n");
2160 pos = p_output.tellp();
2169 std::ostream& p_output,
2177 if(p_intvars == NULL || p_intvars->
size() <= 0)
2180 p_output <<
"Generals\n";
2182 for(
int j = 0; j < p_lp.
nCols(); ++j)
2183 if(p_intvars->
pos(j) >= 0)
2184 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
"\n";
2192 std::ostream& p_output,
2200 LPFwriteRows(*
this, p_output, p_rnames, p_cnames, spxout);
2204 p_output <<
"End" << std::endl;
2216 const char* indicator,
2219 const char* name1 = 0,
2221 const char* name2 = 0,
2229 spxSnprintf(buf,
sizeof(buf),
" %-2.2s %-8.8s", (indicator == 0) ?
"" : indicator,
2230 (name == 0) ?
"" : name);
2236 os << buf << value1;
2241 os << buf << value2;
2251 "XMPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing MPS file\n");
2261 if(
double(left) > -
double(
infinity))
2263 else if(
double(right) <
double(
infinity))
2282 assert(idx < lp.
nRows());
2288 if(rnames->
has(key))
2289 return (*rnames)[key];
2304 std::ostream& p_output,
2311 const char* indicator;
2315 bool has_ranges =
false;
2320 p_output <<
"NAME MPSDATA" << std::endl;
2323 p_output <<
"ROWS" << std::endl;
2325 for(i = 0; i < nRows(); i++)
2327 if(lhs(i) == rhs(i))
2329 else if((
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)))
2334 else if(
double(lhs(i)) > -
double(
infinity))
2336 else if(
double(rhs(i)) <
double(
infinity))
2347 p_output <<
"COLUMNS" << std::endl;
2349 bool has_intvars = (p_intvars != 0) && (p_intvars->
size() > 0);
2351 for(
int j = 0; j < (has_intvars ? 2 : 1); j++)
2353 bool is_intrun = has_intvars && (j == 1);
2356 p_output <<
" MARK0001 'MARKER' 'INTORG'" << std::endl;
2358 for(i = 0; i < nCols(); i++)
2360 bool is_intvar = has_intvars && (p_intvars->
pos(i) >= 0);
2362 if((is_intrun && !is_intvar) || (!is_intrun && is_intvar))
2366 int colsize2 = (col.
size() / 2) * 2;
2368 assert(colsize2 % 2 == 0);
2370 for(k = 0; k < colsize2; k += 2)
2375 if(colsize2 != col.
size())
2384 p_output <<
" MARK0001 'MARKER' 'INTEND'" << std::endl;
2388 p_output <<
"RHS" << std::endl;
2397 for(; i < nRows(); i++)
2398 if((rhsval1 =
MPSgetRHS(lhs(i), rhs(i))) != 0)
2403 for(k = i + 1; k < nRows(); k++)
2405 if((rhsval2 =
MPSgetRHS(lhs(k), rhs(k))) != 0)
2424 p_output <<
"RANGES" << std::endl;
2426 for(i = 0; i < nRows(); i++)
2428 if((
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)))
2438 p_output <<
"BOUNDS" << std::endl;
2440 for(i = 0; i < nCols(); i++)
2445 if(col.
size() == 0 && maxObj(i) == 0)
2448 if(lower(i) == upper(i))
2454 if((
double(lower(i)) <=
double(-
infinity)) && (
double(upper(i)) >=
double(
infinity)))
2462 if(
double(lower(i)) > -
double(
infinity))
2468 if(has_intvars && (p_intvars->
pos(i) >= 0))
2477 if(
double(upper(i)) <
double(
infinity))
2483 p_output <<
"ENDATA" << std::endl;
2489 "XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n");
2501 SPxRowId dualRowIds[],
SPxColId dualColIds[],
int* nprimalrows,
int* nprimalcols,
int* ndualrows,
2505 MSG_ERROR(std::cerr <<
"Method buildDualProblem() not implemented for Rational\n");
const VectorBase< R > & rhs() const
Returns right hand side vector.
virtual void buildDualProblem(SPxLPBase< R > &dualLP, SPxRowId primalRowIds[]=0, SPxColId primalColIds[]=0, SPxRowId dualRowIds[]=0, SPxColId dualColIds[]=0, int *nprimalrows=0, int *nprimalcols=0, int *ndualrows=0, int *ndualcols=0)
Building the dual problem from a given LP.
Rational spxAbs(const Rational &r)
Absolute.
static int LPFreadColName(char *&pos, NameSet *colnames, LPColSetBase< Rational > &colset, const LPColBase< Rational > *emptycol, SPxOut *spxout)
Read the next column name from the input.
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
static bool LPFisValue(const char *s)
Is there a number at the beginning of s ?
void memRemax(int newmax)
Resets length of nonzero memory.
SPxRowId rId(int n) const
Returns the row identifier for row n.
static void MPSreadRows(MPSInput &mps, LPRowSetBase< Rational > &rset, NameSet &rnames, SPxOut *spxout)
Process ROWS section.
static Rational LPFreadInfinity(char *&pos)
const VectorBase< R > & lower() const
static bool LPFisFree(const char *s)
const VectorBase< R > & upper() const
Returns upper bound vector.
virtual R minAbsNzo(bool unscaled=true) const
Absolute smallest non-zero element in (possibly scaled) LP.
THREADLOCAL const Real infinity
static void MPSreadBounds(MPSInput &mps, LPColSetBase< Rational > &cset, const NameSet &cnames, DIdxSet *intvars, SPxOut *spxout)
Process BOUNDS section.
int num() const
returns nr. of names in NameSet.
static const char * MPSgetRowName(const SPxLPBase< Rational > &lp, int idx, const NameSet *rnames, char *buf)
const VectorBase< R > & lhs() const
Returns the vector of lhs values.
static void MPSreadRhs(MPSInput &mps, LPRowSetBase< Rational > &rset, const NameSet &rnames, SPxOut *spxout)
Process RHS section.
int size() const
Number of used indices.
Exception classes for SoPlex.
static void MPSreadObjsen(MPSInput &mps)
Process OBJSEN section. This Section is an ILOG extension.
static void MPSreadCols(MPSInput &mps, const LPRowSetBase< Rational > &rset, const NameSet &rnames, LPColSetBase< Rational > &cset, NameSet &cnames, DIdxSet *intvars, SPxOut *spxout)
Process COLUMNS section.
#define INIT_NZOS
initialy allocated non zeros.
static Rational LPFreadValue(char *&pos, SPxOut *spxout, const int lineno=-1)
Read the next number and advance pos.
void add(const LPColBase< R > &pcol)
R & value(int n)
Reference to value of n 'th nonzero.
Ids for LP columns.Class SPxColId provides DataKeys for the column indices of an SPxLP.
VectorBase< R > & lhs_w()
Returns the vector of lhs values.
virtual bool readMPS(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads an LP in MPS format from input stream in.
VectorBase< R > & maxObj_w()
Returns vector of objective values w.r.t. maximization.
void remove(int n, int m)
Remove nonzeros n thru m.
static const char * getColName(const SPxLP *lp, int idx, const NameSet *cnames, char *buf)
Wrapper for GMP type mpq_class.We wrap mpq_class so that we can replace it by a double type if GMP is...
VectorBase< R > & lower_w()
Returns vector of lower bound values.
void add(const LPRowBase< R > &row)
VectorBase< R > & upper_w()
Returns vector of upper bound values.
SPxColId cId(int n) const
Returns the column identifier for column n.
Saving LPs in a form suitable for SoPlex.
Entry identifier class for items of a DataSet.Every item in a DataSet is assigned a DataKey by which ...
#define MAX_LINE_WRITE_LEN
maximum length allowed for writing lines
static void LPFwriteRow(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const SVectorBase< Rational > &p_svec, const Rational &p_lhs, const Rational &p_rhs, SPxOut *spxout)
Wrapper for different output streams and verbosity levels.
int nRows() const
Returns number of rows in LP.
void add(const SVectorBase< S > &vec)
Append nonzeros of sv.
Exception class for out of memory exceptions.This class is derived from the SoPlex exception base cla...
void spx_alloc(T &p, int n=1)
Allocate memory.
static bool LPFhasRowName(char *&pos, NameSet *rownames)
If buf start with "name:" store the name in rownames and advance pos.
static void LPFwriteBounds(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, SPxOut *spxout)
virtual void computeDualActivity(const VectorBase< R > &dual, VectorBase< R > &activity, const bool unscaled=true) const
Computes "dual" activity of the columns for a given dual vector, i.e., y^T A; activity does not need ...
static bool LPFisSense(const char *s)
Is there a comparison operator at the beginning of s ?
int pos(int i) const
returns the position of index i.
SPxSense spxSense() const
Returns the optimization sense.
int & index(int n)
Reference to index of n 'th nonzero.
const VectorBase< R > & rhs() const
Returns the vector of rhs values.
int size() const
returns the number of used indices.
#define MSG_INFO2(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO2.
#define MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
bool readString(const char *s)
read Rational from string
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
void addIdx(int i)
adds index i to the index set
virtual bool readLPF(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0)
Reads LP in LP format from input stream in.
const VectorBase< R > & lhs() const
Returns left hand side vector.
static void LPFwriteSVector(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const SVectorBase< Rational > &p_svec, SPxOut *spxout)
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
void add(const char *str)
static void MPSreadRanges(MPSInput &mps, LPRowSetBase< Rational > &rset, const NameSet &rnames, SPxOut *spxout)
Process RANGES section.
#define NUM_ENTRIES_PER_LINE
(In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is...
void clear()
removes all names from NameSet.
#define INIT_COLS
Read LP in MPS File Format.
#define MSG_INFO3(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::INFO3.
Debugging, floating point type and parameter definitions.
Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i...
void setLhs(const R &p_left)
Sets left-hand side value.
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
int dim() const
Dimension of vector.
Everything should be within this namespace.
static void LPFwriteRows(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_rnames, const NameSet *p_cnames, SPxOut *spxout)
static void MPSreadObjname(MPSInput &mps)
Process OBJNAME section. This Section is an ILOG extension.
void clear()
Remove all indices.
virtual void writeLPF(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
void setObj(const R &p_object)
Sets objective value.
#define MSG_WARNING(spxout, x)
Prints out message x if the verbosity level is at least SPxOut::WARNING.
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
void setRowVector(const DSVectorBase< R > &p_vec)
access constraint row vector.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
virtual void writeMPS(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const
Writes a file in MPS format to out.
void clear()
Set vector to 0.
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
static int LPFreadSense(char *&pos)
Read the next <,>,=,==,<=,=<,>=,=> and advance pos.
static bool LPFisColName(const char *s)
Is there a possible column name at the beginning of s ?
static void LPFwriteObjective(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, SPxOut *spxout)
const VectorBase< R > & upper() const
static bool LPFhasKeyword(char *&pos, const char *keyword)
Is the keyword present in buf ? If yes, advance pos.
int pos(int i) const
Position of index i.
static Rational MPSgetRHS(Rational left, Rational right)
int nCols() const
Returns number of columns in LP.
#define LPF_MAX_LINE_LEN
maximum length of a line (8190 + \n + \0)
static bool LPFisSpace(int c)
Is c a space, tab, nl or cr ?
static void MPSwriteRecord(std::ostream &os, const char *indicator, const char *name, SPxOut *spxout, const char *name1=0, const Rational value1=0, const char *name2=0, const Rational value2=0)
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
void setColVector(const SVectorBase< R > &p_vec)
Sets constraint column vector.
static void LPFwriteGenerals(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const DIdxSet *p_intvars)
static const char * LPFgetRowName(const SPxLPBase< Rational > &p_lp, int p_idx, const NameSet *p_rnames, char *p_buf, int p_num_written_rows)
std::string rationalToString(const Rational &r, const int precision)
convert rational number to string
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
virtual void clear()
clears the LP.
int size() const
returns maximum DataKey::idx used in NameSet.
int number(const DataKey &pkey) const
returns number of name with DataKey pkey in NameSet.
void reMax(int newmax=0)
Reallocates memory to be able to store newmax LPColBases.
void setRhs(const R &p_right)
Sets right-hand side value.
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
virtual R maxAbsNzo(bool unscaled=true) const
Absolute biggest non-zero element in (in rational case possibly scaled) LP.
int num() const
Returns the number of LPColBases currently in LPColSetBase.
virtual void computePrimalActivity(const VectorBase< R > &primal, VectorBase< R > &activity, const bool unscaled=true) const
Computes activity of the rows for a given primal vector; activity does not need to be zero...
LP column.Class LPColBase provides a datatype for storing the column of an LP a the form similar to ...
void spx_free(T &p)
Release memory.
bool has(int pnum) const
does NameSet has a name with number pnum?
int num() const
Returns the number of LPRowBases in LPRowSetBase.
static void MPSreadName(MPSInput &mps, SPxOut *spxout)
Process NAME section.
static bool LPFisInfinity(const char *s)