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 162 assert(LPFisValue(pos));
168 bool has_digits =
false;
169 bool has_emptyexponent =
false;
170 bool has_dot =
false;
171 bool has_exponent =
false;
172 bool has_emptydivisor =
false;
175 if((*s ==
'+') || (*s ==
'-'))
179 while((*s >=
'0') && (*s <=
'9'))
192 while((*s >=
'0') && (*s <=
'9'))
200 if(tolower(*s) ==
'e')
203 has_emptyexponent =
true;
207 if((*s ==
'+') || (*s ==
'-'))
211 while((*s >=
'0') && (*s <=
'9'))
213 has_emptyexponent =
false;
222 has_emptydivisor =
true;
224 while((*s >=
'0') && (*s <=
'9'))
226 has_emptydivisor =
false;
230 if(has_dot || has_exponent || has_emptydivisor ||
231 (*s ==
'.') || (*s ==
'+') || (*s ==
'-') || (tolower(*s) ==
'e'))
233 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD03 Warning: In line " << lineno <<
234 ": malformed rational value in LP file\n";)
241 if(has_emptyexponent)
243 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD01 Warning: In line " << lineno <<
244 ": found empty exponent in LP file - check for forbidden variable names with initial 'e' or 'E'\n");
248 value = (*pos ==
'-') ? -1 : 1;
251 for(t = tmp; pos != s; pos++)
258 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD04 Warning: In line " << lineno <<
259 ": malformed rational value in LP file\n");
267 MSG_DEBUG(std::cout <<
"DLPFRD01 LPFreadValue = " << value << std::endl;)
285 assert(LPFisColName(pos));
286 assert(colnames != 0);
294 while((strchr(
"+-.<>= ", *s) == 0) && (*s !=
'\0'))
297 for(i = 0; pos != s; i++, pos++)
302 if((colidx = colnames->
number(name)) < 0)
306 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD02 Unknown variable \"" << name <<
"\" ";)
309 colidx = colnames->
num();
311 colset.
add(*emptycol);
315 MSG_DEBUG(std::cout <<
"DLPFRD03 LPFreadColName [" << name <<
"] = " << colidx << std::endl;)
325 assert(LPFisInfinity(pos));
327 Rational sense = (*pos ==
'-') ? -1 : 1;
329 (void) LPFhasKeyword(++pos,
"inf[inity]");
356 std::istream& p_input,
363 START, OBJECTIVE, CONSTRAINTS, BOUNDS, INTEGERS, BINARIES
384 bool finished =
false;
386 bool have_value =
true;
399 cnames =
new(cnames)
NameSet();
412 rnames =
new(rnames)
NameSet();
436 if(!p_input.getline(buf,
sizeof(buf)))
441 <<
" characters" << std::endl;)
445 MSG_ERROR(std::cerr <<
"ELPFRD07 No 'End' marker found" << std::endl;)
456 MSG_DEBUG(std::cout <<
"DLPFRD08 Reading line " << lineno
457 <<
" (pos=" << pos <<
")" << std::endl;)
460 if(0 != (s = strchr(buf,
'\\')))
466 if(LPFhasKeyword(pos,
"max[imize]"))
471 else if(LPFhasKeyword(pos,
"min[imize]"))
477 else if(section == OBJECTIVE)
479 if(LPFhasKeyword(pos,
"s[ubject][ ]t[o]")
480 || LPFhasKeyword(pos,
"s[uch][ ]t[hat]")
481 || LPFhasKeyword(pos,
"s[.][ ]t[.]")
482 || LPFhasKeyword(pos,
"lazy con[straints]"))
485 for(
int j = vec.
size() - 1; j >= 0; --j)
492 section = CONSTRAINTS;
495 else if(section == CONSTRAINTS &&
496 (LPFhasKeyword(pos,
"s[ubject][ ]t[o]")
497 || LPFhasKeyword(pos,
"s[uch][ ]t[hat]")
498 || LPFhasKeyword(pos,
"s[.][ ]t[.]")))
505 if(LPFhasKeyword(pos,
"lazy con[straints]"))
507 else if(LPFhasKeyword(pos,
"bound[s]"))
509 else if(LPFhasKeyword(pos,
"bin[ary]"))
511 else if(LPFhasKeyword(pos,
"bin[aries]"))
513 else if(LPFhasKeyword(pos,
"gen[erals]"))
515 else if(LPFhasKeyword(pos,
"int[egers]"))
517 else if(LPFhasKeyword(pos,
"end"))
522 else if(LPFhasKeyword(pos,
"s[ubject][ ]t[o]")
523 || LPFhasKeyword(pos,
"s[uch][ ]t[hat]")
524 || LPFhasKeyword(pos,
"s[.][ ]t[.]")
525 || LPFhasKeyword(pos,
"lazy con[straints]"))
538 if(section == OBJECTIVE)
539 LPFhasRowName(pos, 0);
542 if(section == CONSTRAINTS)
543 if(LPFhasRowName(pos, rnames))
547 while(LPFisSpace(pos[i]))
551 for(k = 0; pos[i] !=
'\0'; i++)
552 if(!LPFisSpace(pos[i]) || LPFisColName(&pos[i + 1]))
562 for(i = 0, k = 0; tmp[i] !=
'\0'; i++)
564 while(((tmp[i] ==
'+') || (tmp[i] ==
'-')) && ((tmp[i + 1] ==
'+') || (tmp[i + 1] ==
'-')))
567 tmp[i] = (tmp[i] ==
'-') ?
'+' :
'-';
580 MSG_DEBUG(std::cout <<
"DLPFRD09 pos=" << pos << std::endl;)
583 while((pos != 0) && (*pos !=
'\0'))
616 if(!have_value || !LPFisColName(pos))
621 vec.
add(colidx, val);
652 else if(sense ==
'>')
659 assert(sense ==
'=');
692 if(LPFisColName(pos))
699 int n = vec.
pos(colidx);
703 vec.
add(colidx, val);
707 assert(vec.
index(n) == colidx);
716 assert(cnames->
has(colidx));
718 MSG_WARNING((*this->spxout), (*this->spxout) <<
"WLPFRD10 Duplicate index " 720 <<
" in line " << lineno
744 sense = LPFreadSense(pos);
759 sense = LPFreadSense(pos);
763 if(!LPFisColName(pos))
768 MSG_WARNING((*this->spxout), (*this->spxout) <<
"WLPFRD11 in Bounds section line " 769 << lineno <<
" ignored" << std::endl;)
778 else if(sense ==
'>')
782 assert(sense ==
'=');
795 else if(LPFisSense(pos))
797 sense = LPFreadSense(pos);
807 else if(sense ==
'>')
811 assert(sense ==
'=');
829 MSG_WARNING((*this->spxout), (*this->spxout) <<
"WLPFRD12 in Binary/General section line " << lineno
830 <<
" ignored" << std::endl;)
834 if(section == BINARIES)
836 if(cset.
lower(colidx) < 0)
841 if(cset.
upper(colidx) > 1)
848 p_intvars->
addIdx(colidx);
854 MSG_ERROR(std::cerr <<
"ELPFRD13 This seems to be no LP format file" << std::endl;)
866 assert(isConsistent());
869 assert(isConsistent());
872 assert(isConsistent());
878 MSG_INFO2((*this->spxout), (*this->spxout) <<
"Finished reading " << lineno <<
" lines" <<
882 MSG_ERROR(std::cerr <<
"ELPFRD15 Syntax error in line " << lineno << std::endl;)
903 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD02 Objective name : " << mps.
objName() << std::endl;)
905 if(strcmp(mps.
field0(),
"COLUMNS"))
975 if(strcmp(mps.
field0(),
"RHS"))
978 if(colname[0] !=
'\0')
993 if(strcmp(colname, mps.
field1()))
996 if(colname[0] !=
'\0')
998 col.setColVector(vec);
1006 int ncnames = cnames.
size();
1007 cnames.
add(colname);
1010 if(cnames.
size() <= ncnames)
1012 MSG_ERROR(std::cerr <<
"ERROR in COLUMNS: duplicate column name or not column-wise ordering" <<
1024 assert(cnames.
number(colname) == cset.
num());
1036 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD01 Warning: malformed rational value in MPS file\n");
1052 assert(mps.
field4() != 0);
1056 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD02 Warning: malformed rational value in MPS file\n");
1089 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD03 RHS name : " << rhsname << std::endl;);
1091 if(!strcmp(mps.
field0(),
"RANGES"))
1093 else if(!strcmp(mps.
field0(),
"BOUNDS"))
1095 else if(!strcmp(mps.
field0(),
"ENDATA"))
1109 if(*rhsname ==
'\0')
1112 if(strcmp(rhsname, mps.
field1()))
1114 if(strcmp(addname, mps.
field1()))
1118 MSG_INFO3((*spxout), (*spxout) <<
"IMPSRD07 RHS ignored : " << addname << std::endl);
1129 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD03 Warning: malformed rational value in MPS file\n");
1134 rset.
rhs_w(idx) = val;
1138 rset.
lhs_w(idx) = val;
1149 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD04 Warning: malformed rational value in MPS file\n");
1154 rset.
rhs_w(idx) = val;
1158 rset.
lhs_w(idx) = val;
1181 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD04 Range name : " << rngname << std::endl;);
1183 if(!strcmp(mps.
field0(),
"BOUNDS"))
1185 else if(!strcmp(mps.
field0(),
"ENDATA"))
1199 if(*rngname ==
'\0')
1214 if(!strcmp(rngname, mps.
field1()))
1222 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD05 Warning: malformed rational value in MPS file\n");
1228 assert(rset.
lhs(idx) == rset.
rhs(idx));
1230 if(
double(val) >= 0)
1231 rset.
rhs_w(idx) += val;
1233 rset.
lhs_w(idx) += val;
1260 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD06 Warning: malformed rational value in MPS file\n");
1266 assert(rset.
lhs(idx) == rset.
rhs(idx));
1268 if(
double(val) >= 0)
1269 rset.
rhs_w(idx) += val;
1271 rset.
lhs_w(idx) += val;
1311 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD05 Bound name : " << bndname << std::endl;)
1313 if(strcmp(mps.
field0(),
"ENDATA"))
1322 if((!strcmp(mps.
field1(),
"LO"))
1323 || (!strcmp(mps.
field1(),
"UP"))
1324 || (!strcmp(mps.
field1(),
"FX"))
1325 || (!strcmp(mps.
field1(),
"LI"))
1326 || (!strcmp(mps.
field1(),
"UI")))
1340 if(*bndname ==
'\0')
1347 if(!strcmp(bndname, mps.
field2()))
1355 else if(!strcmp(mps.
field4(),
"-Inf") || !strcmp(mps.
field4(),
"-inf"))
1357 else if(!strcmp(mps.
field4(),
"Inf") || !strcmp(mps.
field4(),
"inf")
1358 || !strcmp(mps.
field4(),
"+Inf") || !strcmp(mps.
field4(),
"+inf"))
1362 MSG_WARNING((*spxout), (*spxout) <<
"WMPSRD07 Warning: malformed rational value in MPS file line " 1369 if(mps.
field1()[1] ==
'I')
1376 if(oldbinvars.
pos(idx) < 0)
1394 if(mps.
field1()[1] ==
'X')
1449 #define INIT_COLS 1000 1450 #define INIT_NZOS 5000
1453 std::istream& p_input,
1469 cnames =
new(cnames)
NameSet();
1482 rnames =
new(rnames)
NameSet();
1505 MPSreadName(mps, spxout);
1511 MPSreadObjname(mps);
1516 addedRows(rset.
num());
1519 MPSreadCols(mps, rset, *rnames, cset, *cnames, p_intvars, spxout);
1540 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD06 Objective sense: " << ((mps.
objSense() ==
1547 addedCols(cset.
num());
1549 assert(isConsistent());
1579 int p_num_written_rows
1584 assert(p_idx < p_lp.
nRows());
1590 if(p_rnames->
has(key))
1591 return (*p_rnames)[key];
1594 spxSnprintf(p_buf, 16,
"C%d", p_num_written_rows);
1611 assert(p_idx < p_lp.
nCols());
1617 if(p_cnames->
has(key))
1618 return (*p_cnames)[key];
1629 #define NUM_ENTRIES_PER_LINE 5 1632 std::ostream& p_output,
1643 pos = p_output.tellp();
1645 for(
int j = 0; j < p_lp.
nCols(); ++j)
1653 p_output << coeff <<
" " <<
getColName(p_lp, j, p_cnames, name);
1667 "XLPSWR01 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n");
1670 pos = p_output.tellp();
1674 p_output <<
" - " << -coeff;
1676 p_output <<
" + " << coeff;
1678 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name);
1690 std::ostream& p_output,
1698 p_output << ((sense == SPxLPBase<Rational>::MINIMIZE) ?
"Minimize\n" :
"Maximize\n");
1699 p_output <<
" obj: ";
1703 svec.operator = (obj);
1714 std::ostream& p_output,
1724 pos = p_output.tellp();
1729 sidelen = (p_lhs == p_rhs
1734 if((
long long)(p_output.tellp()) - pos + sidelen + (
long long)100 >
MAX_LINE_WRITE_LEN)
1741 "XLPSWR02 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n");
1744 pos = p_output.tellp();
1749 p_output <<
" = " << p_rhs;
1750 else if(
double(p_lhs) <=
double(-
infinity))
1751 p_output <<
" <= " << p_rhs;
1754 assert(
double(p_rhs) >=
double(
infinity));
1755 p_output <<
" >= " << p_lhs;
1763 "XLPSWR03 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n");
1772 std::ostream& p_output,
1781 p_output <<
"Subject To\n";
1783 for(
int i = 0; i < p_lp.
nRows(); ++i)
1788 if(
double(lhs) > -
double(
infinity) &&
double(rhs) <
double(
infinity) && lhs != rhs)
1791 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_1 : ";
1794 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_2 : ";
1799 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
" : ";
1811 std::ostream& p_output,
1820 pos = p_output.tellp();
1822 p_output <<
"Bounds\n";
1824 for(
int j = 0; j < p_lp.
nCols(); ++j)
1831 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
" = " << upper <<
'\n';
1833 else if(
double(lower) > -
double(
infinity))
1835 if(
double(upper) <
double(
infinity))
1839 p_output <<
" " << lower <<
" <= " 1841 <<
" <= " << upper <<
'\n';
1843 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
1844 <<
" <= " << upper <<
'\n';
1847 p_output <<
" " << lower <<
" <= " 1851 else if(
double(upper) <
double(
infinity))
1852 p_output <<
" -Inf <= " 1854 <<
" <= " << upper <<
'\n';
1856 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
1863 "XLPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing LP file\n");
1866 pos = p_output.tellp();
1875 std::ostream& p_output,
1883 if(p_intvars == NULL || p_intvars->
size() <= 0)
1886 p_output <<
"Generals\n";
1888 for(
int j = 0; j < p_lp.
nCols(); ++j)
1889 if(p_intvars->
pos(j) >= 0)
1890 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
"\n";
1898 std::ostream& p_output,
1906 LPFwriteRows(*
this, p_output, p_rnames, p_cnames, spxout);
1910 p_output <<
"End" << std::endl;
1922 const char* indicator,
1925 const char* name1 =
nullptr,
1927 const char* name2 =
nullptr,
1935 spxSnprintf(buf,
sizeof(buf),
" %-2.2s %-8.8s", (indicator == 0) ?
"" : indicator,
1936 (name == 0) ?
"" : name);
1939 if(name1 !=
nullptr)
1942 os << buf << value1;
1947 os << buf << value2;
1957 "XMPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing MPS file\n");
1967 if(
double(left) > -
double(
infinity))
1969 else if(
double(right) <
double(
infinity))
1988 assert(idx < lp.
nRows());
1994 if(rnames->
has(key))
1995 return (*rnames)[key];
2010 std::ostream& p_output,
2017 const char* indicator;
2021 bool has_ranges =
false;
2026 p_output <<
"NAME MPSDATA" << std::endl;
2029 p_output <<
"ROWS" << std::endl;
2031 for(i = 0; i < nRows(); i++)
2033 if(lhs(i) == rhs(i))
2035 else if((
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)))
2040 else if(
double(lhs(i)) > -
double(
infinity))
2042 else if(
double(rhs(i)) <
double(
infinity))
2053 p_output <<
"COLUMNS" << std::endl;
2055 bool has_intvars = (p_intvars != 0) && (p_intvars->
size() > 0);
2057 for(
int j = 0; j < (has_intvars ? 2 : 1); j++)
2059 bool is_intrun = has_intvars && (j == 1);
2062 p_output <<
" MARK0001 'MARKER' 'INTORG'" << std::endl;
2064 for(i = 0; i < nCols(); i++)
2066 bool is_intvar = has_intvars && (p_intvars->
pos(i) >= 0);
2068 if((is_intrun && !is_intvar) || (!is_intrun && is_intvar))
2072 int colsize2 = (col.
size() / 2) * 2;
2074 assert(colsize2 % 2 == 0);
2076 for(k = 0; k < colsize2; k += 2)
2081 if(colsize2 != col.
size())
2090 p_output <<
" MARK0001 'MARKER' 'INTEND'" << std::endl;
2094 p_output <<
"RHS" << std::endl;
2103 for(; i < nRows(); i++)
2104 if((rhsval1 =
MPSgetRHS(lhs(i), rhs(i))) != 0)
2109 for(k = i + 1; k < nRows(); k++)
2111 if((rhsval2 =
MPSgetRHS(lhs(k), rhs(k))) != 0)
2130 p_output <<
"RANGES" << std::endl;
2132 for(i = 0; i < nRows(); i++)
2134 if((
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)))
2144 p_output <<
"BOUNDS" << std::endl;
2146 for(i = 0; i < nCols(); i++)
2151 if(col.
size() == 0 && maxObj(i) == 0)
2154 if(lower(i) == upper(i))
2160 if((
double(lower(i)) <=
double(-
infinity)) && (
double(upper(i)) >=
double(
infinity)))
2168 if(
double(lower(i)) > -
double(
infinity))
2174 if(has_intvars && (p_intvars->
pos(i) >= 0))
2183 if(
double(upper(i)) <
double(
infinity))
2189 p_output <<
"ENDATA" << std::endl;
2195 "XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n");
2207 SPxRowId dualRowIds[],
SPxColId dualColIds[],
int* nprimalrows,
int* nprimalcols,
int* ndualrows,
2211 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...
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
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 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.
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 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 ...
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)
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.
static const char * getColName(const SPxLPBase< Rational > &p_lp, int p_idx, const NameSet *p_cnames, char *p_buf)
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 contain all-zeros (keeping the same length)
Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations...
static void LPFwriteObjective(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, SPxOut *spxout)
const VectorBase< R > & upper() const
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)
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 MPSwriteRecord(std::ostream &os, const char *indicator, const char *name, SPxOut *spxout, const char *name1=nullptr, const Rational value1=0, const char *name2=nullptr, const Rational value2=0)