38 MSG_INFO3( (*spxout), (*spxout) <<
"remove persistent scaling of LP" << std::endl; )
41 lp_scaler->unscale(*
this);
43 MSG_INFO3( (*spxout), (*spxout) <<
"no LP scaler available" << std::endl; )
49 if( primal.
dim() != nCols() )
52 if( activity.
dim() != nRows() )
57 for( c = 0; c < nCols() && primal[c] == 0; c++ )
68 if( unscaled && _isScaled )
70 lp_scaler->getColUnscaled(*
this, c, tmp);
74 activity = colVector(c);
76 activity *= primal[c];
79 for( ; c < nCols(); c++ )
83 if( unscaled && _isScaled )
85 lp_scaler->getColUnscaled(*
this, c, tmp);
86 activity.
multAdd(primal[c], tmp);
89 activity.
multAdd(primal[c], colVector(c));
97 if( dual.
dim() != nRows() )
100 if( activity.
dim() != nCols() )
105 for( r = 0; r < nRows() && dual[r] == 0; r++ )
116 if( unscaled && _isScaled )
118 lp_scaler->getRowUnscaled(*
this, r, tmp);
122 activity = rowVector(r);
127 for( ; r < nRows(); r++ )
131 if( unscaled && _isScaled )
133 lp_scaler->getRowUnscaled(*
this, r, tmp);
134 activity.
multAdd(dual[r], tmp);
137 activity.
multAdd(dual[r], rowVector(r));
147 if( unscaled && _isScaled )
149 assert(lp_scaler != 0);
151 for(
int i = 0; i < nCols(); ++i )
153 Real m = lp_scaler->getColMaxAbsUnscaled(*
this, i);
161 for(
int i = 0; i < nCols(); ++i )
163 Real m = colVector(i).maxAbs();
180 if( unscaled && _isScaled )
182 assert(lp_scaler != 0);
184 for(
int i = 0; i < nCols(); ++i )
186 Real m = lp_scaler->getColMinAbsUnscaled(*
this, i);
194 for(
int i = 0; i < nCols(); ++i )
196 Real m = colVector(i).minAbs();
215 lp_scaler->getMaxObjUnscaled(*
this, pobj);
222 if( spxSense() == MINIMIZE )
230 assert(i >= 0 && i < nRows());
232 lp_scaler->getRowUnscaled(*
this, i, vec);
251 assert(i >= 0 && i < nRows());
253 return lp_scaler->rhsUnscaled(*
this, i);
262 assert(
id.isValid());
263 return rhsUnscaled(number(
id));
280 assert(i >= 0 && i < nRows());
282 return lp_scaler->lhsUnscaled(*
this,i);
291 assert(
id.isValid());
292 return lhsUnscaled(number(
id));
299 assert(i >= 0 && i < nCols());
301 lp_scaler->getColUnscaled(*
this, i, vec);
310 assert(
id.isValid());
311 getColVectorUnscaled(number(
id), vec);
318 assert(i >= 0 && i < nCols());
323 res = lp_scaler->maxObjUnscaled(*
this, i);
330 if( spxSense() == MINIMIZE )
339 assert(
id.isValid());
340 return objUnscaled(number(
id));
348 lp_scaler->getMaxObjUnscaled(*
this, vec);
357 assert(i >= 0 && i < nCols());
359 return lp_scaler->maxObjUnscaled(*
this, i);
368 assert(
id.isValid());
369 return maxObjUnscaled(number(
id));
386 assert(i >= 0 && i < nCols());
388 return lp_scaler->upperUnscaled(*
this, i);
397 assert(
id.isValid());
398 return upperUnscaled(number(
id));
415 assert(i >= 0 && i < nCols());
417 return lp_scaler->lowerUnscaled(*
this, i);
426 assert(
id.isValid());
427 return lowerUnscaled(number(
id));
434 assert(maxObj().dim() == newObj.
dim());
443 assert(isConsistent());
450 assert(lower().dim() == newLower.
dim());
459 assert(isConsistent());
467 assert(upper().dim() == newUpper.
dim());
476 assert(isConsistent());
483 assert(lhs().dim() == newLhs.
dim());
492 assert(isConsistent());
499 assert(rhs().dim() == newRhs.
dim());
508 assert(isConsistent());
515 #define LPF_MAX_LINE_LEN 8192 520 return (c ==
' ') || (c ==
'\t') || (c ==
'\n') || (c ==
'\r');
528 return ((*s >=
'0') && (*s <=
'9')) || (*s ==
'+') || (*s ==
'-') || (*s ==
'.');
540 return ((*s >=
'A') && (*s <=
'Z'))
541 || ((*s >=
'a') && (*s <=
'z'))
542 || (strchr(
"!\"#$%&()/,;?@_'`{}|~", *s) != 0);
550 return (*s ==
'<') || (*s ==
'>') || (*s ==
'=');
557 return ((s[0] ==
'-') || (s[0] ==
'+'))
558 && (tolower(s[1]) ==
'i')
559 && (tolower(s[2]) ==
'n')
560 && (tolower(s[3]) ==
'f');
567 return (tolower(s[0]) ==
'f')
568 && ( tolower(s[1]) ==
'r')
569 && ( tolower(s[2]) ==
'e')
570 && ( tolower(s[3]) ==
'e');
587 bool has_digits =
false;
588 bool has_emptyexponent =
false;
591 if( (*s ==
'+') || (*s ==
'-') )
595 while( (*s >=
'0') && (*s <=
'9') )
607 while( (*s >=
'0') && (*s <=
'9') )
615 if( tolower(*s) ==
'e' )
617 has_emptyexponent =
true;
621 if( (*s ==
'+') || (*s ==
'-') )
625 while( (*s >=
'0') && (*s <=
'9') )
627 has_emptyexponent =
false;
633 if( has_emptyexponent )
635 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD01 Warning: found empty exponent in LP file - check for forbidden variable names with initial 'e' or 'E'\n"; )
639 value = (*pos ==
'-') ? -1.0 : 1.0;
642 for( t = tmp; pos != s; pos++ )
652 MSG_DEBUG( std::cout <<
"DLPFRD01 LPFreadValue = " << value << std::endl; )
670 assert(colnames != 0);
678 while( (strchr(
"+-.<>= ", *s) == 0) && (*s !=
'\0') )
681 for( i = 0; pos != s; i++, pos++ )
686 if( (colidx = colnames->
number(name)) < 0 )
690 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD02 Unknown variable \"" << name <<
"\" "; )
693 colidx = colnames->
num();
695 colset.
add(*emptycol);
699 MSG_DEBUG( std::cout <<
"DLPFRD03 LPFreadColName [" << name <<
"] = " << colidx << std::endl; )
716 if( (*pos ==
'<') || (*pos ==
'>') )
718 else if( *pos ==
'=' )
721 MSG_DEBUG( std::cout <<
"DLPFRD04 LPFreadSense = " << static_cast<char>(sense) << std::endl; )
739 assert(keyword != 0);
741 for( i = 0, k = 0; keyword[i] !=
'\0'; i++, k++ )
743 if( keyword[i] ==
'[' )
748 while( (tolower(pos[k]) == keyword[i]) && (pos[k] !=
'\0') )
753 while( keyword[i] !=
']' )
759 if( keyword[i] != tolower(pos[k]) )
770 MSG_DEBUG( std::cout <<
"DLPFRD05 LPFhasKeyword: " << keyword << std::endl; )
783 const char* s = strchr(pos,
':');
788 int dcolpos = int(s - pos);
794 for( end = dcolpos-1; end >= 0; end-- )
801 pos = &(pos[dcolpos+1]);
806 for( srt = end-1; srt >= 0; srt-- )
807 if( pos[srt] ==
' ' )
813 assert(srt <= end && pos[srt] !=
' ');
819 for( i = srt; i <= end; i++ )
827 pos = &(pos[dcolpos+1]);
838 Real sense = (*pos ==
'-') ? -1.0 : 1.0;
866 std::istream& p_input,
873 START, OBJECTIVE, CONSTRAINTS, BOUNDS, INTEGERS, BINARIES
894 bool finished =
false;
896 bool have_value =
true;
909 cnames =
new (cnames)
NameSet();
922 rnames =
new (rnames)
NameSet();
945 if( !p_input.getline(buf,
sizeof(buf)) )
950 <<
" characters" << std::endl; )
954 MSG_ERROR( std::cerr <<
"ELPFRD07 No 'End' marker found" << std::endl; )
963 MSG_DEBUG( std::cout <<
"DLPFRD08 Reading line " << lineno
964 <<
" (pos=" << pos <<
")" << std::endl; )
967 if( 0 != (s = strchr(buf,
'\\')) )
971 if( section == START )
984 else if( section == OBJECTIVE )
992 for(
int j = vec.
size() - 1; j >= 0; --j )
998 section = CONSTRAINTS;
1001 else if( section == CONSTRAINTS &&
1044 if( section == OBJECTIVE )
1048 if( section == CONSTRAINTS )
1057 for( k = 0; pos[i] !=
'\0'; i++ )
1064 if( tmp[0] ==
'\0' )
1068 for( i = 0, k = 0; tmp[i] !=
'\0'; i++ )
1070 while( ((tmp[i] ==
'+') || (tmp[i] ==
'-')) && ((tmp[i + 1] ==
'+') || (tmp[i + 1] ==
'-')) )
1072 if( tmp[i++] ==
'-' )
1073 tmp[i] = (tmp[i] ==
'-') ?
'+' :
'-';
1084 MSG_DEBUG( std::cout <<
"DLPFRD09 pos=" << pos << std::endl; )
1087 while( (pos != 0) && (*pos !=
'\0') )
1098 Real pre_sign = 1.0;
1122 vec.
add(colidx, val);
1127 Real pre_sign = 1.0;
1151 else if( sense ==
'>' )
1158 assert(sense ==
'=');
1172 sprintf(name,
"C%d", rset.
num());
1195 int n = vec.
pos(colidx);
1199 vec.
add(colidx, val);
1203 assert(vec.
index(n) == colidx);
1205 val += vec.
value(n);
1212 assert(cnames->
has(colidx));
1214 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD10 Duplicate index " 1215 << (*cnames)[colidx]
1216 <<
" in line " << lineno
1235 assert(!have_value);
1258 if( (colidx =
LPFreadColName(pos, cnames, cset, 0, spxout)) < 0 )
1260 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD11 in Bounds section line " 1261 << lineno <<
" ignored" << std::endl; )
1270 else if( sense ==
'>' )
1274 assert(sense ==
'=');
1299 else if( sense ==
'>' )
1303 assert(sense ==
'=');
1317 if( (colidx =
LPFreadColName(pos, cnames, cset, 0, spxout)) < 0 )
1319 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD12 in Binary/General section line " << lineno <<
" ignored" << std::endl; )
1323 if( section == BINARIES )
1325 if( cset.
lower(colidx) < 0.0 )
1329 if( cset.
upper(colidx) > 1.0 )
1335 if( p_intvars != 0 )
1336 p_intvars->
addIdx(colidx);
1340 MSG_ERROR( std::cerr <<
"ELPFRD13 This seems to be no LP format file" << std::endl; )
1346 if( pos == pos_old )
1351 assert(isConsistent());
1354 assert(isConsistent());
1357 assert(isConsistent());
1362 MSG_INFO2( (*spxout), (*spxout) <<
"Finished reading " << lineno <<
" lines" << std::endl; )
1365 MSG_ERROR( std::cerr <<
"ELPFRD15 Syntax error in line " << lineno << std::endl; )
1393 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD01 Problem name : " << mps.
probName() << std::endl; )
1399 if( !strcmp(mps.
field0(),
"ROWS") )
1401 else if( !strncmp(mps.
field0(),
"OBJSEN", 6) )
1403 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1426 if( !strcmp(mps.
field1(),
"MIN") )
1428 else if( !strcmp(mps.
field1(),
"MAX") )
1437 if( !strcmp(mps.
field0(),
"ROWS") )
1439 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1468 if( strcmp(mps.
field0(),
"ROWS") )
1491 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD02 Objective name : " << mps.
objName() << std::endl; )
1493 if( strcmp(mps.
field0(),
"COLUMNS") )
1504 if( *mps.
field1() ==
'N' )
1551 char colname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1562 if( strcmp(mps.
field0(),
"RHS") )
1565 if( colname[0] !=
'\0' )
1580 if( strcmp(colname, mps.
field1()) )
1583 if( colname[0] !=
'\0' )
1585 col.setColVector(vec);
1590 strncpy(colname, mps.
field1(), MPSInput::MAX_LINE_LEN-1);
1591 colname[MPSInput::MAX_LINE_LEN-1] =
'\0';
1592 cnames.
add(colname);
1600 assert(cnames.
number(colname) == cset.
num());
1610 val = atof(mps.
field3());
1618 else if( val != 0.0 )
1624 assert(mps.
field4() != 0);
1626 val = atof(mps.
field5());
1634 else if( val != 0.0 )
1648 char rhsname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1649 char addname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1657 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD03 RHS name : " << rhsname << std::endl; );
1659 if( !strcmp(mps.
field0(),
"RANGES") )
1661 else if( !strcmp(mps.
field0(),
"BOUNDS") )
1663 else if( !strcmp(mps.
field0(),
"ENDATA") )
1677 if( *rhsname ==
'\0' )
1678 strcpy(rhsname, mps.
field1());
1680 if( strcmp(rhsname, mps.
field1()) )
1682 if( strcmp(addname, mps.
field1()) )
1684 assert(strlen(mps.
field1()) < MPSInput::MAX_LINE_LEN);
1685 strcpy(addname, mps.
field1());
1686 MSG_INFO3( (*spxout), (*spxout) <<
"IMPSRD07 RHS ignored : " << addname << std::endl );
1695 val = atof(mps.
field3());
1699 rset.
rhs_w(idx) = val;
1702 rset.
lhs_w(idx) = val;
1711 val = atof(mps.
field5());
1715 rset.
rhs_w(idx) = val;
1718 rset.
lhs_w(idx) = val;
1732 char rngname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1740 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD04 Range name : " << rngname << std::endl; );
1742 if( !strcmp(mps.
field0(),
"BOUNDS") )
1744 else if( !strcmp(mps.
field0(),
"ENDATA") )
1758 if( *rngname ==
'\0' )
1760 assert(strlen(mps.
field2()) < MPSInput::MAX_LINE_LEN);
1761 strcpy(rngname, mps.
field1());
1773 if( !strcmp(rngname, mps.
field1()) )
1779 val = atof(mps.
field3());
1784 assert(rset.
lhs(idx) == rset.
rhs(idx));
1787 rset.
rhs_w(idx) += val;
1789 rset.
lhs_w(idx) += val;
1808 val = atof(mps.
field5());
1813 assert(rset.
lhs(idx) == rset.
rhs(idx));
1816 rset.
rhs_w(idx) += val;
1818 rset.
lhs_w(idx) += val;
1843 char bndname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1851 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD05 Bound name : " << bndname << std::endl; )
1853 if( strcmp(mps.
field0(),
"ENDATA") )
1862 if( (!strcmp(mps.
field1(),
"LO"))
1863 || (!strcmp(mps.
field1(),
"UP"))
1864 || (!strcmp(mps.
field1(),
"FX"))
1865 || (!strcmp(mps.
field1(),
"LI"))
1866 || (!strcmp(mps.
field1(),
"UI")) )
1880 if( *bndname ==
'\0' )
1882 assert(strlen(mps.
field2()) < MPSInput::MAX_LINE_LEN);
1883 strcpy(bndname, mps.
field2());
1887 if( !strcmp(bndname, mps.
field2()) )
1895 else if( !strcmp(mps.
field4(),
"-Inf") || !strcmp(mps.
field4(),
"-inf") )
1897 else if( !strcmp(mps.
field4(),
"Inf") || !strcmp(mps.
field4(),
"inf") || !strcmp(mps.
field4(),
"+Inf") || !strcmp(mps.
field4(),
"+inf") )
1900 val = atof(mps.
field4());
1903 if( mps.
field1()[1] ==
'I' )
1910 if( oldbinvars.
pos(idx) < 0 )
1926 if( mps.
field1()[1] ==
'X' )
1975 #define INIT_COLS 10000 1976 #define INIT_NZOS 100000
1979 std::istream& p_input,
1995 cnames =
new (cnames)
NameSet();
2008 rnames =
new (rnames)
NameSet();
2032 if( mps.
section() == MPSInput::OBJSEN )
2035 if( mps.
section() == MPSInput::OBJNAME )
2041 addedRows(rset.
num());
2043 if( mps.
section() == MPSInput::COLUMNS )
2044 MPSreadCols(mps, rset, *rnames, cset, *cnames, p_intvars);
2046 if( mps.
section() == MPSInput::RHS )
2049 if( mps.
section() == MPSInput::RANGES )
2052 if( mps.
section() == MPSInput::BOUNDS )
2055 if( mps.
section() != MPSInput::ENDATA )
2064 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD06 Objective sense: " << ((mps.
objSense() == MPSInput::MINIMIZE) ?
"Minimize\n" :
"Maximize\n") );
2070 addedCols(cset.
num());
2072 assert(isConsistent());
2102 int p_num_written_rows
2107 assert(p_idx < p_lp.
nRows());
2113 if( p_rnames->
has(key) )
2114 return (*p_rnames)[key];
2117 sprintf(p_buf,
"C%d", p_num_written_rows);
2134 assert(p_idx < p_lp.
nCols());
2140 if( p_cnames->
has(key) )
2141 return (*p_cnames)[key];
2144 sprintf(p_buf,
"x%d", p_idx);
2152 #define NUM_ENTRIES_PER_LINE 5 2155 std::ostream& p_output,
2163 for(
int j = 0; j < p_lp.
nCols(); ++j )
2165 const Real coeff = p_svec[j];
2170 if( num_coeffs == 0 )
2171 p_output << coeff <<
" " <<
getColName(p_lp, j, p_cnames, name);
2179 p_output <<
" - " << -coeff;
2181 p_output <<
" + " << coeff;
2183 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name);
2195 std::ostream& p_output,
2202 p_output << ((sense == SPxLPBase<Real>::MINIMIZE) ?
"Minimize\n" :
"Maximize\n");
2203 p_output <<
" obj: ";
2207 svec.operator=(obj);
2208 svec *=
Real(sense);
2218 std::ostream& p_output,
2228 if( p_lhs == p_rhs )
2229 p_output <<
" = " << p_rhs;
2231 p_output <<
" <= " << p_rhs;
2235 p_output <<
" >= " << p_lhs;
2246 std::ostream& p_output,
2254 p_output <<
"Subject To\n";
2256 int num_written_rows = 0;
2257 for(
int i = 0; i < p_lp.
nRows(); ++i )
2265 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, ++num_written_rows) <<
"_1 : ";
2268 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, ++num_written_rows) <<
"_2 : ";
2273 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, ++num_written_rows) <<
" : ";
2285 std::ostream& p_output,
2292 p_output <<
"Bounds\n";
2294 for(
int j = 0; j < p_lp.
nCols(); ++j )
2299 if( lower == upper )
2301 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
" = " << upper <<
'\n';
2309 p_output <<
" " << lower <<
" <= " 2311 <<
" <= " << upper <<
'\n';
2313 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2314 <<
" <= " << upper <<
'\n';
2316 else if( lower != 0 )
2317 p_output <<
" " << lower <<
" <= " 2322 p_output <<
" -Inf <= " 2324 <<
" <= " << upper <<
'\n';
2326 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2336 std::ostream& p_output,
2344 if( p_intvars == NULL || p_intvars->
size() <= 0 )
2347 p_output <<
"Generals\n";
2349 for(
int j = 0; j < p_lp.
nCols(); ++j )
2350 if( p_intvars->
pos(j) >= 0 )
2351 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
"\n";
2359 std::ostream& p_output,
2366 p_output << std::setprecision(15);
2372 p_output <<
"End" << std::endl;
2383 const char* indicator,
2385 const char* name1 = 0,
2386 const Real value1 = 0.0,
2387 const char* name2 = 0,
2388 const Real value2 = 0.0
2393 sprintf(buf,
" %-2.2s %-8.8s", (indicator == 0) ?
"" : indicator, (name == 0) ?
"" : name);
2398 sprintf(buf,
" %-8.8s %.15" REAL_FORMAT, name1, value1);
2403 sprintf(buf,
" %-8.8s %.15" REAL_FORMAT, name2, value2);
2438 assert(idx < lp.
nRows());
2444 if( rnames->
has(key) )
2445 return (*rnames)[key];
2448 sprintf(buf,
"C%d", idx);
2460 std::ostream& p_output,
2467 const char* indicator;
2471 bool has_ranges =
false;
2476 p_output <<
"NAME MPSDATA" << std::endl;
2479 p_output <<
"ROWS" << std::endl;
2481 for( i = 0; i < nRows(); i++ )
2483 if( lhs(i) == rhs(i) )
2503 p_output <<
"COLUMNS" << std::endl;
2505 bool has_intvars = (p_intvars != 0) && (p_intvars->
size() > 0);
2507 for(
int j = 0; j < (has_intvars ? 2 : 1); j++ )
2509 bool is_intrun = has_intvars && (j == 1);
2512 p_output <<
" MARK0001 'MARKER' 'INTORG'" << std::endl;
2514 for( i = 0; i < nCols(); i++ )
2516 bool is_intvar = has_intvars && (p_intvars->
pos(i) >= 0);
2518 if( ( is_intrun && !is_intvar) || (!is_intrun && is_intvar) )
2522 int colsize2 = (col.
size() / 2) * 2;
2524 assert(colsize2 % 2 == 0);
2526 for( k = 0; k < colsize2; k += 2 )
2531 if( colsize2 != col.
size() )
2540 p_output <<
" MARK0001 'MARKER' 'INTEND'" << std::endl;
2544 p_output <<
"RHS" << std::endl;
2547 while( i < nRows() )
2552 for( ; i < nRows(); i++ )
2553 if( (rhsval1 =
MPSgetRHS(lhs(i), rhs(i))) != 0.0 )
2558 for( k = i + 1; k < nRows(); k++ )
2560 if( (rhsval2 =
MPSgetRHS(lhs(k), rhs(k))) != 0.0 )
2579 p_output <<
"RANGES" << std::endl;
2581 for( i = 0; i < nRows(); i++ )
2589 p_output <<
"BOUNDS" << std::endl;
2591 for( i = 0; i < nCols(); i++ )
2599 if( lower(i) == upper(i) )
2611 if( lower(i) != 0.0 )
2619 if( has_intvars && (p_intvars->
pos(i) >= 0) )
2634 p_output <<
"ENDATA" << std::endl;
2639 MSG_WARNING( (*spxout), (*spxout) <<
"XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n" );
2650 SPxRowId dualRowIds[],
SPxColId dualColIds[],
int* nprimalrows,
int* nprimalcols,
int* ndualrows,
int* ndualcols)
2653 if( primalRowIds == 0 || primalColIds == 0 || dualRowIds == 0 || dualColIds == 0 )
2659 int numprimalrows = 0;
2660 int numprimalcols = 0;
2661 int numdualrows = 0;
2662 int numdualcols = 0;
2665 dualcolids.
get_ptr(), &numprimalrows, &numprimalcols, &numdualrows, &numdualcols);
2667 if( primalRowIds != 0 )
2669 primalRowIds = primalrowids.
get_ptr();
2670 (*nprimalrows) = numprimalrows;
2673 if( primalColIds != 0 )
2675 primalColIds = primalcolids.
get_ptr();
2676 (*nprimalcols) = numprimalcols;
2679 if( dualRowIds != 0 )
2681 dualRowIds = dualrowids.
get_ptr();
2682 (*ndualrows) = numdualrows;
2685 if( dualColIds != 0 )
2687 dualColIds = dualcolids.
get_ptr();
2688 (*ndualcols) = numdualcols;
2695 if( spxSense() == MINIMIZE )
2704 int numAddedRows = 0;
2705 int numVarBoundCols = 0;
2706 int primalrowsidx = 0;
2707 int primalcolsidx = 0;
2709 for(
int i = 0; i < nCols(); ++i )
2711 primalColIds[primalcolsidx] = cId(i);
2715 dualrows.
create(0, obj(i), obj(i));
2722 if( spxSense() == MINIMIZE )
2729 col.
add(numAddedRows, 1.0);
2730 if( spxSense() == MINIMIZE )
2732 dualrows.
create(0, obj(i), obj(i));
2737 dualrows.
create(0, obj(i), obj(i));
2750 if( spxSense() == MINIMIZE )
2757 col.
add(numAddedRows, 1.0);
2758 if( spxSense() == MINIMIZE )
2760 dualrows.
create(0, obj(i), obj(i));
2765 dualrows.
create(0, obj(i), obj(i));
2774 else if (
NE(lower(i), upper(i)) )
2778 col.
add(numAddedRows, 1.0);
2779 if( spxSense() == MINIMIZE )
2793 else if(
isZero(upper(i)) )
2795 col.
add(numAddedRows, 1.0);
2796 if( spxSense() == MINIMIZE )
2812 dualrows.
create(0, obj(i), obj(i));
2814 col.
add(numAddedRows, 1.0);
2815 if( spxSense() == MINIMIZE )
2827 numVarBoundCols += 2;
2833 assert(lower(i) == upper(i));
2835 dualrows.
create(0, obj(i), obj(i));
2837 col.
add(numAddedRows, 1.0);
2842 numVarBoundCols += 2;
2852 for(
int i = 0; i < primalcolsidx; i++ )
2853 dualRowIds[i] = dualLP.
rId(i);
2855 (*nprimalcols) = primalcolsidx;
2856 (*ndualrows) = primalcolsidx;
2859 for(
int i = 0; i < nRows(); ++i )
2862 switch( rowType(i) )
2867 if( spxSense() == MINIMIZE )
2869 primalRowIds[primalrowsidx] = rId(i);
2871 dualcols.
add(lhs(i), 0.0, rowVector(i),
infinity);
2873 primalRowIds[primalrowsidx] = rId(i);
2875 dualcols.
add(rhs(i), -
infinity, rowVector(i), 0.0);
2879 primalRowIds[primalrowsidx] = rId(i);
2881 dualcols.
add(lhs(i), -
infinity, rowVector(i), 0.0);
2883 primalRowIds[primalrowsidx] = rId(i);
2885 dualcols.
add(rhs(i), 0.0, rowVector(i),
infinity);
2891 primalRowIds[primalrowsidx] = rId(i);
2893 if( spxSense() == MINIMIZE )
2894 dualcols.
add(lhs(i), 0.0, rowVector(i),
infinity);
2896 dualcols.
add(lhs(i), -
infinity, rowVector(i), 0.0);
2901 primalRowIds[primalrowsidx] = rId(i);
2903 if( spxSense() == MINIMIZE )
2904 dualcols.
add(rhs(i), -
infinity, rowVector(i), 0.0);
2906 dualcols.
add(rhs(i), 0.0, rowVector(i),
infinity);
2910 assert(
EQ(lhs(i), rhs(i)) );
2911 primalRowIds[primalrowsidx] = rId(i);
2926 for(
int i = 0; i < primalrowsidx; i++ )
2927 dualColIds[i] = dualLP.
cId(i + numVarBoundCols);
2929 (*nprimalrows) = primalrowsidx;
2930 (*ndualcols) = primalrowsidx;
const VectorBase< R > & rhs() const
Returns right hand side vector.
Rational spxAbs(const Rational &r)
Absolute.
bool isNotZero(Real a, Real eps=Param::epsilon())
returns true iff |a| > eps
void getRhsUnscaled(VectorBase< Real > &vec) const
Gets unscaled right hand side vector.
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
static void MPSreadCols(MPSInput &mps, const LPRowSetBase< Real > &rset, const NameSet &rnames, LPColSetBase< Real > &cset, NameSet &cnames, DIdxSet *intvars)
Process COLUMNS section.
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.
Safe arrays of data objects.Class DataArray provides safe arrays of Data Objects. For general C++ obj...
#define INIT_NZOS
initialy allocated non zeros.
const VectorBase< R > & lower() const
static bool LPFisFree(const char *s)
const VectorBase< R > & upper() const
Returns upper bound vector.
THREADLOCAL const Real infinity
int num() const
returns nr. of names in NameSet.
static void MPSreadRanges(MPSInput &mps, LPRowSetBase< Real > &rset, const NameSet &rnames, SPxOut *spxout)
Process RANGES section.
T * get_ptr()
get a C pointer to the data.
const VectorBase< R > & lhs() const
Returns the vector of lhs values.
int size() const
Number of used indices.
static Real LPFreadValue(char *&pos, SPxOut *spxout)
Read the next number and advance pos.
Exception classes for SoPlex.
static void MPSreadObjsen(MPSInput &mps)
Process OBJSEN section. This Section is an ILOG extension.
#define INIT_COLS
Read LP in MPS File Format.
bool NE(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| > eps
static Real MPSgetRHS(Real left, Real right)
void add(const LPColBase< R > &pcol)
R & value(int n)
Reference to value of n 'th nonzero.
static void LPFwriteSVector(const SPxLPBase< Real > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const SVectorBase< Real > &p_svec)
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.
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 void LPFwriteGenerals(const SPxLPBase< Real > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const DIdxSet *p_intvars)
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.
static void LPFwriteRow(const SPxLPBase< Real > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const SVectorBase< Real > &p_svec, const Real &p_lhs, const Real &p_rhs)
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 ...
static void LPFwriteObjective(const SPxLPBase< Real > &p_lp, std::ostream &p_output, const NameSet *p_cnames)
static const char * getColName(const SPxLPBase< Real > &p_lp, int p_idx, const NameSet *p_cnames, char *p_buf)
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 Real LPFreadInfinity(char *&pos)
static void MPSreadBounds(MPSInput &mps, LPColSetBase< Real > &cset, const NameSet &cnames, DIdxSet *intvars, SPxOut *spxout)
Process BOUNDS section.
void getLowerUnscaled(DVector &vec) const
Gets unscaled lower bound vector.
static bool LPFhasRowName(char *&pos, NameSet *rownames)
If buf start with "name:" store the name in rownames and advance pos.
#define NUM_ENTRIES_PER_LINE
static void LPFwriteRows(const SPxLPBase< Real > &p_lp, std::ostream &p_output, const NameSet *p_rnames, const NameSet *p_cnames)
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.
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
virtual void addRows(const LPRowSetBase< R > &pset, bool scale=false)
void addIdx(int i)
adds index i to the index set
const VectorBase< R > & lhs() const
Returns left hand side vector.
static int LPFreadColName(char *&pos, NameSet *colnames, LPColSetBase< Real > &colset, const LPColBase< Real > *emptycol, SPxOut *spxout)
Read the next column name from the input.
static const char * LPFgetRowName(const SPxLPBase< Real > &p_lp, int p_idx, const NameSet *p_rnames, char *p_buf, int p_num_written_rows)
Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ...
void add(const char *str)
static void MPSreadRows(MPSInput &mps, LPRowSetBase< Real > &rset, NameSet &rnames, SPxOut *spxout)
Process ROWS section.
(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 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.
bool EQ(Real a, Real b, Real eps=Param::epsilon())
returns true iff |a-b| <= eps
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 LPFwriteBounds(const SPxLPBase< Real > &p_lp, std::ostream &p_output, const NameSet *p_cnames)
static void MPSreadObjname(MPSInput &mps)
Process OBJNAME section. This Section is an ILOG extension.
void clear()
Remove all indices.
Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa...
#define LPF_MAX_LINE_LEN
maximum length of a line (8190 + \n + \0)
Set of LP columns.Class LPColSetBase implements a set of LPColBase%s. Unless for memory limitations...
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.
static void MPSreadRhs(MPSInput &mps, LPRowSetBase< Real > &rset, const NameSet &rnames, SPxOut *spxout)
Process RHS section.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
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.
DVectorBase< Real > DVector
static bool LPFisColName(const char *s)
Is there a possible column name at the beginning of s ?
virtual void changeSense(SPxSense sns)
Changes optimization sense to sns.
void getUpperUnscaled(DVector &vec) const
Gets unscaled upper bound vector.
void unscaleLP()
unscales the lp and clears basis
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.
int nCols() const
Returns number of columns in LP.
static bool LPFisSpace(int c)
Is c a space, tab, nl or cr ?
static const char * MPSgetRowName(const SPxLPBase< Real > &lp, int idx, const NameSet *rnames, char *buf)
Ids for LP rows.Class SPxRowId provides DataKeys for the row indices of an SPxLP. ...
bool isZero(Real a, Real eps=Param::epsilon())
returns true iff |a| <= eps
void setColVector(const SVectorBase< R > &p_vec)
Sets constraint column vector.
void getLhsUnscaled(VectorBase< Real > &vec) const
Returns unscaled left hand side vector.
VectorBase< R > & rhs_w()
Returns the vector of rhs values (writeable).
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.
SVectorBase< R > & create(int pnonzeros=0, const R &plhs=0, const R &prhs=1, const R &pobj=0, const int &pscaleExp=0)
Creates new LPRowBase with specified parameters and returns a reference to its row vector...
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
int num() const
Returns the number of LPColBases currently in LPColSetBase.
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?
virtual void addCols(const LPColSetBase< R > &pset, bool scale=false)
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)
static void MPSwriteRecord(std::ostream &os, const char *indicator, const char *name, const char *name1=0, const Real value1=0.0, const char *name2=0, const Real value2=0.0)