31 #define MAX_LINE_WRITE_LEN 65536 39 if( primal.
dim() != nCols() )
44 if( activity.
dim() != nRows() )
51 for( c = 0; c < nCols() && primal[c] == 0; c++ )
60 activity = colVector(c);
62 activity *= primal[c];
65 for( ; c < nCols(); c++ )
69 activity.
multAdd(primal[c], colVector(c));
77 if( dual.
dim() != nRows() )
82 if( activity.
dim() != nCols() )
89 for( r = 0; r < nRows() && dual[r] == 0; r++ )
98 activity = rowVector(r);
103 for( ; r < nRows(); r++ )
107 activity.
multAdd(dual[r], rowVector(r));
117 for(
int i = 0; i < nCols(); ++i )
135 for(
int i = 0; i < nCols(); ++i )
152 #define LPF_MAX_LINE_LEN 8192 157 return (c ==
' ') || (c ==
'\t') || (c ==
'\n') || (c ==
'\r');
165 return ((*s >=
'0') && (*s <=
'9')) || (*s ==
'+') || (*s ==
'-') || (*s ==
'.');
177 return ((*s >=
'A') && (*s <=
'Z'))
178 || ((*s >=
'a') && (*s <=
'z'))
179 || (strchr(
"!\"#$%&()/,;?@_'`{}|~", *s) != 0);
187 return (*s ==
'<') || (*s ==
'>') || (*s ==
'=');
194 return ((s[0] ==
'-') || (s[0] ==
'+'))
195 && (tolower(s[1]) ==
'i')
196 && (tolower(s[2]) ==
'n')
197 && (tolower(s[3]) ==
'f');
204 return (tolower(s[0]) ==
'f')
205 && ( tolower(s[1]) ==
'r')
206 && ( tolower(s[2]) ==
'e')
207 && ( tolower(s[3]) ==
'e');
224 bool has_digits =
false;
225 bool has_emptyexponent =
false;
226 bool has_dot =
false;
227 bool has_exponent =
false;
228 bool has_emptydivisor =
false;
231 if( (*s ==
'+') || (*s ==
'-') )
235 while( (*s >=
'0') && (*s <=
'9') )
248 while( (*s >=
'0') && (*s <=
'9') )
256 if( tolower(*s) ==
'e' )
259 has_emptyexponent =
true;
263 if( (*s ==
'+') || (*s ==
'-') )
267 while( (*s >=
'0') && (*s <=
'9') )
269 has_emptyexponent =
false;
278 has_emptydivisor =
true;
279 while( (*s >=
'0') && (*s <=
'9') )
281 has_emptydivisor =
false;
284 if( has_dot || has_exponent || has_emptydivisor ||
285 (*s ==
'.') ||(*s ==
'+') || (*s ==
'-') || (tolower(*s) ==
'e') )
287 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD03 Warning: In line " << lineno <<
": malformed rational value in LP file\n";)
294 if( has_emptyexponent )
296 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" );
300 value = (*pos ==
'-') ? -1 : 1;
303 for( t = tmp; pos != s; pos++ )
309 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD04 Warning: In line " << lineno <<
": malformed rational value in LP file\n" );
316 MSG_DEBUG( std::cout <<
"DLPFRD01 LPFreadValue = " << value << std::endl; )
334 assert(colnames != 0);
342 while( (strchr(
"+-.<>= ", *s) == 0) && (*s !=
'\0') )
345 for( i = 0; pos != s; i++, pos++ )
350 if( (colidx = colnames->
number(name)) < 0 )
354 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD02 Unknown variable \"" << name <<
"\" "; )
357 colidx = colnames->
num();
359 colset.
add(*emptycol);
363 MSG_DEBUG( std::cout <<
"DLPFRD03 LPFreadColName [" << name <<
"] = " << colidx << std::endl; )
380 if( (*pos ==
'<') || (*pos ==
'>') )
382 else if( *pos ==
'=' )
385 MSG_DEBUG( std::cout <<
"DLPFRD04 LPFreadSense = " << static_cast<char>(sense) << std::endl; )
403 assert(keyword != 0);
405 for( i = 0, k = 0; keyword[i] !=
'\0'; i++, k++ )
407 if( keyword[i] ==
'[' )
412 while( (tolower(pos[k]) == keyword[i]) && (pos[k] !=
'\0') )
417 while( keyword[i] !=
']' )
423 if( keyword[i] != tolower(pos[k]) )
434 MSG_DEBUG( std::cout <<
"DLPFRD05 LPFhasKeyword: " << keyword << std::endl; )
447 const char* s = strchr(pos,
':');
452 int dcolpos = int(s - pos);
458 for( end = dcolpos-1; end >= 0; end-- )
465 pos = &(pos[dcolpos+1]);
470 for( srt = end-1; srt >= 0; srt-- )
471 if( pos[srt] ==
' ' )
477 assert(srt <= end && pos[srt] !=
' ');
483 for( i = srt; i <= end; i++ )
491 pos = &(pos[dcolpos+1]);
502 Rational sense = (*pos ==
'-') ? -1 : 1;
531 std::istream& p_input,
538 START, OBJECTIVE, CONSTRAINTS, BOUNDS, INTEGERS, BINARIES
559 bool finished =
false;
561 bool have_value =
true;
574 cnames =
new (cnames)
NameSet();
587 rnames =
new (rnames)
NameSet();
610 if( !p_input.getline(buf,
sizeof(buf)) )
615 <<
" characters" << std::endl; )
619 MSG_ERROR( std::cerr <<
"ELPFRD07 No 'End' marker found" << std::endl; )
628 MSG_DEBUG( std::cout <<
"DLPFRD08 Reading line " << lineno
629 <<
" (pos=" << pos <<
")" << std::endl; )
632 if( 0 != (s = strchr(buf,
'\\')) )
636 if( section == START )
649 else if( section == OBJECTIVE )
657 for(
int j = vec.
size() - 1; j >= 0; --j )
663 section = CONSTRAINTS;
666 else if( section == CONSTRAINTS &&
709 if( section == OBJECTIVE )
713 if( section == CONSTRAINTS )
722 for( k = 0; pos[i] !=
'\0'; i++ )
733 for( i = 0, k = 0; tmp[i] !=
'\0'; i++ )
735 while( ((tmp[i] ==
'+') || (tmp[i] ==
'-')) && ((tmp[i + 1] ==
'+') || (tmp[i + 1] ==
'-')) )
737 if( tmp[i++] ==
'-' )
738 tmp[i] = (tmp[i] ==
'-') ?
'+' :
'-';
749 MSG_DEBUG( std::cout <<
"DLPFRD09 pos=" << pos << std::endl; )
752 while( (pos != 0) && (*pos !=
'\0') )
788 vec.
add(colidx, val);
818 else if( sense ==
'>' )
825 assert(sense ==
'=');
862 int n = vec.
pos(colidx);
866 vec.
add(colidx, val);
870 assert(vec.
index(n) == colidx);
879 assert(cnames->
has(colidx));
881 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD10 Duplicate index " 883 <<
" in line " << lineno
927 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD11 in Bounds section line " 928 << lineno <<
" ignored" << std::endl; )
937 else if( sense ==
'>' )
941 assert(sense ==
'=');
966 else if( sense ==
'>' )
970 assert(sense ==
'=');
986 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD12 in Binary/General section line " << lineno <<
" ignored" << std::endl; )
990 if( section == BINARIES )
992 if( cset.
lower(colidx) < 0 )
996 if( cset.
upper(colidx) > 1 )
1002 if( p_intvars != 0 )
1003 p_intvars->
addIdx(colidx);
1007 MSG_ERROR( std::cerr <<
"ELPFRD13 This seems to be no LP format file" << std::endl; )
1013 if( pos == pos_old )
1018 assert(isConsistent());
1021 assert(isConsistent());
1024 assert(isConsistent());
1029 MSG_INFO2( (*spxout), (*spxout) <<
"Finished reading " << lineno <<
" lines" << std::endl; )
1032 MSG_ERROR( std::cerr <<
"ELPFRD15 Syntax error in line " << lineno << std::endl; )
1060 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD01 Problem name : " << mps.
probName() << std::endl; )
1066 if( !strcmp(mps.
field0(),
"ROWS") )
1068 else if( !strncmp(mps.
field0(),
"OBJSEN", 6) )
1070 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1093 if( !strcmp(mps.
field1(),
"MIN") )
1095 else if( !strcmp(mps.
field1(),
"MAX") )
1104 if( !strcmp(mps.
field0(),
"ROWS") )
1106 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1135 if( strcmp(mps.
field0(),
"ROWS") )
1158 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD02 Objective name : " << mps.
objName() << std::endl; )
1160 if( strcmp(mps.
field0(),
"COLUMNS") )
1168 if( *mps.
field1() ==
'N' )
1226 if( strcmp(mps.
field0(),
"RHS") )
1229 if( colname[0] !=
'\0' )
1244 if( strcmp(colname, mps.
field1()) )
1247 if( colname[0] !=
'\0' )
1249 col.setColVector(vec);
1256 cnames.
add(colname);
1264 assert(cnames.
number(colname) == cset.
num());
1276 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD01 Warning: malformed rational value in MPS file\n" );
1292 assert(mps.
field4() != 0);
1296 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD02 Warning: malformed rational value in MPS file\n" );
1328 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD03 RHS name : " << rhsname << std::endl; );
1330 if( !strcmp(mps.
field0(),
"RANGES") )
1332 else if( !strcmp(mps.
field0(),
"BOUNDS") )
1334 else if( !strcmp(mps.
field0(),
"ENDATA") )
1348 if( *rhsname ==
'\0' )
1351 if( strcmp(rhsname, mps.
field1()) )
1353 if( strcmp(addname, mps.
field1()) )
1357 MSG_INFO3( (*spxout), (*spxout) <<
"IMPSRD07 RHS ignored : " << addname << std::endl );
1368 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD03 Warning: malformed rational value in MPS file\n" );
1373 rset.
rhs_w(idx) = val;
1376 rset.
lhs_w(idx) = val;
1387 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD04 Warning: malformed rational value in MPS file\n" );
1392 rset.
rhs_w(idx) = val;
1395 rset.
lhs_w(idx) = val;
1417 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD04 Range name : " << rngname << std::endl; );
1419 if( !strcmp(mps.
field0(),
"BOUNDS") )
1421 else if( !strcmp(mps.
field0(),
"ENDATA") )
1435 if( *rngname ==
'\0' )
1450 if( !strcmp(rngname, mps.
field1()) )
1458 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD05 Warning: malformed rational value in MPS file\n" );
1464 assert(rset.
lhs(idx) == rset.
rhs(idx));
1466 if(
double(val) >= 0 )
1467 rset.
rhs_w(idx) += val;
1469 rset.
lhs_w(idx) += val;
1496 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD06 Warning: malformed rational value in MPS file\n" );
1502 assert(rset.
lhs(idx) == rset.
rhs(idx));
1504 if(
double(val) >= 0 )
1505 rset.
rhs_w(idx) += val;
1507 rset.
lhs_w(idx) += val;
1546 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD05 Bound name : " << bndname << std::endl; )
1548 if( strcmp(mps.
field0(),
"ENDATA") )
1557 if( (!strcmp(mps.
field1(),
"LO"))
1558 || (!strcmp(mps.
field1(),
"UP"))
1559 || (!strcmp(mps.
field1(),
"FX"))
1560 || (!strcmp(mps.
field1(),
"LI"))
1561 || (!strcmp(mps.
field1(),
"UI")) )
1575 if( *bndname ==
'\0' )
1582 if( !strcmp(bndname, mps.
field2()) )
1590 else if( !strcmp(mps.
field4(),
"-Inf") || !strcmp(mps.
field4(),
"-inf") )
1592 else if( !strcmp(mps.
field4(),
"Inf") || !strcmp(mps.
field4(),
"inf") || !strcmp(mps.
field4(),
"+Inf") || !strcmp(mps.
field4(),
"+inf") )
1596 MSG_WARNING( (*spxout), (*spxout) <<
"WMPSRD07 Warning: malformed rational value in MPS file line " << mps.
lineno() <<
": " << mps.
field4() <<
"\n" );
1602 if( mps.
field1()[1] ==
'I' )
1609 if( oldbinvars.
pos(idx) < 0 )
1625 if( mps.
field1()[1] ==
'X' )
1674 #define INIT_COLS 1000 1675 #define INIT_NZOS 5000
1678 std::istream& p_input,
1694 cnames =
new (cnames)
NameSet();
1707 rnames =
new (rnames)
NameSet();
1740 addedRows(rset.
num());
1743 MPSreadCols(mps, rset, *rnames, cset, *cnames, p_intvars, spxout);
1769 addedCols(cset.
num());
1771 assert(isConsistent());
1801 int p_num_written_rows
1806 assert(p_idx < p_lp.
nRows());
1812 if( p_rnames->
has(key) )
1813 return (*p_rnames)[key];
1816 spxSnprintf(p_buf, 16,
"C%d", p_num_written_rows);
1833 assert(p_idx < p_lp.
nCols());
1839 if( p_cnames->
has(key) )
1840 return (*p_cnames)[key];
1851 #define NUM_ENTRIES_PER_LINE 5 1854 std::ostream& p_output,
1865 pos = p_output.tellp();
1867 for(
int j = 0; j < p_lp.
nCols(); ++j )
1874 if( num_coeffs == 0 )
1875 p_output << coeff <<
" " <<
getColName(p_lp, j, p_cnames, name);
1886 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR01 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" );
1888 pos = p_output.tellp();
1892 p_output <<
" - " << -coeff;
1894 p_output <<
" + " << coeff;
1896 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name);
1908 std::ostream& p_output,
1916 p_output << ((sense == SPxLPBase<Rational>::MINIMIZE) ?
"Minimize\n" :
"Maximize\n");
1917 p_output <<
" obj: ";
1921 svec.operator=(obj);
1932 std::ostream& p_output,
1942 pos = p_output.tellp();
1950 if( (
long long)(p_output.tellp()) - pos + sidelen + (
long long)100 >
MAX_LINE_WRITE_LEN )
1955 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR02 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" );
1957 pos = p_output.tellp();
1961 if( p_lhs == p_rhs )
1962 p_output <<
" = " << p_rhs;
1963 else if(
double(p_lhs) <=
double(-
infinity) )
1964 p_output <<
" <= " << p_rhs;
1967 assert(
double(p_rhs) >=
double(
infinity));
1968 p_output <<
" >= " << p_lhs;
1975 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR03 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" );
1984 std::ostream& p_output,
1993 p_output <<
"Subject To\n";
1995 for(
int i = 0; i < p_lp.
nRows(); ++i )
2000 if(
double(lhs) > -
double(
infinity) &&
double(rhs) <
double(
infinity) && lhs != rhs )
2003 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_1 : ";
2006 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_2 : ";
2011 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
" : ";
2023 std::ostream& p_output,
2032 pos = p_output.tellp();
2034 p_output <<
"Bounds\n";
2036 for(
int j = 0; j < p_lp.
nCols(); ++j )
2041 if( lower == upper )
2043 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
" = " << upper <<
'\n';
2045 else if(
double(lower) > -
double(
infinity) )
2047 if(
double(upper) <
double(
infinity) )
2051 p_output <<
" " << lower <<
" <= " 2053 <<
" <= " << upper <<
'\n';
2055 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2056 <<
" <= " << upper <<
'\n';
2058 else if( lower != 0 )
2059 p_output <<
" " << lower <<
" <= " 2063 else if(
double(upper) <
double(
infinity) )
2064 p_output <<
" -Inf <= " 2066 <<
" <= " << upper <<
'\n';
2068 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2074 MSG_WARNING( (*spxout), (*spxout) <<
"XLPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing LP file\n" );
2076 pos = p_output.tellp();
2085 std::ostream& p_output,
2093 if( p_intvars == NULL || p_intvars->
size() <= 0 )
2096 p_output <<
"Generals\n";
2098 for(
int j = 0; j < p_lp.
nCols(); ++j )
2099 if( p_intvars->
pos(j) >= 0 )
2100 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
"\n";
2108 std::ostream& p_output,
2116 LPFwriteRows(*
this, p_output, p_rnames, p_cnames, spxout);
2120 p_output <<
"End" << std::endl;
2132 const char* indicator,
2135 const char* name1 = 0,
2137 const char* name2 = 0,
2144 sprintf(buf,
" %-2.2s %-8.8s", (indicator == 0) ?
"" : indicator, (name == 0) ?
"" : name);
2150 os << buf << value1;
2154 os << buf << value2;
2162 MSG_WARNING( (*spxout), (*spxout) <<
"XMPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing MPS file\n" );
2172 if(
double(left) > -
double(
infinity) )
2174 else if(
double(right) <
double(
infinity) )
2193 assert(idx < lp.
nRows());
2199 if( rnames->
has(key) )
2200 return (*rnames)[key];
2215 std::ostream& p_output,
2222 const char* indicator;
2226 bool has_ranges =
false;
2231 p_output <<
"NAME MPSDATA" << std::endl;
2234 p_output <<
"ROWS" << std::endl;
2236 for( i = 0; i < nRows(); i++ )
2238 if( lhs(i) == rhs(i) )
2240 else if( (
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)) )
2245 else if(
double(lhs(i)) > -
double(
infinity) )
2247 else if(
double(rhs(i)) <
double(
infinity) )
2258 p_output <<
"COLUMNS" << std::endl;
2260 bool has_intvars = (p_intvars != 0) && (p_intvars->
size() > 0);
2262 for(
int j = 0; j < (has_intvars ? 2 : 1); j++ )
2264 bool is_intrun = has_intvars && (j == 1);
2267 p_output <<
" MARK0001 'MARKER' 'INTORG'" << std::endl;
2269 for( i = 0; i < nCols(); i++ )
2271 bool is_intvar = has_intvars && (p_intvars->
pos(i) >= 0);
2273 if( ( is_intrun && !is_intvar) || (!is_intrun && is_intvar) )
2277 int colsize2 = (col.
size() / 2) * 2;
2279 assert(colsize2 % 2 == 0);
2281 for( k = 0; k < colsize2; k += 2 )
2286 if( colsize2 != col.
size() )
2290 if( maxObj(i) != 0 )
2295 p_output <<
" MARK0001 'MARKER' 'INTEND'" << std::endl;
2299 p_output <<
"RHS" << std::endl;
2302 while( i < nRows() )
2307 for( ; i < nRows(); i++ )
2308 if( (rhsval1 =
MPSgetRHS(lhs(i), rhs(i))) != 0 )
2313 for( k = i + 1; k < nRows(); k++ )
2315 if( (rhsval2 =
MPSgetRHS(lhs(k), rhs(k))) != 0 )
2334 p_output <<
"RANGES" << std::endl;
2336 for( i = 0; i < nRows(); i++ )
2338 if( (
double(lhs(i)) > -
double(
infinity)) && (double(rhs(i)) < double(
infinity)) )
2348 p_output <<
"BOUNDS" << std::endl;
2350 for( i = 0; i < nCols(); i++ )
2355 if( col.
size() == 0 && maxObj(i) == 0 )
2358 if( lower(i) == upper(i) )
2364 if( (
double(lower(i)) <=
double(-
infinity)) && (
double(upper(i)) >=
double(
infinity)) )
2372 if(
double(lower(i)) > -
double(
infinity) )
2378 if( has_intvars && (p_intvars->
pos(i) >= 0) )
2387 if(
double(upper(i)) <
double(
infinity) )
2393 p_output <<
"ENDATA" << std::endl;
2398 MSG_WARNING( (*spxout), (*spxout) <<
"XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n" );
2409 SPxRowId dualRowIds[],
SPxColId dualColIds[],
int* nprimalrows,
int* nprimalcols,
int* ndualrows,
int* ndualcols)
2412 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 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)