OsiData.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef OsiData_H
00011 #define OsiData_H
00012
00020 #include "CoinPackedMatrix.hpp"
00021
00022 class OsiData {
00023
00024 public:
00025
00028
00030 virtual void setInfinity(const double givenInfinity){
00031 infinity = givenInfinity;
00032 }
00033
00035 inline double getInfinity() const {return infinity;};
00036
00038 virtual void setNrow(const int givenNrow){
00039 nrow = givenNrow;
00040 }
00041
00043 inline int getNrow() const {return nrow;};
00044
00046 virtual void setNcol(const int givenNcol){
00047 ncol = givenNcol;
00048 }
00049
00051 inline int getNcol() const {return ncol;};
00052
00055 virtual void setMatrixByCol(const CoinPackedMatrix *givenMatrixByCol){
00056 matrixByCol = givenMatrixByCol;
00057 }
00058
00060 inline const CoinPackedMatrix *getMatrixByCol() const {return matrixByCol;};
00061
00064 virtual void setMatrixByRow(const CoinPackedMatrix *givenMatrixByRow){
00065 matrixByRow = givenMatrixByRow;
00066 }
00067
00069 inline const CoinPackedMatrix *getMatrixByRow() const {return matrixByRow;};
00070
00072 virtual void setObj(const double *givenObj){
00073 obj = givenObj;
00074 }
00075
00077 inline const double *getObj() const {return obj;};
00078
00081 virtual void setColLower(const double *givenColLower){
00082 colLower = givenColLower;
00083 }
00084
00086 inline const double *getColLower() const {return colLower;};
00087
00090 virtual void setColUpper(const double *givenColUpper){
00091 colUpper = givenColUpper;
00092 }
00093
00095 inline const double *getColUpper() const {return colUpper;};
00096
00099 virtual void setRowLower(const double *givenRowLower){
00100 rowLower = givenRowLower;
00101 }
00102
00104 inline const double *getRowLower() const {return rowLower;};
00105
00108 virtual void setRowUpper(const double *givenRowUpper){
00109 rowUpper = givenRowUpper;
00110 }
00111
00113 inline const double *getRowUpper() const {return rowUpper;};
00114
00117
00119 inline const double *getRowRhs() const {return rowRhs;};
00121 inline const double *getRowRange() const {return rowRange;};
00123 inline const char *getRowSense() const {return rowSense;};
00124
00127
00129 inline const double *getRowActivity() const {return rowActivity;};
00130
00133 virtual void setColType(const char *givenColType){
00134 colType = givenColType;
00135 }
00136
00138 inline const char *getColType() const {return colType;};
00139
00141 virtual void setPrimalSol(const double * givenPrimalSol){
00142 primalSol = givenPrimalSol;
00143 }
00144
00146 inline const double *getPrimalSol() const {return primalSol;};
00147
00149 void initializeOtherData(){
00150 CoinAssert(matrixByRow);
00151 CoinAssert(primalSol);
00152
00153 rowRhs = new double[nrow];
00154 rowRange = new double[nrow];
00155 rowSense = new char[nrow];
00156 rowActivity = new double[nrow];
00157
00158 int r;
00159 for(r = 0; r < nrow; r++){
00160 convertBoundToSense(rowLower[r], rowUpper[r],
00161 rowSense[r], rowRhs[r], rowRange[r]);
00162 }
00163 matrixByRow->times(primalSol, rowActivity);
00164 }
00166
00169 inline void convertBoundToSense(const double lower,
00170 const double upper,
00171 char & sense,
00172 double & right,
00173 double & range) const
00174 {
00175 double inf = getInfinity();
00176 range = 0.0;
00177 if (lower > -inf) {
00178 if (upper < inf) {
00179 right = upper;
00180 if (upper==lower) {
00181 sense = 'E';
00182 } else {
00183 sense = 'R';
00184 range = upper - lower;
00185 }
00186 } else {
00187 sense = 'G';
00188 right = lower;
00189 }
00190 } else {
00191 if (upper < inf) {
00192 sense = 'L';
00193 right = upper;
00194 } else {
00195 sense = 'N';
00196 right = 0.0;
00197 }
00198 }
00199 }
00200
00203
00204 OsiData(const double givenInfinity = DBL_MAX,
00205 const int &givenNrow = 0,
00206 const int &givenNcol = 0,
00207 const CoinPackedMatrix * givenMatrixByCol = NULL,
00208 const CoinPackedMatrix * givenMatrixByRow = NULL,
00209 const double * givenObj = NULL,
00210 const double * givenColLower = NULL,
00211 const double * givenColUpper = NULL,
00212 const double * givenRowLower = NULL,
00213 const double * givenRowUpper = NULL,
00214 const char * givenColType = NULL,
00215 const double * givenPrimalSol = NULL) :
00216 infinity(givenInfinity),
00217 nrow(givenNrow),
00218 ncol(givenNcol),
00219 matrixByCol(givenMatrixByCol),
00220 matrixByRow(givenMatrixByRow),
00221 obj(givenObj),
00222 colLower(givenColLower),
00223 colUpper(givenColUpper),
00224 rowLower(givenRowLower),
00225 rowUpper(givenRowUpper),
00226 colType(givenColType),
00227 primalSol(givenPrimalSol) {}
00228
00229
00231 virtual ~OsiData(){
00232 if(rowRhs)
00233 delete [] rowRhs;
00234 if(rowRange)
00235 delete [] rowRange;
00236 if(rowSense)
00237 delete [] rowSense;
00238 if(rowActivity)
00239 delete [] rowActivity;
00240 }
00242
00243 protected:
00244
00245
00246
00250
00251
00252 double infinity;
00253
00254
00255 int nrow;
00256
00257
00258 int ncol;
00259
00260
00261 CoinPackedMatrix const *matrixByCol;
00262
00263
00264 CoinPackedMatrix const *matrixByRow;
00265
00266
00267 const double *obj;
00268
00269
00270 const double *colLower;
00271
00272
00273 const double *colUpper;
00274
00275
00276 const double *rowLower;
00277
00278
00279 const double *rowUpper;
00280
00289 const char * colType;
00290
00291
00292 const double * primalSol;
00293
00294 protected:
00295
00296
00297 double * rowRhs;
00298
00299
00300 double * rowRange;
00301
00302
00303 char * rowSense;
00304
00305
00306
00307 double * rowActivity;
00308
00309
00311
00312 };
00313
00314
00315
00316 #endif