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;)
50 if(primal.
dim() != nCols())
53 if(activity.
dim() != nRows())
58 for(c = 0; c < nCols() && primal[c] == 0; c++)
69 if(unscaled && _isScaled)
71 lp_scaler->getColUnscaled(*
this, c, tmp);
75 activity = colVector(c);
77 activity *= primal[c];
80 for(; c < nCols(); c++)
84 if(unscaled && _isScaled)
86 lp_scaler->getColUnscaled(*
this, c, tmp);
87 activity.
multAdd(primal[c], tmp);
90 activity.
multAdd(primal[c], colVector(c));
97 const bool unscaled)
const 99 if(dual.
dim() != nRows())
102 if(activity.
dim() != nCols())
107 for(r = 0; r < nRows() && dual[r] == 0; r++)
118 if(unscaled && _isScaled)
120 lp_scaler->getRowUnscaled(*
this, r, tmp);
124 activity = rowVector(r);
129 for(; r < nRows(); r++)
133 if(unscaled && _isScaled)
135 lp_scaler->getRowUnscaled(*
this, r, tmp);
136 activity.
multAdd(dual[r], tmp);
139 activity.
multAdd(dual[r], rowVector(r));
149 if(unscaled && _isScaled)
151 assert(lp_scaler != 0);
153 for(
int i = 0; i < nCols(); ++i)
155 Real m = lp_scaler->getColMaxAbsUnscaled(*
this, i);
163 for(
int i = 0; i < nCols(); ++i)
165 Real m = colVector(i).maxAbs();
182 if(unscaled && _isScaled)
184 assert(lp_scaler != 0);
186 for(
int i = 0; i < nCols(); ++i)
188 Real m = lp_scaler->getColMinAbsUnscaled(*
this, i);
196 for(
int i = 0; i < nCols(); ++i)
198 Real m = colVector(i).minAbs();
217 lp_scaler->getMaxObjUnscaled(*
this, pobj);
224 if(spxSense() == MINIMIZE)
232 assert(i >= 0 && i < nRows());
235 lp_scaler->getRowUnscaled(*
this, i, vec);
254 assert(i >= 0 && i < nRows());
257 return lp_scaler->rhsUnscaled(*
this, i);
266 assert(
id.isValid());
267 return rhsUnscaled(number(
id));
284 assert(i >= 0 && i < nRows());
287 return lp_scaler->lhsUnscaled(*
this, i);
296 assert(
id.isValid());
297 return lhsUnscaled(number(
id));
304 assert(i >= 0 && i < nCols());
307 lp_scaler->getColUnscaled(*
this, i, vec);
316 assert(
id.isValid());
317 getColVectorUnscaled(number(
id), vec);
324 assert(i >= 0 && i < nCols());
329 res = lp_scaler->maxObjUnscaled(*
this, i);
336 if(spxSense() == MINIMIZE)
346 assert(
id.isValid());
347 return objUnscaled(number(
id));
355 lp_scaler->getMaxObjUnscaled(*
this, vec);
364 assert(i >= 0 && i < nCols());
367 return lp_scaler->maxObjUnscaled(*
this, i);
376 assert(
id.isValid());
377 return maxObjUnscaled(number(
id));
394 assert(i >= 0 && i < nCols());
397 return lp_scaler->upperUnscaled(*
this, i);
406 assert(
id.isValid());
407 return upperUnscaled(number(
id));
424 assert(i >= 0 && i < nCols());
427 return lp_scaler->lowerUnscaled(*
this, i);
436 assert(
id.isValid());
437 return lowerUnscaled(number(
id));
444 assert(maxObj().dim() == newObj.
dim());
455 assert(isConsistent());
462 assert(lower().dim() == newLower.
dim());
474 assert(isConsistent());
482 assert(upper().dim() == newUpper.
dim());
494 assert(isConsistent());
501 assert(lhs().dim() == newLhs.
dim());
512 assert(isConsistent());
519 assert(rhs().dim() == newRhs.
dim());
530 assert(isConsistent());
551 newVal = lp_scaler->scaleElement(*
this, i, j, val);
556 if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
567 else if(row.
pos(j) >= 0 && col.
pos(i) >= 0)
573 assert(isConsistent());
580 #define LPF_MAX_LINE_LEN 8192 585 return (c ==
' ') || (c ==
'\t') || (c ==
'\n') || (c ==
'\r');
593 return ((*s >=
'0') && (*s <=
'9')) || (*s ==
'+') || (*s ==
'-') || (*s ==
'.');
605 return ((*s >=
'A') && (*s <=
'Z'))
606 || ((*s >=
'a') && (*s <=
'z'))
607 || (strchr(
"!\"#$%&()/,;?@_'`{}|~", *s) != 0);
615 return (*s ==
'<') || (*s ==
'>') || (*s ==
'=');
622 return ((s[0] ==
'-') || (s[0] ==
'+'))
623 && (tolower(s[1]) ==
'i')
624 && (tolower(s[2]) ==
'n')
625 && (tolower(s[3]) ==
'f');
632 return (tolower(s[0]) ==
'f')
633 && (tolower(s[1]) ==
'r')
634 && (tolower(s[2]) ==
'e')
635 && (tolower(s[3]) ==
'e');
652 bool has_digits =
false;
653 bool has_emptyexponent =
false;
656 if((*s ==
'+') || (*s ==
'-'))
660 while((*s >=
'0') && (*s <=
'9'))
672 while((*s >=
'0') && (*s <=
'9'))
680 if(tolower(*s) ==
'e')
682 has_emptyexponent =
true;
686 if((*s ==
'+') || (*s ==
'-'))
690 while((*s >=
'0') && (*s <=
'9'))
692 has_emptyexponent =
false;
699 if(has_emptyexponent)
702 "WLPFRD01 Warning: found empty exponent in LP file - check for forbidden variable names with initial 'e' or 'E'\n";
707 value = (*pos ==
'-') ? -1.0 : 1.0;
710 for(t = tmp; pos != s; pos++)
721 MSG_DEBUG(std::cout <<
"DLPFRD01 LPFreadValue = " << value << std::endl;)
740 assert(colnames != 0);
748 while((strchr(
"+-.<>= ", *s) == 0) && (*s !=
'\0'))
751 for(i = 0; pos != s; i++, pos++)
756 if((colidx = colnames->
number(name)) < 0)
760 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD02 Unknown variable \"" << name <<
"\" ";)
763 colidx = colnames->
num();
765 colset.
add(*emptycol);
769 MSG_DEBUG(std::cout <<
"DLPFRD03 LPFreadColName [" << name <<
"] = " << colidx << std::endl;)
786 if((*pos ==
'<') || (*pos ==
'>'))
791 MSG_DEBUG(std::cout <<
"DLPFRD04 LPFreadSense = " << static_cast<char>(sense) << std::endl;)
809 assert(keyword != 0);
811 for(i = 0, k = 0; keyword[i] !=
'\0'; i++, k++)
813 if(keyword[i] ==
'[')
818 while((tolower(pos[k]) == keyword[i]) && (pos[k] !=
'\0'))
824 while(keyword[i] !=
']')
831 if(keyword[i] != tolower(pos[k]))
842 MSG_DEBUG(std::cout <<
"DLPFRD05 LPFhasKeyword: " << keyword << std::endl;)
855 const char* s = strchr(pos,
':');
860 int dcolpos = int(s - pos);
866 for(end = dcolpos - 1; end >= 0; end--)
873 pos = &(pos[dcolpos + 1]);
878 for(srt = end - 1; srt >= 0; srt--)
885 assert(srt <= end && pos[srt] !=
' ');
891 for(i = srt; i <= end; i++)
899 pos = &(pos[dcolpos + 1]);
910 Real sense = (*pos ==
'-') ? -1.0 : 1.0;
938 std::istream& p_input,
945 START, OBJECTIVE, CONSTRAINTS, BOUNDS, INTEGERS, BINARIES
966 bool finished =
false;
968 bool have_value =
true;
981 cnames =
new(cnames)
NameSet();
994 rnames =
new(rnames)
NameSet();
1018 if(!p_input.getline(buf,
sizeof(buf)))
1023 <<
" characters" << std::endl;)
1027 MSG_ERROR(std::cerr <<
"ELPFRD07 No 'End' marker found" << std::endl;)
1038 MSG_DEBUG(std::cout <<
"DLPFRD08 Reading line " << lineno
1039 <<
" (pos=" << pos <<
")" << std::endl;)
1042 if(0 != (s = strchr(buf,
'\\')))
1046 if(section == START)
1051 section = OBJECTIVE;
1056 section = OBJECTIVE;
1059 else if(section == OBJECTIVE)
1067 for(
int j = vec.
size() - 1; j >= 0; --j)
1074 section = CONSTRAINTS;
1077 else if(section == CONSTRAINTS &&
1120 if(section == OBJECTIVE)
1124 if(section == CONSTRAINTS)
1133 for(k = 0; pos[i] !=
'\0'; i++)
1144 for(i = 0, k = 0; tmp[i] !=
'\0'; i++)
1146 while(((tmp[i] ==
'+') || (tmp[i] ==
'-')) && ((tmp[i + 1] ==
'+') || (tmp[i + 1] ==
'-')))
1149 tmp[i] = (tmp[i] ==
'-') ?
'+' :
'-';
1162 MSG_DEBUG(std::cout <<
"DLPFRD09 pos=" << pos << std::endl;)
1165 while((pos != 0) && (*pos !=
'\0'))
1176 Real pre_sign = 1.0;
1206 vec.
add(colidx, val);
1212 Real pre_sign = 1.0;
1246 else if(sense ==
'>')
1253 assert(sense ==
'=');
1293 int n = vec.
pos(colidx);
1297 vec.
add(colidx, val);
1301 assert(vec.
index(n) == colidx);
1303 val += vec.
value(n);
1310 assert(cnames->
has(colidx));
1312 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD10 Duplicate index " 1313 << (*cnames)[colidx]
1314 <<
" in line " << lineno
1335 assert(!have_value);
1362 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD11 in Bounds section line " 1363 << lineno <<
" ignored" << std::endl;)
1372 else if(sense ==
'>')
1376 assert(sense ==
'=');
1401 else if(sense ==
'>')
1405 assert(sense ==
'=');
1423 MSG_WARNING((*spxout), (*spxout) <<
"WLPFRD12 in Binary/General section line " << lineno <<
1424 " ignored" << std::endl;)
1428 if(section == BINARIES)
1430 if(cset.
lower(colidx) < 0.0)
1435 if(cset.
upper(colidx) > 1.0)
1442 p_intvars->
addIdx(colidx);
1448 MSG_ERROR(std::cerr <<
"ELPFRD13 This seems to be no LP format file" << std::endl;)
1460 assert(isConsistent());
1463 assert(isConsistent());
1466 assert(isConsistent());
1472 MSG_INFO2((*spxout), (*spxout) <<
"Finished reading " << lineno <<
" lines" << std::endl;)
1475 MSG_ERROR(std::cerr <<
"ELPFRD15 Syntax error in line " << lineno << std::endl;)
1504 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD01 Problem name : " << mps.
probName() << std::endl;)
1510 if(!strcmp(mps.
field0(),
"ROWS"))
1512 else if(!strncmp(mps.
field0(),
"OBJSEN", 6))
1514 else if(!strcmp(mps.
field0(),
"OBJNAME"))
1537 if(!strcmp(mps.
field1(),
"MIN"))
1539 else if(!strcmp(mps.
field1(),
"MAX"))
1548 if(!strcmp(mps.
field0(),
"ROWS"))
1550 else if(!strcmp(mps.
field0(),
"OBJNAME"))
1579 if(strcmp(mps.
field0(),
"ROWS"))
1602 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD02 Objective name : " << mps.
objName() << std::endl;)
1604 if(strcmp(mps.
field0(),
"COLUMNS"))
1666 char colname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1677 if(strcmp(mps.
field0(),
"RHS"))
1680 if(colname[0] !=
'\0')
1695 if(strcmp(colname, mps.
field1()))
1698 if(colname[0] !=
'\0')
1700 col.setColVector(vec);
1706 colname[MPSInput::MAX_LINE_LEN - 1] =
'\0';
1708 int ncnames = cnames.
size();
1709 cnames.
add(colname);
1712 if(cnames.
size() <= ncnames)
1714 MSG_ERROR(std::cerr <<
"ERROR in COLUMNS: duplicate column name or not column-wise ordering" <<
1726 assert(cnames.
number(colname) == cset.
num());
1736 val = atof(mps.
field3());
1750 assert(mps.
field4() != 0);
1752 val = atof(mps.
field5());
1775 char rhsname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1776 char addname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1784 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD03 RHS name : " << rhsname << std::endl;);
1786 if(!strcmp(mps.
field0(),
"RANGES"))
1788 else if(!strcmp(mps.
field0(),
"BOUNDS"))
1790 else if(!strcmp(mps.
field0(),
"ENDATA"))
1804 if(*rhsname ==
'\0')
1807 if(strcmp(rhsname, mps.
field1()))
1809 if(strcmp(addname, mps.
field1()))
1811 assert(strlen(mps.
field1()) < MPSInput::MAX_LINE_LEN);
1813 MSG_INFO3((*spxout), (*spxout) <<
"IMPSRD07 RHS ignored : " << addname << std::endl);
1822 val = atof(mps.
field3());
1826 rset.
rhs_w(idx) = val;
1830 rset.
lhs_w(idx) = val;
1839 val = atof(mps.
field5());
1843 rset.
rhs_w(idx) = val;
1847 rset.
lhs_w(idx) = val;
1862 char rngname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1870 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD04 Range name : " << rngname << std::endl;);
1872 if(!strcmp(mps.
field0(),
"BOUNDS"))
1874 else if(!strcmp(mps.
field0(),
"ENDATA"))
1888 if(*rngname ==
'\0')
1890 assert(strlen(mps.
field1()) < MPSInput::MAX_LINE_LEN);
1903 if(!strcmp(rngname, mps.
field1()))
1909 val = atof(mps.
field3());
1914 assert(rset.
lhs(idx) == rset.
rhs(idx));
1917 rset.
rhs_w(idx) += val;
1919 rset.
lhs_w(idx) += val;
1938 val = atof(mps.
field5());
1943 assert(rset.
lhs(idx) == rset.
rhs(idx));
1946 rset.
rhs_w(idx) += val;
1948 rset.
lhs_w(idx) += val;
1974 char bndname[MPSInput::MAX_LINE_LEN] = {
'\0' };
1982 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD05 Bound name : " << bndname << std::endl;)
1984 if(strcmp(mps.
field0(),
"ENDATA"))
1993 if((!strcmp(mps.
field1(),
"LO"))
1994 || (!strcmp(mps.
field1(),
"UP"))
1995 || (!strcmp(mps.
field1(),
"FX"))
1996 || (!strcmp(mps.
field1(),
"LI"))
1997 || (!strcmp(mps.
field1(),
"UI")))
2011 if(*bndname ==
'\0')
2013 assert(strlen(mps.
field2()) < MPSInput::MAX_LINE_LEN);
2018 if(!strcmp(bndname, mps.
field2()))
2026 else if(!strcmp(mps.
field4(),
"-Inf") || !strcmp(mps.
field4(),
"-inf"))
2028 else if(!strcmp(mps.
field4(),
"Inf") || !strcmp(mps.
field4(),
"inf")
2029 || !strcmp(mps.
field4(),
"+Inf") || !strcmp(mps.
field4(),
"+inf"))
2032 val = atof(mps.
field4());
2035 if(mps.
field1()[1] ==
'I')
2042 if(oldbinvars.
pos(idx) < 0)
2060 if(mps.
field1()[1] ==
'X')
2115 #define INIT_COLS 10000 2116 #define INIT_NZOS 100000
2119 std::istream& p_input,
2135 cnames =
new(cnames)
NameSet();
2148 rnames =
new(rnames)
NameSet();
2173 if(mps.
section() == MPSInput::OBJSEN)
2176 if(mps.
section() == MPSInput::OBJNAME)
2182 addedRows(rset.
num());
2184 if(mps.
section() == MPSInput::COLUMNS)
2185 MPSreadCols(mps, rset, *rnames, cset, *cnames, p_intvars);
2187 if(mps.
section() == MPSInput::RHS)
2190 if(mps.
section() == MPSInput::RANGES)
2193 if(mps.
section() == MPSInput::BOUNDS)
2196 if(mps.
section() != MPSInput::ENDATA)
2206 MSG_INFO2((*spxout), (*spxout) <<
"IMPSRD06 Objective sense: " << ((mps.
objSense() ==
2207 MPSInput::MINIMIZE) ?
"Minimize\n" :
"Maximize\n"));
2213 addedCols(cset.
num());
2215 assert(isConsistent());
2245 int p_num_written_rows
2250 assert(p_idx < p_lp.
nRows());
2256 if(p_rnames->
has(key))
2257 return (*p_rnames)[key];
2260 spxSnprintf(p_buf, 16,
"C%d", p_num_written_rows);
2277 assert(p_idx < p_lp.
nCols());
2283 if(p_cnames->
has(key))
2284 return (*p_cnames)[key];
2295 #define NUM_ENTRIES_PER_LINE 5 2298 std::ostream& p_output,
2306 for(
int j = 0; j < p_lp.
nCols(); ++j)
2308 const Real coeff = p_svec[j];
2314 p_output << coeff <<
" " <<
getColName(p_lp, j, p_cnames, name);
2322 p_output <<
" - " << -coeff;
2324 p_output <<
" + " << coeff;
2326 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name);
2338 std::ostream& p_output,
2345 p_output << ((sense == SPxLPBase<Real>::MINIMIZE) ?
"Minimize\n" :
"Maximize\n");
2346 p_output <<
" obj: ";
2350 svec.operator = (obj);
2351 svec *=
Real(sense);
2361 std::ostream& p_output,
2372 p_output <<
" = " << p_rhs;
2374 p_output <<
" <= " << p_rhs;
2378 p_output <<
" >= " << p_lhs;
2389 std::ostream& p_output,
2397 p_output <<
"Subject To\n";
2399 for(
int i = 0; i < p_lp.
nRows(); ++i)
2407 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_1 : ";
2410 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
"_2 : ";
2415 p_output <<
" " <<
LPFgetRowName(p_lp, i, p_rnames, name, i) <<
" : ";
2427 std::ostream& p_output,
2434 p_output <<
"Bounds\n";
2436 for(
int j = 0; j < p_lp.
nCols(); ++j)
2443 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
" = " << upper <<
'\n';
2451 p_output <<
" " << lower <<
" <= " 2453 <<
" <= " << upper <<
'\n';
2455 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2456 <<
" <= " << upper <<
'\n';
2459 p_output <<
" " << lower <<
" <= " 2464 p_output <<
" -Inf <= " 2466 <<
" <= " << upper <<
'\n';
2468 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name)
2478 std::ostream& p_output,
2486 if(p_intvars == NULL || p_intvars->
size() <= 0)
2489 p_output <<
"Generals\n";
2491 for(
int j = 0; j < p_lp.
nCols(); ++j)
2492 if(p_intvars->
pos(j) >= 0)
2493 p_output <<
" " <<
getColName(p_lp, j, p_cnames, name) <<
"\n";
2501 std::ostream& p_output,
2507 SPxOut::setScientific(p_output, 16);
2514 p_output <<
"End" << std::endl;
2525 const char* indicator,
2527 const char* name1 = 0,
2528 const Real value1 = 0.0,
2529 const char* name2 = 0,
2530 const Real value2 = 0.0
2535 spxSnprintf(buf,
sizeof(buf),
" %-2.2s %-8.8s", (indicator == 0) ?
"" : indicator,
2536 (name == 0) ?
"" : name);
2581 assert(idx < lp.
nRows());
2587 if(rnames->
has(key))
2588 return (*rnames)[key];
2603 std::ostream& p_output,
2610 const char* indicator;
2614 bool has_ranges =
false;
2618 SPxOut::setScientific(p_output, 16);
2620 p_output <<
"NAME MPSDATA" << std::endl;
2623 p_output <<
"ROWS" << std::endl;
2625 for(i = 0; i < nRows(); i++)
2627 if(lhs(i) == rhs(i))
2647 p_output <<
"COLUMNS" << std::endl;
2649 bool has_intvars = (p_intvars != 0) && (p_intvars->
size() > 0);
2651 for(
int j = 0; j < (has_intvars ? 2 : 1); j++)
2653 bool is_intrun = has_intvars && (j == 1);
2656 p_output <<
" MARK0001 'MARKER' 'INTORG'" << std::endl;
2658 for(i = 0; i < nCols(); i++)
2660 bool is_intvar = has_intvars && (p_intvars->
pos(i) >= 0);
2662 if((is_intrun && !is_intvar) || (!is_intrun && is_intvar))
2666 int colsize2 = (col.
size() / 2) * 2;
2668 assert(colsize2 % 2 == 0);
2670 for(k = 0; k < colsize2; k += 2)
2675 if(colsize2 != col.
size())
2684 p_output <<
" MARK0001 'MARKER' 'INTEND'" << std::endl;
2688 p_output <<
"RHS" << std::endl;
2697 for(; i < nRows(); i++)
2698 if((rhsval1 =
MPSgetRHS(lhs(i), rhs(i))) != 0.0)
2703 for(k = i + 1; k < nRows(); k++)
2705 if((rhsval2 =
MPSgetRHS(lhs(k), rhs(k))) != 0.0)
2724 p_output <<
"RANGES" << std::endl;
2726 for(i = 0; i < nRows(); i++)
2734 p_output <<
"BOUNDS" << std::endl;
2736 for(i = 0; i < nCols(); i++)
2744 if(lower(i) == upper(i))
2764 if(has_intvars && (p_intvars->
pos(i) >= 0))
2779 p_output <<
"ENDATA" << std::endl;
2785 "XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n");
2797 SPxRowId dualRowIds[],
SPxColId dualColIds[],
int* nprimalrows,
int* nprimalcols,
int* ndualrows,
2801 if(primalRowIds == 0 || primalColIds == 0 || dualRowIds == 0 || dualColIds == 0)
2807 int numprimalrows = 0;
2808 int numprimalcols = 0;
2809 int numdualrows = 0;
2810 int numdualcols = 0;
2813 dualcolids.
get_ptr(), &numprimalrows, &numprimalcols, &numdualrows, &numdualcols);
2815 if(primalRowIds != 0)
2817 primalRowIds = primalrowids.
get_ptr();
2818 (*nprimalrows) = numprimalrows;
2821 if(primalColIds != 0)
2823 primalColIds = primalcolids.
get_ptr();
2824 (*nprimalcols) = numprimalcols;
2829 dualRowIds = dualrowids.
get_ptr();
2830 (*ndualrows) = numdualrows;
2835 dualColIds = dualcolids.
get_ptr();
2836 (*ndualcols) = numdualcols;
2843 if(spxSense() == MINIMIZE)
2852 int numAddedRows = 0;
2853 int numVarBoundCols = 0;
2854 int primalrowsidx = 0;
2855 int primalcolsidx = 0;
2857 for(
int i = 0; i < nCols(); ++i)
2859 primalColIds[primalcolsidx] = cId(i);
2864 dualrows.
create(0, obj(i), obj(i));
2871 if(spxSense() == MINIMIZE)
2878 col.
add(numAddedRows, 1.0);
2880 if(spxSense() == MINIMIZE)
2882 dualrows.
create(0, obj(i), obj(i));
2887 dualrows.
create(0, obj(i), obj(i));
2902 if(spxSense() == MINIMIZE)
2909 col.
add(numAddedRows, 1.0);
2911 if(spxSense() == MINIMIZE)
2913 dualrows.
create(0, obj(i), obj(i));
2918 dualrows.
create(0, obj(i), obj(i));
2929 else if(
NE(lower(i), upper(i)))
2933 col.
add(numAddedRows, 1.0);
2935 if(spxSense() == MINIMIZE)
2950 else if(
isZero(upper(i)))
2952 col.
add(numAddedRows, 1.0);
2954 if(spxSense() == MINIMIZE)
2971 dualrows.
create(0, obj(i), obj(i));
2973 col.
add(numAddedRows, 1.0);
2975 if(spxSense() == MINIMIZE)
2988 numVarBoundCols += 2;
2995 assert(lower(i) == upper(i));
2997 dualrows.
create(0, obj(i), obj(i));
2999 col.
add(numAddedRows, 1.0);
3004 numVarBoundCols += 2;
3014 for(
int i = 0; i < primalcolsidx; i++)
3015 dualRowIds[i] = dualLP.
rId(i);
3017 (*nprimalcols) = primalcolsidx;
3018 (*ndualrows) = primalcolsidx;
3021 for(
int i = 0; i < nRows(); ++i)
3030 if(spxSense() == MINIMIZE)
3032 primalRowIds[primalrowsidx] = rId(i);
3034 dualcols.
add(lhs(i), 0.0, rowVector(i),
infinity);
3036 primalRowIds[primalrowsidx] = rId(i);
3038 dualcols.
add(rhs(i), -
infinity, rowVector(i), 0.0);
3042 primalRowIds[primalrowsidx] = rId(i);
3044 dualcols.
add(lhs(i), -
infinity, rowVector(i), 0.0);
3046 primalRowIds[primalrowsidx] = rId(i);
3048 dualcols.
add(rhs(i), 0.0, rowVector(i),
infinity);
3055 primalRowIds[primalrowsidx] = rId(i);
3058 if(spxSense() == MINIMIZE)
3059 dualcols.
add(lhs(i), 0.0, rowVector(i),
infinity);
3061 dualcols.
add(lhs(i), -
infinity, rowVector(i), 0.0);
3067 primalRowIds[primalrowsidx] = rId(i);
3070 if(spxSense() == MINIMIZE)
3071 dualcols.
add(rhs(i), -
infinity, rowVector(i), 0.0);
3073 dualcols.
add(rhs(i), 0.0, rowVector(i),
infinity);
3078 assert(
EQ(lhs(i), rhs(i)));
3079 primalRowIds[primalrowsidx] = rId(i);
3094 for(
int i = 0; i < primalrowsidx; i++)
3095 dualColIds[i] = dualLP.
cId(i + numVarBoundCols);
3097 (*nprimalrows) = primalrowsidx;
3098 (*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 size() const
returns maximum DataKey::idx used in NameSet.
int number(const DataKey &pkey) const
returns number of name with DataKey pkey in NameSet.
void reMax(int newmax=0)
Reallocates memory to be able to store newmax LPColBases.
void setRhs(const R &p_right)
Sets right-hand side value.
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)