31 int status =
m_MpsData->readMps( &mpsfilename[ 0],
"", nOfSOS, SOS );
33 throw ErrorClass(
"Error trying to read MPS file");
40 std::ostringstream outStr;
42 outStr <<
"Detected " << nOfSOS <<
" special ordered sets" << std::endl;
43 for (
int i=0; i < nOfSOS; i++)
45 int numberEntries = SOS[i]->numberEntries();
46 const int * which = SOS[i]->which();
47 const double * weights = SOS[i]->weights();
48 outStr <<
"SOS " << i <<
" has type " << SOS[i]->setType();
49 outStr <<
" and " << numberEntries <<
" entries:" << std::endl;
50 for (
int j=0;
j<numberEntries;
j++)
51 outStr <<
" Idx: " << which[
j] <<
" Weight: " << weights[
j] << std::endl;
59 #if 0 // Not yet supported
60 int * columnStart = NULL;
61 int * columnIdx = NULL;
62 double * elements = NULL;
63 status =
m_MpsData->readQuadraticMps(NULL, columnStart, columnIdx, elements, 0);
67 if (status != -2 && status != -3)
68 throw ErrorClass(
"Error trying to read QUADOBJ section");
73 std::ostringstream outStr;
74 int numberColumns=
m_MpsData->getNumCols();
75 outStr <<
"Quadratic objective has " << columnStart[numberColumns] <<
" entries" << std::endl;
76 outStr <<
"Column starts:" << std::endl;
77 for (
int i=0; i<=numberColumns; i++)
78 outStr <<
" " << columnStart[i] << std::endl;
79 for (
int i=0; i<numberColumns; i++)
81 if (columnStart[i] < columnStart[i+1])
83 outStr <<
"Column " << i <<
": index value" << std::endl;
84 for (
int j=columnStart[i];
j<columnStart[i+1];
j++)
85 outStr <<
" " << columnIdx[
j] <<
" " << elements[
j] << std::endl;
94 int * coneStart = NULL;
96 int * coneType = NULL;
97 status =
m_MpsData->readConicMps(NULL, coneStart, coneIdx, coneType, nOfCones);
100 if (status != -2 && status != -3)
101 throw ErrorClass(
"Error trying to read cone section");
106 std::ostringstream outStr;
107 outStr <<
"Conic section has " << nOfCones <<
" cones" << std::endl;
108 for (
int i=0;i<nOfCones;i++)
110 outStr <<
"Cone " << i <<
" has " << coneStart[i+1]-coneStart[i] <<
" entries ";
111 outStr <<
"(type " << coneType[i] <<
"):" << std::endl;
112 for (
int j=coneStart[i];
j<coneStart[i+1];
j++)
113 outStr <<
" " << coneIdx[
j] << std::endl;
149 int numnonz =
m_MpsData->getNumElements();
152 double objWeight = 1.0;
158 for(i = 0; i < numvar; i++)
169 double *p =
const_cast<double*
>(
m_MpsData->getObjCoefficients());
170 for(i = 0; i < numvar; i++)
172 objectiveCoefficients->
indexes[i] = i;
173 objectiveCoefficients->
values[i] = *(p++);
179 "min",
m_MpsData->objectiveOffset(), objWeight, objectiveCoefficients) ;
180 delete objectiveCoefficients;
181 objectiveCoefficients = NULL;
186 double constant = 0.0;
187 for(i = 0; i < numrows; i++)
196 int valuesEnd = numnonz - 1;
198 int indexesBegin = 0;
199 int indexesEnd = numnonz - 1;
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
~OSmps2osil()
the OSmps2osil class destructor
IntVector * colIdx
a pointer of column indices if the problem is stored by row
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.
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
InstanceData * instanceData
A pointer to an InstanceData object.
bool createOSInstance()
create an OSInstance from the MPS instance representation
double * values
values holds a double array of nonzero values.
CoinPackedMatrix * m_CoinPackedMatrix
m_CoinPackedMatrix is a pointer to a CoinPackedMatrix object
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..
OSInstance * osinstance
osinstance is a pointer to the OSInstance object that gets created from the instance represented in N...
OSmps2osil(std::string mpsfilename)
the OSmps2osil class constructor
used for throwing exceptions.
LinearConstraintCoefficients * linearConstraintCoefficients
linearConstraintCoefficients is a pointer to a LinearConstraintCoefficients object ...
CoinMpsIO * m_MpsData
m_MpsData is a pointer to a CoinMpsIO object