CoinSnapshot.hpp
Go to the documentation of this file.
1 /* $Id: CoinSnapshot.hpp 1191 2009-07-25 08:38:12Z forrest $ */
2 // Copyright (C) 2006, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 #ifndef CoinSnapshot_H
5 #define CoinSnapshot_H
6 
7 class CoinPackedMatrix;
8 #include "CoinFinite.hpp"
9 
10 //#############################################################################
11 
23 class CoinSnapshot {
24 
25 public:
26 
27  //---------------------------------------------------------------------------
33 
34  inline int getNumCols() const
35  { return numCols_;}
36 
38  inline int getNumRows() const
39  { return numRows_;}
40 
42  inline int getNumElements() const
43  { return numElements_;}
44 
46  inline int getNumIntegers() const
47  { return numIntegers_;}
48 
50  inline const double * getColLower() const
51  { return colLower_;}
52 
54  inline const double * getColUpper() const
55  { return colUpper_;}
56 
58  inline const double * getRowLower() const
59  { return rowLower_;}
60 
62  inline const double * getRowUpper() const
63  { return rowUpper_;}
64 
72  inline const double * getRightHandSide() const
73  { return rightHandSide_;}
74 
76  inline const double * getObjCoefficients() const
77  { return objCoefficients_;}
78 
80  inline double getObjSense() const
81  { return objSense_;}
82 
84  inline bool isContinuous(int colIndex) const
85  { return colType_[colIndex]=='C';}
86 
88  inline bool isBinary(int colIndex) const
89  { return colType_[colIndex]=='B';}
90 
92  inline bool isInteger(int colIndex) const
93  { return colType_[colIndex]=='B'||colType_[colIndex]=='I';}
94 
96  inline bool isIntegerNonBinary(int colIndex) const
97  { return colType_[colIndex]=='I';}
98 
100  inline bool isFreeBinary(int colIndex) const
101  { return colType_[colIndex]=='B'&&colUpper_[colIndex]>colLower_[colIndex];}
102 
104  inline const char * getColType() const
105  { return colType_;}
106 
108  inline const CoinPackedMatrix * getMatrixByRow() const
109  { return matrixByRow_;}
110 
112  inline const CoinPackedMatrix * getMatrixByCol() const
113  { return matrixByCol_;}
114 
117  { return originalMatrixByRow_;}
118 
121  { return originalMatrixByCol_;}
123 
126 
127  inline const double * getColSolution() const
128  { return colSolution_;}
129 
131  inline const double * getRowPrice() const
132  { return rowPrice_;}
133 
135  inline const double * getReducedCost() const
136  { return reducedCost_;}
137 
139  inline const double * getRowActivity() const
140  { return rowActivity_;}
141 
143  inline const double * getDoNotSeparateThis() const
144  { return doNotSeparateThis_;}
146 
149 
150  inline double getInfinity() const
151  { return infinity_;}
152 
155  inline double getObjValue() const
156  { return objValue_;}
157 
159  inline double getObjOffset() const
160  { return objOffset_;}
161 
163  inline double getDualTolerance() const
164  { return dualTolerance_;}
165 
167  inline double getPrimalTolerance() const
168  { return primalTolerance_;}
169 
171  inline double getIntegerTolerance() const
172  { return integerTolerance_;}
173 
175  inline double getIntegerUpperBound() const
176  { return integerUpperBound_;}
177 
179  inline double getIntegerLowerBound() const
180  { return integerLowerBound_;}
182 
183  //---------------------------------------------------------------------------
184 
199  void loadProblem(const CoinPackedMatrix& matrix,
200  const double* collb, const double* colub,
201  const double* obj,
202  const double* rowlb, const double* rowub,
203  bool makeRowCopy=false);
204 
206 
207  //---------------------------------------------------------------------------
208 
211 
212  inline void setNumCols(int value)
213  { numCols_ = value;}
214 
216  inline void setNumRows(int value)
217  { numRows_ = value;}
218 
220  inline void setNumElements(int value)
221  { numElements_ = value;}
222 
224  inline void setNumIntegers(int value)
225  { numIntegers_ = value;}
226 
228  void setColLower(const double * array, bool copyIn=true);
229 
231  void setColUpper(const double * array, bool copyIn=true);
232 
234  void setRowLower(const double * array, bool copyIn=true);
235 
237  void setRowUpper(const double * array, bool copyIn=true);
238 
246  void setRightHandSide(const double * array, bool copyIn=true);
247 
256  void createRightHandSide();
257 
259  void setObjCoefficients(const double * array, bool copyIn=true);
260 
262  inline void setObjSense(double value)
263  { objSense_ = value;}
264 
266  void setColType(const char *array, bool copyIn=true);
267 
269  void setMatrixByRow(const CoinPackedMatrix * matrix, bool copyIn=true);
270 
272  void createMatrixByRow();
273 
275  void setMatrixByCol(const CoinPackedMatrix * matrix, bool copyIn=true);
276 
278  void setOriginalMatrixByRow(const CoinPackedMatrix * matrix, bool copyIn=true);
279 
281  void setOriginalMatrixByCol(const CoinPackedMatrix * matrix, bool copyIn=true);
282 
284  void setColSolution(const double * array, bool copyIn=true);
285 
287  void setRowPrice(const double * array, bool copyIn=true);
288 
290  void setReducedCost(const double * array, bool copyIn=true);
291 
293  void setRowActivity(const double * array, bool copyIn=true);
294 
296  void setDoNotSeparateThis(const double * array, bool copyIn=true);
297 
299  inline void setInfinity(double value)
300  { infinity_ = value;}
301 
303  inline void setObjValue(double value)
304  { objValue_ = value;}
305 
307  inline void setObjOffset(double value)
308  { objOffset_ = value;}
309 
311  inline void setDualTolerance(double value)
312  { dualTolerance_ = value;}
313 
315  inline void setPrimalTolerance(double value)
316  { primalTolerance_ = value;}
317 
319  inline void setIntegerTolerance(double value)
320  { integerTolerance_ = value;}
321 
323  inline void setIntegerUpperBound(double value)
324  { integerUpperBound_ = value;}
325 
327  inline void setIntegerLowerBound(double value)
328  { integerLowerBound_ = value;}
330 
331  //---------------------------------------------------------------------------
332 
334 
335 
336  CoinSnapshot();
337 
339  CoinSnapshot(const CoinSnapshot &);
340 
342  CoinSnapshot & operator=(const CoinSnapshot& rhs);
343 
345  virtual ~CoinSnapshot ();
346 
348 
349 private:
351 
352 
358  void gutsOfDestructor(int type);
360  void gutsOfCopy(const CoinSnapshot & rhs);
362 
364 
366  double objSense_;
367 
369  double infinity_;
370 
372  double objValue_;
373 
375  double objOffset_;
376 
379 
382 
385 
388 
391 
393  const double * colLower_;
394 
396  const double * colUpper_;
397 
399  const double * rowLower_;
400 
402  const double * rowUpper_;
403 
405  const double * rightHandSide_;
406 
408  const double * objCoefficients_;
409 
411  const char * colType_;
412 
415 
418 
421 
424 
426  const double * colSolution_;
427 
429  const double * rowPrice_;
430 
432  const double * reducedCost_;
433 
435  const double * rowActivity_;
436 
438  const double * doNotSeparateThis_;
439 
441  int numCols_;
442 
444  int numRows_;
445 
448 
451 
453  typedef struct {
454  unsigned int colLower:1;
455  unsigned int colUpper:1;
456  unsigned int rowLower:1;
457  unsigned int rowUpper:1;
458  unsigned int rightHandSide:1;
459  unsigned int objCoefficients:1;
460  unsigned int colType:1;
461  unsigned int matrixByRow:1;
462  unsigned int matrixByCol:1;
463  unsigned int originalMatrixByRow:1;
464  unsigned int originalMatrixByCol:1;
465  unsigned int colSolution:1;
466  unsigned int rowPrice:1;
467  unsigned int reducedCost:1;
468  unsigned int rowActivity:1;
469  unsigned int doNotSeparateThis:1;
470  } coinOwned;
473 };
474 #endif