38 throw ErrorClass(
"Error trying to read MPS file");
45 std::ostringstream outStr;
47 outStr <<
"Detected " <<
m_nOfSOS <<
" special ordered sets" << std::endl;
50 int numberEntries =
m_SOS[i]->numberEntries();
51 const int * which =
m_SOS[i]->which();
52 const double * weights =
m_SOS[i]->weights();
53 outStr <<
"SOS " << i <<
" has type " <<
m_SOS[i]->setType();
54 outStr <<
" and " << numberEntries <<
" entries:" << std::endl;
55 for (
int j=0;
j<numberEntries;
j++)
56 outStr <<
" Idx: " << which[
j] <<
" Weight: " << weights[
j] << std::endl;
64 while (
m_MpsData->reader()->whichSection ( ) != COIN_ENDATA_SECTION )
66 switch (
m_MpsData->reader()->whichSection ( ))
68 case COIN_QUAD_SECTION:
73 if (status != -2 && status != -3)
74 throw ErrorClass(
"Error trying to read QUADOBJ section");
79 std::ostringstream outStr;
80 int numberColumns=
m_MpsData->getNumCols();
81 outStr <<
"Quadratic objective has " <<
m_quadColumnStart[numberColumns] <<
" entries" << std::endl;
82 outStr <<
"Column starts:" << std::endl;
83 for (
int i=0; i<=numberColumns; i++)
85 for (
int i=0; i<numberColumns; i++)
89 outStr <<
"Column " << i <<
": index value" << std::endl;
101 case COIN_CONIC_SECTION:
106 if (status != -2 && status != -3)
107 throw ErrorClass(
"Error trying to read cone section");
112 std::ostringstream outStr;
113 outStr <<
"Conic section has " <<
m_nOfCones <<
" cones" << std::endl;
117 outStr <<
"(type " <<
m_coneType[i] <<
"):" << std::endl;
118 for (
int j=m_coneStart[i];
j<m_coneStart[i+1];
j++)
129 case COIN_BASIS_SECTION:
132 std::ostringstream outStr;
133 outStr <<
"Basis section has not been implemented yet" << std::endl;
140 throw ErrorClass(
"encountered unknown section in MPS file");
197 int numnonz =
m_MpsData->getNumElements();
200 std::ostringstream outStr;
210 for(i = 0; i < numvar; i++)
227 double objWeight = 1.0;
230 double *p =
const_cast<double*
>(
m_MpsData->getObjCoefficients());
231 for(i = 0; i < numvar; i++)
233 objectiveCoefficients->
indexes[i] = i;
234 objectiveCoefficients->
values[i] = *(p++);
240 "min",
m_MpsData->objectiveOffset(), objWeight, objectiveCoefficients) ;
241 delete objectiveCoefficients;
242 objectiveCoefficients = NULL;
247 double constant = 0.0;
248 for(i = 0; i < numrows; i++)
257 int valuesEnd = numnonz - 1;
259 int indexesBegin = 0;
260 int indexesEnd = numnonz - 1;
270 int numberColumns=
m_MpsData->getNumCols();
272 if (numberElements > 0)
274 int *rowindexes =
new int[numberElements];
275 for (
int i=0; i<numberElements;i++)
277 int *colindexes =
new int[numberElements];
278 for (
int i=0; i<numberColumns; i++)
int * m_quadColumnStart
Data structures to hold the quadratic objective.
bool setQuadraticCoefficients(int number, int *rowIndexes, int *varOneIndexes, int *varTwoIndexes, double *coefficients, int begin, int end)
set quadratic coefficients into the QuadraticCoefficients->qTerm data structure
bool addVariable(int index, std::string name, double lowerBound, double upperBound, char type)
add a variable.
const OSSmartPtr< OSOutput > osoutput
IntVector * rowIdx
a pointer of row indices if the problem is stored by column
bool setLinearConstraintCoefficients(int numberOfValues, bool isColumnMajor, double *values, int valuesBegin, int valuesEnd, int *indexes, int indexesBegin, int indexesEnd, int *starts, int startsBegin, int startsEnd)
set linear constraint coefficients
IntVector * colIdx
a pointer of column indices if the problem is stored by row
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the instance represented in M...
int m_nOfSOS
Data structures to hold special ordered sets.
IntVector * start
a pointer to the start of each row or column stored in sparse format
bool setInstanceName(std::string name)
set the instance name.
int m_nOfCones
Data structures to hold the cone information.
bool setConstraintNumber(int number)
set the number of constraints.
DoubleVector * value
a pointer to the array of nonzero values being stored
bool setObjectiveNumber(int number)
set the number of objectives.
bool addConstraint(int index, std::string name, double lowerBound, double upperBound, double constant)
add a constraint.
bool addObjective(int index, std::string name, std::string maxOrMin, double constant, double weight, SparseVector *objectiveCoefficients)
add an objective.
a sparse vector data structure
~OSmps2OS()
the OSmps2os class destructor
bool createOSObjects()
create an OSInstance from the MPS instance representation and an OSOption in case of nonstandard sect...
InstanceData * instanceData
A pointer to an InstanceData object.
OSmps2OS(std::string mpsfilename)
the OSmps2OS class constructor
CoinPackedMatrix * m_CoinPackedMatrix
m_CoinPackedMatrix is a pointer to a CoinPackedMatrix object
CoinMpsIO * m_MpsData
m_MpsData is a pointer to a CoinMpsIO object
double * values
values holds a double array of nonzero values.
int * indexes
indexes holds an integer array of indexes whose corresponding values are nonzero. ...
bool setVariableNumber(int number)
set the number of variables.
The in-memory representation of an OSiL instance..
used for throwing exceptions.
LinearConstraintCoefficients * linearConstraintCoefficients
linearConstraintCoefficients is a pointer to a LinearConstraintCoefficients object ...