spxlpbase_rational.cpp
Go to the documentation of this file.
36 // --------------------------------------------------------------------------------------------------------------------- 38 // --------------------------------------------------------------------------------------------------------------------- 101 /** If only a sign is encountered, the number is assumed to be \c sign * 1. This routine will not catch malformatted 175 MSG_WARNING( (*spxout), (*spxout) << "WLPFRD03 Warning: In line " << lineno << ": malformed rational value in LP file\n";) 184 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" ); 197 MSG_WARNING( (*spxout), (*spxout) <<"WLPFRD04 Warning: In line " << lineno << ": malformed rational value in LP file\n" ); 219 static int LPFreadColName(char*& pos, NameSet* colnames, LPColSetBase<Rational>& colset, const LPColBase<Rational>* emptycol, SPxOut* spxout) 284 /** \p keyword should be lower case. It can contain optional sections which are enclosed in '[' ']' like "min[imize]". 316 // we have to be at the end of the keyword and the word found on the line also has to end here. Attention: The 317 // LPFisSense is a kludge to allow LPFhasKeyword also to process Inf[inity] keywords in the bounds section. 403 * This routine should read (most?) valid LP format files. What it will not do, is find all cases where a file is ill 406 * Problem: A line ending in '+' or '-' followed by a line starting with a number, will be regarded as an error. 408 * The reader will accept the keyword INT[egers] as a synonym for GEN[erals] which is an undocumented feature in CPLEX. 412 * The manual says the maximum allowed line length is 255 characters, but CPLEX does not complain if the lines are 653 /* Already having here a value could only result from being the first number in a constraint, or a sign 683 /* Already having here a value could only result from being the first number in a constraint, or a sign 779 // We have a row like c1: <= 5 with no variables. We can not handle 10 <= 5; issue a syntax error. 864 /* Do we have only a single column name in the input line? We could ignore this savely, but it is probably 874 MSG_WARNING( (*spxout), (*spxout) << "WLPFRD12 in Binary/General section line " << lineno << " ignored" << std::endl; ) 932 // --------------------------------------------------------------------------------------------------------------------- 934 // --------------------------------------------------------------------------------------------------------------------- 1038 static void MPSreadRows(MPSInput& mps, LPRowSetBase<Rational>& rset, NameSet& rnames, SPxOut* spxout) 1046 MSG_INFO2( (*spxout), (*spxout) << "IMPSRD02 Objective name : " << mps.objName() << std::endl; ) 1099 static void MPSreadCols(MPSInput& mps, const LPRowSetBase<Rational>& rset, const NameSet& rnames, LPColSetBase<Rational>& cset, NameSet& cnames, DIdxSet* intvars, SPxOut* spxout) 1164 MSG_WARNING( (*spxout), (*spxout) <<"WMPSRD01 Warning: malformed rational value in MPS file\n" ); 1184 MSG_WARNING( (*spxout), (*spxout) <<"WMPSRD02 Warning: malformed rational value in MPS file\n" ); 1205 static void MPSreadRhs(MPSInput& mps, LPRowSetBase<Rational>& rset, const NameSet& rnames, SPxOut* spxout) 1230 if( ((mps.field2() != 0) && (mps.field3() == 0)) || ((mps.field4() != 0) && (mps.field5() == 0)) ) 1256 MSG_WARNING( (*spxout), (*spxout) <<"WMPSRD03 Warning: malformed rational value in MPS file\n" ); 1275 MSG_WARNING( (*spxout), (*spxout) <<"WMPSRD04 Warning: malformed rational value in MPS file\n" ); 1295 static void MPSreadRanges(MPSInput& mps, LPRowSetBase<Rational>& rset, const NameSet& rnames, SPxOut* spxout) 1317 if( ((mps.field2() != 0) && (mps.field3() == 0)) || ((mps.field4() != 0) && (mps.field5() == 0)) ) 1346 MSG_WARNING( (*spxout), (*spxout) <<"WMPSRD05 Warning: malformed rational value in MPS file\n" ); 1350 if( (double(rset.lhs(idx)) > -double(infinity)) && (double(rset.rhs_w(idx)) < double(infinity)) ) 1384 MSG_WARNING( (*spxout), (*spxout) <<"WMPSRD06 Warning: malformed rational value in MPS file\n" ); 1388 if( (double(rset.lhs(idx)) > -double(infinity)) && (double(rset.rhs(idx)) < double(infinity)) ) 1423 static void MPSreadBounds(MPSInput& mps, LPColSetBase<Rational>& cset, const NameSet& cnames, DIdxSet* intvars, SPxOut* spxout) 1482 MSG_WARNING( (*spxout), (*spxout) <<"WMPSRD07 Warning: malformed rational value in MPS file\n" ); 1492 // if the variable has appeared in the MARKER section of the COLUMNS section then its default bounds were 1493 // set to 0,1; the first time it is declared integer we need to change to default bounds 0,infinity 1550 * The specification is taken from the IBM Optimization Library Guide and Reference, online available at 1551 * http://www.software.ibm.com/sos/features/libuser.htm and from the ILOG CPLEX 7.0 Reference Manual, Appendix E, Page 1554 * This routine should read all valid MPS format files. What it will not do, is find all cases where a file is ill 1646 changeSense(mps.objSense() == MPSInput::MINIMIZE ? SPxLPBase<Rational>::MINIMIZE : SPxLPBase<Rational>::MAXIMIZE); 1648 MSG_INFO2( (*spxout), (*spxout) << "IMPSRD06 Objective sense: " << ((mps.objSense() == MPSInput::MINIMIZE) ? "Minimize\n" : "Maximize\n") ); 1676 // --------------------------------------------------------------------------------------------------------------------- 1678 // --------------------------------------------------------------------------------------------------------------------- 1763 // insert a line break every NUM_ENTRIES_PER_LINE columns or whenever max line length is nearly exceeded 1765 (long long)(p_output.tellp()) - pos + (long long)(rationalToString(coeff, false).length() + 100) > MAX_LINE_WRITE_LEN ) 1771 MSG_WARNING( (*spxout), (*spxout) << "XLPSWR01 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" ); 1832 sidelen = (p_lhs == p_rhs || double(p_lhs) <= double(-infinity)) ? (long long)rationalToString(p_rhs, false).length() : (long long)rationalToString(p_lhs, false).length(); 1840 MSG_WARNING( (*spxout), (*spxout) << "XLPSWR02 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" ); 1860 MSG_WARNING( (*spxout), (*spxout) << "XLPSWR03 Warning: MAX_LINE_WRITE_LEN possibly exceeded when writing LP file\n" ); 1960 MSG_WARNING( (*spxout), (*spxout) << "XLPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing LP file\n" ); 2011 // --------------------------------------------------------------------------------------------------------------------- 2013 // --------------------------------------------------------------------------------------------------------------------- 2048 MSG_WARNING( (*spxout), (*spxout) << "XMPSWR04 Warning: MAX_LINE_WRITE_LEN exceeded when writing MPS file\n" ); 2177 MPSwriteRecord(p_output, 0, getColName(*this, i, p_cnames, name), spxout, "MINIMIZE", -maxObj(i)); 2228 MPSwriteRecord(p_output, "", "RANGE", spxout, MPSgetRowName(*this, i, p_rnames, name1), range); 2246 MPSwriteRecord(p_output, "FX", "BOUND", spxout, getColName(*this, i, p_cnames, name1), lower(i)); 2259 MPSwriteRecord(p_output, "LO", "BOUND", spxout, getColName(*this, i, p_cnames, name1), lower(i)); 2268 MPSwriteRecord(p_output, "UP", "BOUND", spxout, getColName(*this, i, p_cnames, name1), upper(i)); 2274 MPSwriteRecord(p_output, "UP", "BOUND", spxout, getColName(*this, i, p_cnames, name1), upper(i)); 2284 MSG_WARNING( (*spxout), (*spxout) << "XMPSWR03 Warning: objective function inverted when writing maximization problem in MPS file format\n" ); 2290 // --------------------------------------------------------------------------------------------------------------------- 2292 // --------------------------------------------------------------------------------------------------------------------- Definition: mpsinput.h:52 Definition: mpsinput.h:34 static int LPFreadColName(char *&pos, NameSet *colnames, LPColSetBase< Rational > &colset, const LPColBase< Rational > *emptycol, SPxOut *spxout) Read the next column name from the input. Definition: spxlpbase_rational.cpp:219 Definition: mpsinput.h:45 Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b... Definition: exceptions.h:109 static bool LPFisValue(const char *s) Is there a number at the beginning of s ? Definition: spxlpbase_rational.cpp:51 static void MPSreadRows(MPSInput &mps, LPRowSetBase< Rational > &rset, NameSet &rnames, SPxOut *spxout) Process ROWS section. Definition: spxlpbase_rational.cpp:1038 static Rational LPFreadInfinity(char *&pos) Definition: spxlpbase_rational.cpp:386 const VectorBase< R > & maxObj() const Returns objective vector for maximization problem. Definition: spxlpbase.h:384 static void MPSreadBounds(MPSInput &mps, LPColSetBase< Rational > &cset, const NameSet &cnames, DIdxSet *intvars, SPxOut *spxout) Process BOUNDS section. Definition: spxlpbase_rational.cpp:1423 static const char * MPSgetRowName(const SPxLPBase< Rational > &lp, int idx, const NameSet *rnames, char *buf) Definition: spxlpbase_rational.cpp:2070 void entryIgnored(const char *what, const char *what_name, const char *entity, const char *entity_name) Definition: mpsinput.h:205 Read MPS format files. int num() const Returns the number of LPColBases currently in LPColSetBase. Definition: lpcolsetbase.h:80 static void MPSreadRhs(MPSInput &mps, LPRowSetBase< Rational > &rset, const NameSet &rnames, SPxOut *spxout) Process RHS section. Definition: spxlpbase_rational.cpp:1205 Definition: mpsinput.h:45 Exception classes for SoPlex. static void MPSreadObjsen(MPSInput &mps) Process OBJSEN section. This Section is an ILOG extension. Definition: spxlpbase_rational.cpp:973 static void MPSreadCols(MPSInput &mps, const LPRowSetBase< Rational > &rset, const NameSet &rnames, LPColSetBase< Rational > &cset, NameSet &cnames, DIdxSet *intvars, SPxOut *spxout) Process COLUMNS section. Definition: spxlpbase_rational.cpp:1099 static Rational LPFreadValue(char *&pos, SPxOut *spxout, const int lineno=-1) Read the next number and advance pos. Definition: spxlpbase_rational.cpp:104 Definition: mpsinput.h:45 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. Definition: lpcolsetbase.h:98 static const char * getColName(const SPxLP *lp, int idx, const NameSet *cnames, char *buf) Definition: spxbasis.cpp:563 Wrapper for GMP type mpq_class.We wrap mpq_class so that we can replace it by a double type if GMP is... Definition: rational.h:45 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 ... Definition: datakey.h:46 #define MAX_LINE_WRITE_LEN maximum length allowed for writing lines Definition: spxlpbase_rational.cpp:32 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) Definition: spxlpbase_rational.cpp:1815 Wrapper for different output streams and verbosity levels. Exception class for out of memory exceptions.This class is derived from the SoPlex exception base cla... Definition: exceptions.h:70 static bool LPFhasRowName(char *&pos, NameSet *rownames) If buf start with "name:" store the name in rownames and advance pos. Definition: spxlpbase_rational.cpp:333 static void LPFwriteBounds(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, SPxOut *spxout) Definition: spxlpbase_rational.cpp:1907 #define MSG_INFO2(spxout, x) Prints out message x if the verbosity level is at least SPxOut::INFO2. Definition: spxdefines.h:115 static bool LPFisSense(const char *s) Is there a comparison operator at the beginning of s ? Definition: spxlpbase_rational.cpp:73 Definition: mpsinput.h:45 Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth... Definition: spxout.h:63 virtual bool readLPF(std::istream &in, NameSet *rowNames=0, NameSet *colNames=0, DIdxSet *intVars=0) Reads LP in LP format from input stream in. #define MSG_ERROR(x) Prints out message x if the verbosity level is at least SPxOut::ERROR. Definition: spxdefines.h:109 static void LPFwriteSVector(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const SVectorBase< Rational > &p_svec, SPxOut *spxout) Definition: spxlpbase_rational.cpp:1737 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. Dynamic index set.Class DIdxSet provides dynamic IdxSet in the sense, that no restrictions are posed ... Definition: didxset.h:42 static void MPSreadRanges(MPSInput &mps, LPRowSetBase< Rational > &rset, const NameSet &rnames, SPxOut *spxout) Process RANGES section. Definition: spxlpbase_rational.cpp:1295 Definition: mpsinput.h:45 (In)equality for LPs.Class LPRowBase provides constraints for linear programs in the form where a is... Definition: lprowbase.h:45 Debugging, floating point type and parameter definitions. Definition: mpsinput.h:53 Set of strings.Class NameSet implements a symbol or name table. It allows to store or remove names (i... Definition: nameset.h:61 Definition: mpsinput.h:45 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) Definition: spxlpbase_rational.cpp:1867 static void MPSreadObjname(MPSInput &mps) Process OBJNAME section. This Section is an ILOG extension. Definition: spxlpbase_rational.cpp:1009 Saving LPs in a form suitable for SoPlex.Class SPxLPBase provides the data structures required for sa... Definition: spxlpbase.h:76 virtual void writeLPF(std::ostream &out, const NameSet *rowNames, const NameSet *colNames, const DIdxSet *p_intvars=0) const #define MSG_WARNING(spxout, x) Prints out message x if the verbosity level is at least SPxOut::WARNING. Definition: spxdefines.h:111 void setRowVector(const DSVectorBase< R > &p_vec) access constraint row vector. Definition: lprowbase.h:245 int number(const DataKey &pkey) const returns number of name with DataKey pkey in NameSet. Definition: nameset.h:212 Definition: mpsinput.h:45 Set of LP rows.Class LPRowSetBase implements a set of LPRowBase%s. Unless for memory limitations... Definition: lprowsetbase.h:44 static int LPFreadSense(char *&pos) Read the next <,>,=,==,<=,=<,>=,=> and advance pos. Definition: spxlpbase_rational.cpp:262 static bool LPFisColName(const char *s) Is there a possible column name at the beginning of s ? Definition: spxlpbase_rational.cpp:59 static void LPFwriteObjective(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, SPxOut *spxout) Definition: spxlpbase_rational.cpp:1791 Definition: mpsinput.h:45 static bool LPFhasKeyword(char *&pos, const char *keyword) Is the keyword present in buf ? If yes, advance pos. Definition: spxlpbase_rational.cpp:286 const VectorBase< R > & rhs() const Returns the vector of rhs values. Definition: lprowsetbase.h:129 static Rational MPSgetRHS(Rational left, Rational right) Definition: spxlpbase_rational.cpp:2054 #define LPF_MAX_LINE_LEN maximum length of a line (8190 + \n + \0) Definition: spxlpbase_rational.cpp:40 void insertName(const char *name, bool second=false) Inserts name as field 1 and shifts all other fields up. Definition: mpsinput.cpp:250 Definition: mpsinput.h:56 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) Definition: spxlpbase_rational.cpp:2016 const SVectorBase< R > & rowVector(int i) const Gets row vector of row i. Definition: spxlpbase.h:212 void setColVector(const SVectorBase< R > &p_vec) Sets constraint column vector. Definition: lpcolbase.h:154 static void LPFwriteGenerals(const SPxLPBase< Rational > &p_lp, std::ostream &p_output, const NameSet *p_cnames, const DIdxSet *p_intvars) Definition: spxlpbase_rational.cpp:1969 static const char * LPFgetRowName(const SPxLPBase< Rational > &p_lp, int p_idx, const NameSet *p_rnames, char *p_buf, int p_num_written_rows) Definition: spxlpbase_rational.cpp:1681 std::string rationalToString(const Rational &r, const int precision) convert rational number to string Definition: rational.cpp:3468 #define MSG_INFO3(spxout, x) Prints out message x if the verbosity level is at least SPxOut::INFO3. Definition: spxdefines.h:117 VectorBase< R > & rhs_w() Returns the vector of rhs values (writeable). Definition: lprowsetbase.h:135 void reMax(int newmax=0) Reallocates memory to be able to store newmax LPColBases. Definition: lpcolsetbase.h:502 LP column.Class LPColBase provides a datatype for storing the column of an LP a the form similar to ... Definition: lpcolbase.h:45 static void MPSreadName(MPSInput &mps, SPxOut *spxout) Process NAME section. Definition: spxlpbase_rational.cpp:937 |