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());
529 newVal = lp_scaler->scaleElement(*
this, i, j, val);
534 if (row.
pos(j) >= 0 && col.
pos(i) >= 0)
545 else if (row.
pos(j) >= 0 && col.
pos(i) >= 0)
551 assert(isConsistent());
558 #define LPF_MAX_LINE_LEN 8192 563 return (c ==
' ') || (c ==
'\t') || (c ==
'\n') || (c ==
'\r');
571 return ((*s >=
'0') && (*s <=
'9')) || (*s ==
'+') || (*s ==
'-') || (*s ==
'.');
583 return ((*s >=
'A') && (*s <=
'Z'))
584 || ((*s >=
'a') && (*s <=
'z'))
585 || (strchr(
"!\"#$%&()/,;?@_'`{}|~", *s) != 0);
593 return (*s ==
'<') || (*s ==
'>') || (*s ==
'=');
600 return ((s[0] ==
'-') || (s[0] ==
'+'))
601 && (tolower(s[1]) ==
'i')
602 && (tolower(s[2]) ==
'n')
603 && (tolower(s[3]) ==
'f');
610 return (tolower(s[0]) ==
'f')
611 && ( tolower(s[1]) ==
'r')
612 && ( tolower(s[2]) ==
'e')
613 && ( tolower(s[3]) ==
'e');
630 bool has_digits =
false;
631 bool has_emptyexponent =
false;
634 if( (*s ==
'+') || (*s ==
'-') )
638 while( (*s >=
'0') && (*s <=
'9') )
650 while( (*s >=
'0') && (*s <=
'9') )
658 if( tolower(*s) ==
'e' )
660 has_emptyexponent =
true;
664 if( (*s ==
'+') || (*s ==
'-') )
668 while( (*s >=
'0') && (*s <=
'9') )
670 has_emptyexponent =
false;
676 if( has_emptyexponent )
678 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD01 Warning: found empty exponent in LP file - check for forbidden variable names with initial 'e' or 'E'\n"; )
682 value = (*pos ==
'-') ? -1.0 : 1.0;
685 for( t = tmp; pos != s; pos++ )
695 MSG_DEBUG( std::cout <<
"DLPFRD01 LPFreadValue = " << value << std::endl; )
713 assert(colnames != 0);
721 while( (strchr(
"+-.<>= ", *s) == 0) && (*s !=
'\0') )
724 for( i = 0; pos != s; i++, pos++ )
729 if( (colidx = colnames->
number(name)) < 0 )
733 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD02 Unknown variable \"" << name <<
"\" "; )
736 colidx = colnames->
num();
738 colset.
add(*emptycol);
742 MSG_DEBUG( std::cout <<
"DLPFRD03 LPFreadColName [" << name <<
"] = " << colidx << std::endl; )
759 if( (*pos ==
'<') || (*pos ==
'>') )
761 else if( *pos ==
'=' )
764 MSG_DEBUG( std::cout <<
"DLPFRD04 LPFreadSense = " << static_cast<char>(sense) << std::endl; )
782 assert(keyword != 0);
784 for( i = 0, k = 0; keyword[i] !=
'\0'; i++, k++ )
786 if( keyword[i] ==
'[' )
791 while( (tolower(pos[k]) == keyword[i]) && (pos[k] !=
'\0') )
796 while( keyword[i] !=
']' )
802 if( keyword[i] != tolower(pos[k]) )
813 MSG_DEBUG( std::cout <<
"DLPFRD05 LPFhasKeyword: " << keyword << std::endl; )
826 const char* s = strchr(pos,
':');
831 int dcolpos = int(s - pos);
837 for( end = dcolpos-1; end >= 0; end-- )
844 pos = &(pos[dcolpos+1]);
849 for( srt = end-1; srt >= 0; srt-- )
850 if( pos[srt] ==
' ' )
856 assert(srt <= end && pos[srt] !=
' ');
862 for( i = srt; i <= end; i++ )
870 pos = &(pos[dcolpos+1]);
881 Real sense = (*pos ==
'-') ? -1.0 : 1.0;
909 std::istream& p_input,
916 START, OBJECTIVE, CONSTRAINTS, BOUNDS, INTEGERS, BINARIES
937 bool finished =
false;
939 bool have_value =
true;
952 cnames =
new (cnames)
NameSet();
965 rnames =
new (rnames)
NameSet();
988 if( !p_input.getline(buf,
sizeof(buf)) )
993 <<
" characters" << std::endl; )
997 MSG_ERROR( std::cerr <<
"ELPFRD07 No 'End' marker found" << std::endl; )
1006 MSG_DEBUG( std::cout <<
"DLPFRD08 Reading line " << lineno
1007 <<
" (pos=" << pos <<
")" << std::endl; )
1010 if( 0 != (s = strchr(buf,
'\\')) )
1014 if( section == START )
1019 section = OBJECTIVE;
1024 section = OBJECTIVE;
1027 else if( section == OBJECTIVE )
1035 for(
int j = vec.
size() - 1; j >= 0; --j )
1041 section = CONSTRAINTS;
1044 else if( section == CONSTRAINTS &&
1087 if( section == OBJECTIVE )
1091 if( section == CONSTRAINTS )
1100 for( k = 0; pos[i] !=
'\0'; i++ )
1107 if( tmp[0] ==
'\0' )
1111 for( i = 0, k = 0; tmp[i] !=
'\0'; i++ )
1113 while( ((tmp[i] ==
'+') || (tmp[i] ==
'-')) && ((tmp[i + 1] ==
'+') || (tmp[i + 1] ==
'-')) )
1115 if( tmp[i++] ==
'-' )
1116 tmp[i] = (tmp[i] ==
'-') ?
'+' :
'-';
1127 MSG_DEBUG( std::cout <<
"DLPFRD09 pos=" << pos << std::endl; )
1130 while( (pos != 0) && (*pos !=
'\0') )
1141 Real pre_sign = 1.0;
1165 vec.
add(colidx, val);
1170 Real pre_sign = 1.0;
1194 else if( sense ==
'>' )
1201 assert(sense ==
'=');
1238 int n = vec.
pos(colidx);
1242 vec.
add(colidx, val);
1246 assert(vec.
index(n) == colidx);
1248 val += vec.
value(n);
1255 assert(cnames->
has(colidx));
1257 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD10 Duplicate index " 1258 << (*cnames)[colidx]
1259 <<
" in line " << lineno
1278 assert(!have_value);
1301 if( (colidx =
LPFreadColName(pos, cnames, cset, 0, spxout)) < 0 )
1303 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD11 in Bounds section line " 1304 << lineno <<
" ignored" << std::endl; )
1313 else if( sense ==
'>' )
1317 assert(sense ==
'=');
1342 else if( sense ==
'>' )
1346 assert(sense ==
'=');
1360 if( (colidx =
LPFreadColName(pos, cnames, cset, 0, spxout)) < 0 )
1362 MSG_WARNING( (*spxout), (*spxout) <<
"WLPFRD12 in Binary/General section line " << lineno <<
" ignored" << std::endl; )
1366 if( section == BINARIES )
1368 if( cset.
lower(colidx) < 0.0 )
1372 if( cset.
upper(colidx) > 1.0 )
1378 if( p_intvars != 0 )
1379 p_intvars->
addIdx(colidx);
1383 MSG_ERROR( std::cerr <<
"ELPFRD13 This seems to be no LP format file" << std::endl; )
1389 if( pos == pos_old )
1394 assert(isConsistent());
1397 assert(isConsistent());
1400 assert(isConsistent());
1405 MSG_INFO2( (*spxout), (*spxout) <<
"Finished reading " << lineno <<
" lines" << std::endl; )
1408 MSG_ERROR( std::cerr <<
"ELPFRD15 Syntax error in line " << lineno << std::endl; )
1436 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD01 Problem name : " << mps.
probName() << std::endl; )
1442 if( !strcmp(mps.
field0(),
"ROWS") )
1444 else if( !strncmp(mps.
field0(),
"OBJSEN", 6) )
1446 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1469 if( !strcmp(mps.
field1(),
"MIN") )
1471 else if( !strcmp(mps.
field1(),
"MAX") )
1480 if( !strcmp(mps.
field0(),
"ROWS") )
1482 else if( !strcmp(mps.
field0(),
"OBJNAME") )
1511 if( strcmp(mps.
field0(),
"ROWS") )
1534 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD02 Objective name : " << mps.
objName() << std::endl; )
1536 if( strcmp(mps.
field0(),
"COLUMNS") )
1547 if( *mps.
field1() ==
'N' )
1594 char colname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1605 if( strcmp(mps.
field0(),
"RHS") )
1608 if( colname[0] !=
'\0' )
1623 if( strcmp(colname, mps.
field1()) )
1626 if( colname[0] !=
'\0' )
1628 col.setColVector(vec);
1634 colname[MPSInput::MAX_LINE_LEN-1] =
'\0';
1636 cnames.
add(colname);
1644 assert(cnames.
number(colname) == cset.
num());
1654 val = atof(mps.
field3());
1662 else if( val != 0.0 )
1668 assert(mps.
field4() != 0);
1670 val = atof(mps.
field5());
1678 else if( val != 0.0 )
1692 char rhsname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1693 char addname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1701 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD03 RHS name : " << rhsname << std::endl; );
1703 if( !strcmp(mps.
field0(),
"RANGES") )
1705 else if( !strcmp(mps.
field0(),
"BOUNDS") )
1707 else if( !strcmp(mps.
field0(),
"ENDATA") )
1721 if( *rhsname ==
'\0' )
1724 if( strcmp(rhsname, mps.
field1()) )
1726 if( strcmp(addname, mps.
field1()) )
1728 assert(strlen(mps.
field1()) < MPSInput::MAX_LINE_LEN);
1730 MSG_INFO3( (*spxout), (*spxout) <<
"IMPSRD07 RHS ignored : " << addname << std::endl );
1739 val = atof(mps.
field3());
1743 rset.
rhs_w(idx) = val;
1746 rset.
lhs_w(idx) = val;
1755 val = atof(mps.
field5());
1759 rset.
rhs_w(idx) = val;
1762 rset.
lhs_w(idx) = val;
1776 char rngname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1784 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD04 Range name : " << rngname << std::endl; );
1786 if( !strcmp(mps.
field0(),
"BOUNDS") )
1788 else if( !strcmp(mps.
field0(),
"ENDATA") )
1802 if( *rngname ==
'\0' )
1804 assert(strlen(mps.
field1()) < MPSInput::MAX_LINE_LEN);
1817 if( !strcmp(rngname, mps.
field1()) )
1823 val = atof(mps.
field3());
1828 assert(rset.
lhs(idx) == rset.
rhs(idx));
1831 rset.
rhs_w(idx) += val;
1833 rset.
lhs_w(idx) += val;
1852 val = atof(mps.
field5());
1857 assert(rset.
lhs(idx) == rset.
rhs(idx));
1860 rset.
rhs_w(idx) += val;
1862 rset.
lhs_w(idx) += val;
1887 char bndname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1895 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD05 Bound name : " << bndname << std::endl; )
1897 if( strcmp(mps.
field0(),
"ENDATA") )
1906 if( (!strcmp(mps.
field1(),
"LO"))
1907 || (!strcmp(mps.
field1(),
"UP"))
1908 || (!strcmp(mps.
field1(),
"FX"))
1909 || (!strcmp(mps.
field1(),
"LI"))
1910 || (!strcmp(mps.
field1(),
"UI")) )
1924 if( *bndname ==
'\0' )
1926 assert(strlen(mps.
field2()) < MPSInput::MAX_LINE_LEN);
1931 if( !strcmp(bndname, mps.
field2()) )
1939 else if( !strcmp(mps.
field4(),
"-Inf") || !strcmp(mps.
field4(),
"-inf") )
1941 else if( !strcmp(mps.
field4(),
"Inf") || !strcmp(mps.
field4(),
"inf") || !strcmp(mps.
field4(),
"+Inf") || !strcmp(mps.
field4(),
"+inf") )
1944 val = atof(mps.
field4());
1947 if( mps.
field1()[1] ==
'I' )
1954 if( oldbinvars.
pos(idx) < 0 )
1970 if( mps.
field1()[1] ==
'X' )
2019 #define INIT_COLS 10000 2020 #define INIT_NZOS 100000
2023 std::istream& p_input,
2039 cnames =
new (cnames)
NameSet();
2052 rnames =
new (rnames)
NameSet();
2076 if( mps.
section() == MPSInput::OBJSEN )
2079 if( mps.
section() == MPSInput::OBJNAME )
2085 addedRows(rset.
num());
2087 if( mps.
section() == MPSInput::COLUMNS )
2088 MPSreadCols(mps, rset, *rnames, cset, *cnames, p_intvars);
2090 if( mps.
section() == MPSInput::RHS )
2093 if( mps.
section() == MPSInput::RANGES )
2096 if( mps.
section() == MPSInput::BOUNDS )
2099 if( mps.
section() != MPSInput::ENDATA )
2108 MSG_INFO2( (*spxout), (*spxout) <<
"IMPSRD06 Objective sense: " << ((mps.
objSense() == MPSInput::MINIMIZE) ?
"Minimize\n" :
"Maximize\n") );
2114 addedCols(cset.
num());
2116 assert(isConsistent());
2146 int p_num_written_rows
2151 assert(p_idx < p_lp.
nRows());
2157 if( p_rnames->
has(key) )
2158 return (*p_rnames)[key];
2161 spxSnprintf(p_buf, 16,
"C%d", p_num_written_rows);
2178 assert(p_idx < p_lp.
nCols());
2184 if( p_cnames->
has(key) )
2185 return (*p_cnames)[key];
2196 #define NUM_ENTRIES_PER_LINE 5 2199 std::ostream& p_output,
2207 for(
int j = 0; j < p_lp.
nCols(); ++j )
2209 const Real coeff = p_svec[j];
2214 if( num_coeffs == 0 )
2215 p_output << coeff <<
" " <<
getColName(p_lp, j, p_cnames, name);
2223 p_output <<
" - " << -coeff;
2225 p_output <<
" + " << coeff;
2227 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name);
2239 std::ostream& p_output,
2246 p_output << ((sense == SPxLPBase<Real>::MINIMIZE) ?
"Minimize\n" :
"Maximize\n");
2247 p_output <<
" obj: ";
2251 svec.operator=(obj);
2252 svec *=
Real(sense);
2262 std::ostream& p_output,
2272 if( p_lhs == p_rhs )
2273 p_output <<
" = " << p_rhs;
2275 p_output <<
" <= " << p_rhs;
2279 p_output <<
" >= " << p_lhs;
2290 std::ostream& p_output,
2298 p_output <<
"Subject To\n";
2300 for(
int i = 0; i < p_lp.
nRows(); ++i )
2308 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_1 : ";
2311 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_2 : ";
2316 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
" : ";
2328 std::ostream& p_output,
2335 p_output <<
"Bounds\n";
2337 for(
int j = 0; j < p_lp.
nCols(); ++j )
2342 if( lower == upper )
2344 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
" = " << upper <<
'\n';
2352 p_output <<
" " << lower <<
" <= " 2354 <<
" <= " << upper <<
'\n';
2356 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2357 <<
" <= " << upper <<
'\n';
2359 else if( lower != 0 )
2360 p_output <<
" " << lower <<
" <= " 2365 p_output <<
" -Inf <= " 2367 <<
" <= " << upper <<
'\n';
2369 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2379 std::ostream& p_output,
2387 if( p_intvars == NULL || p_intvars->
size() <= 0 )
2390 p_output <<
"Generals\n";
2392 for(
int j = 0; j < p_lp.
nCols(); ++j )
2393 if( p_intvars->
pos(j) >= 0 )
2394 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
"\n";
2402 std::ostream& p_output,
2408 SPxOut::setScientific(p_output, 16);
2415 p_output <<
"End" << std::endl;
2426 const char* indicator,
2428 const char* name1 = 0,
2429 const Real value1 = 0.0,
2430 const char* name2 = 0,
2431 const Real value2 = 0.0
2436 sprintf(buf,
" %-2.2s %-8.8s", (indicator == 0) ?
"" : indicator, (name == 0) ?
"" : name);
2481 assert(idx < lp.
nRows());
2487 if( rnames->
has(key) )
2488 return (*rnames)[key];
2503 std::ostream& p_output,
2510 const char* indicator;
2514 bool has_ranges =
false;
2518 SPxOut::setScientific(p_output, 16);
2520 p_output <<
"NAME MPSDATA" << std::endl;
2523 p_output <<
"ROWS" << std::endl;
2525 for( i = 0; i < nRows(); i++ )
2527 if( lhs(i) == rhs(i) )
2547 p_output <<
"COLUMNS" << std::endl;
2549 bool has_intvars = (p_intvars != 0) && (p_intvars->
size() > 0);
2551 for(
int j = 0; j < (has_intvars ? 2 : 1); j++ )
2553 bool is_intrun = has_intvars && (j == 1);
2556 p_output <<
" MARK0001 'MARKER' 'INTORG'" << std::endl;
2558 for( i = 0; i < nCols(); i++ )
2560 bool is_intvar = has_intvars && (p_intvars->
pos(i) >= 0);
2562 if( ( is_intrun && !is_intvar) || (!is_intrun && is_intvar) )
2566 int colsize2 = (col.
size() / 2) * 2;
2568 assert(colsize2 % 2 == 0);
2570 for( k = 0; k < colsize2; k += 2 )
2575 if( colsize2 != col.
size() )
2584 p_output <<
" MARK0001 'MARKER' 'INTEND'" << std::endl;
2588 p_output <<
"RHS" << std::endl;
2591 while( i < nRows() )
2596 for( ; i < nRows(); i++ )
2597 if( (rhsval1 =
MPSgetRHS(lhs(i), rhs(i))) != 0.0 )
2602 for( k = i + 1; k < nRows(); k++ )
2604 if( (rhsval2 =
MPSgetRHS(lhs(k), rhs(k))) != 0.0 )
2623 p_output <<
"RANGES" << std::endl;
2625 for( i = 0; i < nRows(); i++ )
2633 p_output <<
"BOUNDS" << std::endl;
2635 for( i = 0; i < nCols(); i++ )
2643 if( lower(i) == upper(i) )
2655 if( lower(i) != 0.0 )
2663 if( has_intvars && (p_intvars->
pos(i) >= 0) )
2678 p_output <<
"ENDATA" << std::endl;
2683 MSG_WARNING( (*spxout), (*spxout) <<
"XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n" );
2694 SPxRowId dualRowIds[],
SPxColId dualColIds[],
int* nprimalrows,
int* nprimalcols,
int* ndualrows,
int* ndualcols)
2697 if( primalRowIds == 0 || primalColIds == 0 || dualRowIds == 0 || dualColIds == 0 )
2703 int numprimalrows = 0;
2704 int numprimalcols = 0;
2705 int numdualrows = 0;
2706 int numdualcols = 0;
2709 dualcolids.
get_ptr(), &numprimalrows, &numprimalcols, &numdualrows, &numdualcols);
2711 if( primalRowIds != 0 )
2713 primalRowIds = primalrowids.
get_ptr();
2714 (*nprimalrows) = numprimalrows;
2717 if( primalColIds != 0 )
2719 primalColIds = primalcolids.
get_ptr();
2720 (*nprimalcols) = numprimalcols;
2723 if( dualRowIds != 0 )
2725 dualRowIds = dualrowids.
get_ptr();
2726 (*ndualrows) = numdualrows;
2729 if( dualColIds != 0 )
2731 dualColIds = dualcolids.
get_ptr();
2732 (*ndualcols) = numdualcols;
2739 if( spxSense() == MINIMIZE )
2748 int numAddedRows = 0;
2749 int numVarBoundCols = 0;
2750 int primalrowsidx = 0;
2751 int primalcolsidx = 0;
2753 for(
int i = 0; i < nCols(); ++i )
2755 primalColIds[primalcolsidx] = cId(i);
2759 dualrows.
create(0, obj(i), obj(i));
2766 if( spxSense() == MINIMIZE )
2773 col.
add(numAddedRows, 1.0);
2774 if( spxSense() == MINIMIZE )
2776 dualrows.
create(0, obj(i), obj(i));
2781 dualrows.
create(0, obj(i), obj(i));
2794 if( spxSense() == MINIMIZE )
2801 col.
add(numAddedRows, 1.0);
2802 if( spxSense() == MINIMIZE )
2804 dualrows.
create(0, obj(i), obj(i));
2809 dualrows.
create(0, obj(i), obj(i));
2818 else if (
NE(lower(i), upper(i)) )
2822 col.
add(numAddedRows, 1.0);
2823 if( spxSense() == MINIMIZE )
2837 else if(
isZero(upper(i)) )
2839 col.
add(numAddedRows, 1.0);
2840 if( spxSense() == MINIMIZE )
2856 dualrows.
create(0, obj(i), obj(i));
2858 col.
add(numAddedRows, 1.0);
2859 if( spxSense() == MINIMIZE )
2871 numVarBoundCols += 2;
2877 assert(lower(i) == upper(i));
2879 dualrows.
create(0, obj(i), obj(i));
2881 col.
add(numAddedRows, 1.0);
2886 numVarBoundCols += 2;
2896 for(
int i = 0; i < primalcolsidx; i++ )
2897 dualRowIds[i] = dualLP.
rId(i);
2899 (*nprimalcols) = primalcolsidx;
2900 (*ndualrows) = primalcolsidx;
2903 for(
int i = 0; i < nRows(); ++i )
2906 switch( rowType(i) )
2911 if( spxSense() == MINIMIZE )
2913 primalRowIds[primalrowsidx] = rId(i);
2915 dualcols.
add(lhs(i), 0.0, rowVector(i),
infinity);
2917 primalRowIds[primalrowsidx] = rId(i);
2919 dualcols.
add(rhs(i), -
infinity, rowVector(i), 0.0);
2923 primalRowIds[primalrowsidx] = rId(i);
2925 dualcols.
add(lhs(i), -
infinity, rowVector(i), 0.0);
2927 primalRowIds[primalrowsidx] = rId(i);
2929 dualcols.
add(rhs(i), 0.0, rowVector(i),
infinity);
2935 primalRowIds[primalrowsidx] = rId(i);
2937 if( spxSense() == MINIMIZE )
2938 dualcols.
add(lhs(i), 0.0, rowVector(i),
infinity);
2940 dualcols.
add(lhs(i), -
infinity, rowVector(i), 0.0);
2945 primalRowIds[primalrowsidx] = rId(i);
2947 if( spxSense() == MINIMIZE )
2948 dualcols.
add(rhs(i), -
infinity, rowVector(i), 0.0);
2950 dualcols.
add(rhs(i), 0.0, rowVector(i),
infinity);
2954 assert(
EQ(lhs(i), rhs(i)) );
2955 primalRowIds[primalrowsidx] = rId(i);
2970 for(
int i = 0; i < primalrowsidx; i++ )
2971 dualColIds[i] = dualLP.
cId(i + numVarBoundCols);
2973 (*nprimalrows) = primalrowsidx;
2974 (*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)
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
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)