32 #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));
78 if( dual.
dim() != nRows() )
83 if( activity.
dim() != nCols() )
90 for( r = 0; r < nRows() && dual[r] == 0; r++ )
99 activity = rowVector(r);
104 for( ; r < nRows(); r++ )
108 activity.
multAdd(dual[r], rowVector(r));
118 for(
int i = 0; i < nCols(); ++i )
136 for(
int i = 0; i < nCols(); ++i )
153 #define LPF_MAX_LINE_LEN 8192 158 return (c ==
' ') || (c ==
'\t') || (c ==
'\n') || (c ==
'\r');
166 return ((*s >=
'0') && (*s <=
'9')) || (*s ==
'+') || (*s ==
'-') || (*s ==
'.');
178 return ((*s >=
'A') && (*s <=
'Z'))
179 || ((*s >=
'a') && (*s <=
'z'))
180 || (strchr(
"!\"#$%&()/,;?@_'`{}|~", *s) != 0);
188 return (*s ==
'<') || (*s ==
'>') || (*s ==
'=');
195 return ((s[0] ==
'-') || (s[0] ==
'+'))
196 && (tolower(s[1]) ==
'i')
197 && (tolower(s[2]) ==
'n')
198 && (tolower(s[3]) ==
'f');
205 return (tolower(s[0]) ==
'f')
206 && ( tolower(s[1]) ==
'r')
207 && ( tolower(s[2]) ==
'e')
208 && ( tolower(s[3]) ==
'e');
225 bool has_digits =
false;
226 bool has_emptyexponent =
false;
227 bool has_dot =
false;
228 bool has_exponent =
false;
229 bool has_emptydivisor =
false;
232 if( (*s ==
'+') || (*s ==
'-') )
236 while( (*s >=
'0') && (*s <=
'9') )
249 while( (*s >=
'0') && (*s <=
'9') )
257 if( tolower(*s) ==
'e' )
260 has_emptyexponent =
true;
264 if( (*s ==
'+') || (*s ==
'-') )
268 while( (*s >=
'0') && (*s <=
'9') )
270 has_emptyexponent =
false;
279 has_emptydivisor =
true;
280 while( (*s >=
'0') && (*s <=
'9') )
282 has_emptydivisor =
false;
285 if( has_dot || has_exponent || has_emptydivisor ||
286 (*s ==
'.') ||(*s ==
'+') || (*s ==
'-') || (tolower(*s) ==
'e') )
288 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD03 Warning: In line " << lineno <<
": malformed rational value in LP file\n";)
295 if( has_emptyexponent )
297 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD01 Warning: In line " << lineno <<
": found empty exponent in LP file - check for forbidden variable names with initial 'e' or 'E'\n" );
301 value = (*pos ==
'-') ? -1 : 1;
304 for( t = tmp; pos != s; pos++ )
310 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD04 Warning: In line " << lineno <<
": malformed rational value in LP file\n" );
317 MSG_DEBUG( std::cout <<
"DLPFRD01 LPFreadValue = " << value << std::endl; )
335 assert(colnames != 0);
343 while( (strchr(
"+-.<>= ", *s) == 0) && (*s !=
'\0') )
346 for( i = 0; pos != s; i++, pos++ )
351 if( (colidx = colnames->
number(name)) < 0 )
355 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD02 Unknown variable \"" << name <<
"\" "; )
358 colidx = colnames->
num();
360 colset.
add(*emptycol);
364 MSG_DEBUG( std::cout <<
"DLPFRD03 LPFreadColName [" << name <<
"] = " << colidx << std::endl; )
381 if( (*pos ==
'<') || (*pos ==
'>') )
383 else if( *pos ==
'=' )
386 MSG_DEBUG( std::cout <<
"DLPFRD04 LPFreadSense = " << static_cast<char>(sense) << std::endl; )
404 assert(keyword != 0);
406 for( i = 0, k = 0; keyword[i] !=
'\0'; i++, k++ )
408 if( keyword[i] ==
'[' )
413 while( (tolower(pos[k]) == keyword[i]) && (pos[k] !=
'\0') )
418 while( keyword[i] !=
']' )
424 if( keyword[i] != tolower(pos[k]) )
435 MSG_DEBUG( std::cout <<
"DLPFRD05 LPFhasKeyword: " << keyword << std::endl; )
448 const char* s = strchr(pos,
':');
453 int dcolpos = int(s - pos);
459 for( end = dcolpos-1; end >= 0; end-- )
466 pos = &(pos[dcolpos+1]);
471 for( srt = end-1; srt >= 0; srt-- )
472 if( pos[srt] ==
' ' )
478 assert(srt <= end && pos[srt] !=
' ');
484 for( i = srt; i <= end; i++ )
492 pos = &(pos[dcolpos+1]);
503 Rational sense = (*pos ==
'-') ? -1 : 1;
532 std::istream& p_input,
539 START, OBJECTIVE, CONSTRAINTS, BOUNDS, INTEGERS, BINARIES
560 bool finished =
false;
562 bool have_value =
true;
575 cnames =
new (cnames)
NameSet();
588 rnames =
new (rnames)
NameSet();
611 if( !p_input.getline(buf,
sizeof(buf)) )
616 <<
" characters" << std::endl; )
620 MSG_ERROR( std::cerr <<
"ELPFRD07 No 'End' marker found" << std::endl; )
629 MSG_DEBUG( std::cout <<
"DLPFRD08 Reading line " << lineno
630 <<
" (pos=" << pos <<
")" << std::endl; )
633 if( 0 != (s = strchr(buf,
'\\')) )
637 if( section == START )
650 else if( section == OBJECTIVE )
658 for(
int j = vec.
size() - 1; j >= 0; --j )
664 section = CONSTRAINTS;
667 else if( section == CONSTRAINTS &&
710 if( section == OBJECTIVE )
714 if( section == CONSTRAINTS )
723 for( k = 0; pos[i] !=
'\0'; i++ )
734 for( i = 0, k = 0; tmp[i] !=
'\0'; i++ )
736 while( ((tmp[i] ==
'+') || (tmp[i] ==
'-')) && ((tmp[i + 1] ==
'+') || (tmp[i + 1] ==
'-')) )
738 if( tmp[i++] ==
'-' )
739 tmp[i] = (tmp[i] ==
'-') ?
'+' :
'-';
750 MSG_DEBUG( std::cout <<
"DLPFRD09 pos=" << pos << std::endl; )
753 while( (pos != 0) && (*pos !=
'\0') )
789 vec.
add(colidx, val);
819 else if( sense ==
'>' )
826 assert(sense ==
'=');
840 sprintf(name,
"C%d", rset.
num());
863 int n = vec.
pos(colidx);
867 vec.
add(colidx, val);
871 assert(vec.
index(n) == colidx);
880 assert(cnames->
has(colidx));
882 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD10 Duplicate index " 884 <<
" in line " << lineno
928 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD11 in Bounds section line " 929 << lineno <<
" ignored" << std::endl; )
938 else if( sense ==
'>' )
942 assert(sense ==
'=');
967 else if( sense ==
'>' )
971 assert(sense ==
'=');
987 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD12 in Binary/General section line " << lineno <<
" ignored" << std::endl; )
991 if( section == BINARIES )
993 if( cset.
lower(colidx) < 0 )
997 if( cset.
upper(colidx) > 1 )
1003 if( p_intvars != 0 )
1004 p_intvars->
addIdx(colidx);
1008 MSG_ERROR( std::cerr <<
"ELPFRD13 This seems to be no LP format file" << std::endl; )
1014 if( pos == pos_old )
1019 assert(isConsistent());
1022 assert(isConsistent());
1025 assert(isConsistent());
1030 MSG_INFO2( (*spxout), (*spxout) <<
"Finished reading " << lineno <<
" lines" << std::endl; )
1033 MSG_ERROR( std::cerr <<
"ELPFRD15 Syntax error in line " << lineno << std::endl; )
1061 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD01 Problem name : " << mps.
probName() << std::endl; )
1067 if( !strcmp(mps.
field0(),
"ROWS") )
1069 else if( !strncmp(mps.
field0(),
"OBJSEN", 6) )
1071 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1094 if( !strcmp(mps.
field1(),
"MIN") )
1096 else if( !strcmp(mps.
field1(),
"MAX") )
1105 if( !strcmp(mps.
field0(),
"ROWS") )
1107 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1136 if( strcmp(mps.
field0(),
"ROWS") )
1159 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD02 Objective name : " << mps.
objName() << std::endl; )
1161 if( strcmp(mps.
field0(),
"COLUMNS") )
1169 if( *mps.
field1() ==
'N' )
1227 if( strcmp(mps.
field0(),
"RHS") )
1230 if( colname[0] !=
'\0' )
1245 if( strcmp(colname, mps.
field1()) )
1248 if( colname[0] !=
'\0' )
1250 col.setColVector(vec);
1257 cnames.
add(colname);
1265 assert(cnames.
number(colname) == cset.
num());
1277 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD01 Warning: malformed rational value in MPS file\n" );
1293 assert(mps.
field4() != 0);
1297 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD02 Warning: malformed rational value in MPS file\n" );
1329 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD03 RHS name : " << rhsname << std::endl; );
1331 if( !strcmp(mps.
field0(),
"RANGES") )
1333 else if( !strcmp(mps.
field0(),
"BOUNDS") )
1335 else if( !strcmp(mps.
field0(),
"ENDATA") )
1349 if( *rhsname ==
'\0' )
1350 strcpy(rhsname, mps.
field1());
1352 if( strcmp(rhsname, mps.
field1()) )
1354 if( strcmp(addname, mps.
field1()) )
1357 strcpy(addname, mps.
field1());
1358 MSG_INFO3( (*spxout), (*spxout) <<
"IMPSRD07 RHS ignored : " << addname << std::endl );
1369 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD03 Warning: malformed rational value in MPS file\n" );
1374 rset.
rhs_w(idx) = val;
1377 rset.
lhs_w(idx) = val;
1388 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD04 Warning: malformed rational value in MPS file\n" );
1393 rset.
rhs_w(idx) = val;
1396 rset.
lhs_w(idx) = val;
1418 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD04 Range name : " << rngname << std::endl; );
1420 if( !strcmp(mps.
field0(),
"BOUNDS") )
1422 else if( !strcmp(mps.
field0(),
"ENDATA") )
1436 if( *rngname ==
'\0' )
1439 strcpy(rngname, mps.
field1());
1451 if( !strcmp(rngname, mps.
field1()) )
1459 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD05 Warning: malformed rational value in MPS file\n" );
1465 assert(rset.
lhs(idx) == rset.
rhs(idx));
1467 if(
double(val) >= 0 )
1468 rset.
rhs_w(idx) += val;
1470 rset.
lhs_w(idx) += val;
1497 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD06 Warning: malformed rational value in MPS file\n" );
1503 assert(rset.
lhs(idx) == rset.
rhs(idx));
1505 if(
double(val) >= 0 )
1506 rset.
rhs_w(idx) += val;
1508 rset.
lhs_w(idx) += val;
1547 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD05 Bound name : " << bndname << std::endl; )
1549 if( strcmp(mps.
field0(),
"ENDATA") )
1558 if( (!strcmp(mps.
field1(),
"LO"))
1559 || (!strcmp(mps.
field1(),
"UP"))
1560 || (!strcmp(mps.
field1(),
"FX"))
1561 || (!strcmp(mps.
field1(),
"LI"))
1562 || (!strcmp(mps.
field1(),
"UI")) )
1576 if( *bndname ==
'\0' )
1579 strcpy(bndname, mps.
field2());
1583 if( !strcmp(bndname, mps.
field2()) )
1591 else if( !strcmp(mps.
field4(),
"-Inf") || !strcmp(mps.
field4(),
"-inf") )
1593 else if( !strcmp(mps.
field4(),
"Inf") || !strcmp(mps.
field4(),
"inf") || !strcmp(mps.
field4(),
"+Inf") || !strcmp(mps.
field4(),
"+inf") )
1597 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD07 Warning: malformed rational value in MPS file line " << mps.
lineno() <<
": " << mps.
field4() <<
"\n" );
1603 if( mps.
field1()[1] ==
'I' )
1610 if( oldbinvars.
pos(idx) < 0 )
1626 if( mps.
field1()[1] ==
'X' )
1675 #define INIT_COLS 1000 1676 #define INIT_NZOS 5000
1679 std::istream& p_input,
1695 cnames =
new (cnames)
NameSet();
1708 rnames =
new (rnames)
NameSet();
1741 addedRows(rset.
num());
1744 MPSreadCols(mps, rset, *rnames, cset, *cnames, p_intvars, spxout);
1770 addedCols(cset.
num());
1772 assert(isConsistent());
1802 int p_num_written_rows
1807 assert(p_idx < p_lp.
nRows());
1813 if( p_rnames->
has(key) )
1814 return (*p_rnames)[key];
1817 sprintf(p_buf,
"C%d", p_num_written_rows);
1834 assert(p_idx < p_lp.
nCols());
1840 if( p_cnames->
has(key) )
1841 return (*p_cnames)[key];
1844 sprintf(p_buf,
"x%d", p_idx);
1852 #define NUM_ENTRIES_PER_LINE 5 1855 std::ostream& p_output,
1866 pos = p_output.tellp();
1868 for(
int j = 0; j < p_lp.
nCols(); ++j )
1875 if( num_coeffs == 0 )
1876 p_output << coeff <<
" " <<
getColName(p_lp, j, p_cnames, name);
1887 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR01 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" );
1889 pos = p_output.tellp();
1893 p_output <<
" - " << -coeff;
1895 p_output <<
" + " << coeff;
1897 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name);
1909 std::ostream& p_output,
1917 p_output << ((sense == SPxLPBase<Rational>::MINIMIZE) ?
"Minimize\n" :
"Maximize\n");
1918 p_output <<
" obj: ";
1922 svec.operator=(obj);
1933 std::ostream& p_output,
1943 pos = p_output.tellp();
1951 if( (
long long)(p_output.tellp()) - pos + sidelen + (
long long)100 >
MAX_LINE_WRITE_LEN )
1956 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR02 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" );
1958 pos = p_output.tellp();
1962 if( p_lhs == p_rhs )
1963 p_output <<
" = " << p_rhs;
1964 else if(
double(p_lhs) <=
double(-
infinity) )
1965 p_output <<
" <= " << p_rhs;
1968 assert(
double(p_rhs) >=
double(
infinity));
1969 p_output <<
" >= " << p_lhs;
1976 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR03 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" );
1985 std::ostream& p_output,
1994 p_output <<
"Subject To\n";
1996 int num_written_rows = 0;
1997 for(
int i = 0; i < p_lp.
nRows(); ++i )
2002 if(
double(lhs) > -
double(
infinity) &&
double(rhs) <
double(
infinity) && lhs != rhs )
2005 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, ++num_written_rows) <<
"_1 : ";
2008 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, ++num_written_rows) <<
"_2 : ";
2013 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, ++num_written_rows) <<
" : ";
2025 std::ostream& p_output,
2034 pos = p_output.tellp();
2036 p_output <<
"Bounds\n";
2038 for(
int j = 0; j < p_lp.
nCols(); ++j )
2043 if( lower == upper )
2045 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
" = " << upper <<
'\n';
2047 else if(
double(lower) > -
double(
infinity) )
2049 if(
double(upper) <
double(
infinity) )
2053 p_output <<
" " << lower <<
" <= " 2055 <<
" <= " << upper <<
'\n';
2057 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2058 <<
" <= " << upper <<
'\n';
2060 else if( lower != 0 )
2061 p_output <<
" " << lower <<
" <= " 2065 else if(
double(upper) <
double(
infinity) )
2066 p_output <<
" -Inf <= " 2068 <<
" <= " << upper <<
'\n';
2070 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2076 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing LP file\n" );
2078 pos = p_output.tellp();
2087 std::ostream& p_output,
2095 if( p_intvars == NULL || p_intvars->
size() <= 0 )
2098 p_output <<
"Generals\n";
2100 for(
int j = 0; j < p_lp.
nCols(); ++j )
2101 if( p_intvars->
pos(j) >= 0 )
2102 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
"\n";
2110 std::ostream& p_output,
2118 LPFwriteRows(*
this, p_output, p_rnames, p_cnames, spxout);
2122 p_output <<
"End" << std::endl;
2134 const char* indicator,
2137 const char* name1 = 0,
2139 const char* name2 = 0,
2146 sprintf(buf,
" %-2.2s %-8.8s", (indicator == 0) ?
"" : indicator, (name == 0) ?
"" : name);
2151 sprintf(buf,
" %-8.8s ", name1);
2152 os << buf << value1;
2155 sprintf(buf,
" %-8.8s ", name2);
2156 os << buf << value2;
2164 MSG_WARNING( (*spxout), (*spxout) <<
"XMPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing MPS file\n" );
2174 if(
double(left) > -
double(
infinity) )
2176 else if(
double(right) <
double(
infinity) )
2195 assert(idx < lp.
nRows());
2201 if( rnames->
has(key) )
2202 return (*rnames)[key];
2205 sprintf(buf,
"C%d", idx);
2217 std::ostream& p_output,
2224 const char* indicator;
2228 bool has_ranges =
false;
2233 p_output <<
"NAME MPSDATA" << std::endl;
2236 p_output <<
"ROWS" << std::endl;
2238 for( i = 0; i < nRows(); i++ )
2240 if( lhs(i) == rhs(i) )
2242 else if( (
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)) )
2247 else if(
double(lhs(i)) > -
double(
infinity) )
2249 else if(
double(rhs(i)) <
double(
infinity) )
2260 p_output <<
"COLUMNS" << std::endl;
2262 bool has_intvars = (p_intvars != 0) && (p_intvars->
size() > 0);
2264 for(
int j = 0; j < (has_intvars ? 2 : 1); j++ )
2266 bool is_intrun = has_intvars && (j == 1);
2269 p_output <<
" MARK0001 'MARKER' 'INTORG'" << std::endl;
2271 for( i = 0; i < nCols(); i++ )
2273 bool is_intvar = has_intvars && (p_intvars->
pos(i) >= 0);
2275 if( ( is_intrun && !is_intvar) || (!is_intrun && is_intvar) )
2279 int colsize2 = (col.
size() / 2) * 2;
2281 assert(colsize2 % 2 == 0);
2283 for( k = 0; k < colsize2; k += 2 )
2288 if( colsize2 != col.
size() )
2292 if( maxObj(i) != 0 )
2297 p_output <<
" MARK0001 'MARKER' 'INTEND'" << std::endl;
2301 p_output <<
"RHS" << std::endl;
2304 while( i < nRows() )
2309 for( ; i < nRows(); i++ )
2310 if( (rhsval1 =
MPSgetRHS(lhs(i), rhs(i))) != 0 )
2315 for( k = i + 1; k < nRows(); k++ )
2317 if( (rhsval2 =
MPSgetRHS(lhs(k), rhs(k))) != 0 )
2336 p_output <<
"RANGES" << std::endl;
2338 for( i = 0; i < nRows(); i++ )
2340 if( (
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)) )
2350 p_output <<
"BOUNDS" << std::endl;
2352 for( i = 0; i < nCols(); i++ )
2357 if( col.
size() == 0 && maxObj(i) == 0 )
2360 if( lower(i) == upper(i) )
2366 if( (
double(lower(i)) <=
double(-
infinity)) && (
double(upper(i)) >=
double(
infinity)) )
2374 if(
double(lower(i)) > -
double(
infinity) )
2380 if( has_intvars && (p_intvars->
pos(i) >= 0) )
2389 if(
double(upper(i)) <
double(
infinity) )
2395 p_output <<
"ENDATA" << std::endl;
2400 MSG_WARNING( (*spxout), (*spxout) <<
"XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n" );
2411 SPxRowId dualRowIds[],
SPxColId dualColIds[],
int* nprimalrows,
int* nprimalcols,
int* ndualrows,
int* ndualcols)
2414 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...
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 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)