CoinUtils  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinSnapshot.hpp
Go to the documentation of this file.
1 /* $Id: CoinSnapshot.hpp 1416 2011-04-17 09:57:29Z stefan $ */
2 // Copyright (C) 2006, International Business Machines
3 // Corporation and others. All Rights Reserved.
4 // This code is licensed under the terms of the Eclipse Public License (EPL).
5 
6 #ifndef CoinSnapshot_H
7 #define CoinSnapshot_H
8 
9 class CoinPackedMatrix;
10 #include "CoinTypes.hpp"
11 
12 //#############################################################################
13 
25 class CoinSnapshot {
26 
27 public:
28 
29  //---------------------------------------------------------------------------
35 
36  inline int getNumCols() const
37  { return numCols_;}
38 
40  inline int getNumRows() const
41  { return numRows_;}
42 
44  inline int getNumElements() const
45  { return numElements_;}
46 
48  inline int getNumIntegers() const
49  { return numIntegers_;}
50 
52  inline const double * getColLower() const
53  { return colLower_;}
54 
56  inline const double * getColUpper() const
57  { return colUpper_;}
58 
60  inline const double * getRowLower() const
61  { return rowLower_;}
62 
64  inline const double * getRowUpper() const
65  { return rowUpper_;}
66 
74  inline const double * getRightHandSide() const
75  { return rightHandSide_;}
76 
78  inline const double * getObjCoefficients() const
79  { return objCoefficients_;}
80 
82  inline double getObjSense() const
83  { return objSense_;}
84 
86  inline bool isContinuous(int colIndex) const
87  { return colType_[colIndex]=='C';}
88 
90  inline bool isBinary(int colIndex) const
91  { return colType_[colIndex]=='B';}
92 
94  inline bool isInteger(int colIndex) const
95  { return colType_[colIndex]=='B'||colType_[colIndex]=='I';}
96 
98  inline bool isIntegerNonBinary(int colIndex) const
99  { return colType_[colIndex]=='I';}
100 
102  inline bool isFreeBinary(int colIndex) const
103  { return colType_[colIndex]=='B'&&colUpper_[colIndex]>colLower_[colIndex];}
104 
106  inline const char * getColType() const
107  { return colType_;}
108 
110  inline const CoinPackedMatrix * getMatrixByRow() const
111  { return matrixByRow_;}
112 
114  inline const CoinPackedMatrix * getMatrixByCol() const
115  { return matrixByCol_;}
116 
119  { return originalMatrixByRow_;}
120 
123  { return originalMatrixByCol_;}
125 
128 
129  inline const double * getColSolution() const
130  { return colSolution_;}
131 
133  inline const double * getRowPrice() const
134  { return rowPrice_;}
135 
137  inline const double * getReducedCost() const
138  { return reducedCost_;}
139 
141  inline const double * getRowActivity() const
142  { return rowActivity_;}
143 
145  inline const double * getDoNotSeparateThis() const
146  { return doNotSeparateThis_;}
148 
151 
152  inline double getInfinity() const
153  { return infinity_;}
154 
157  inline double getObjValue() const
158  { return objValue_;}
159 
161  inline double getObjOffset() const
162  { return objOffset_;}
163 
165  inline double getDualTolerance() const
166  { return dualTolerance_;}
167 
169  inline double getPrimalTolerance() const
170  { return primalTolerance_;}
171 
173  inline double getIntegerTolerance() const
174  { return integerTolerance_;}
175 
177  inline double getIntegerUpperBound() const
178  { return integerUpperBound_;}
179 
181  inline double getIntegerLowerBound() const
182  { return integerLowerBound_;}
184 
185  //---------------------------------------------------------------------------
186 
201  void loadProblem(const CoinPackedMatrix& matrix,
202  const double* collb, const double* colub,
203  const double* obj,
204  const double* rowlb, const double* rowub,
205  bool makeRowCopy=false);
206 
208 
209  //---------------------------------------------------------------------------
210 
213 
214  inline void setNumCols(int value)
215  { numCols_ = value;}
216 
218  inline void setNumRows(int value)
219  { numRows_ = value;}
220 
222  inline void setNumElements(int value)
223  { numElements_ = value;}
224 
226  inline void setNumIntegers(int value)
227  { numIntegers_ = value;}
228 
230  void setColLower(const double * array, bool copyIn=true);
231 
233  void setColUpper(const double * array, bool copyIn=true);
234 
236  void setRowLower(const double * array, bool copyIn=true);
237 
239  void setRowUpper(const double * array, bool copyIn=true);
240 
248  void setRightHandSide(const double * array, bool copyIn=true);
249 
258  void createRightHandSide();
259 
261  void setObjCoefficients(const double * array, bool copyIn=true);
262 
264  inline void setObjSense(double value)
265  { objSense_ = value;}
266 
268  void setColType(const char *array, bool copyIn=true);
269 
271  void setMatrixByRow(const CoinPackedMatrix * matrix, bool copyIn=true);
272 
274  void createMatrixByRow();
275 
277  void setMatrixByCol(const CoinPackedMatrix * matrix, bool copyIn=true);
278 
280  void setOriginalMatrixByRow(const CoinPackedMatrix * matrix, bool copyIn=true);
281 
283  void setOriginalMatrixByCol(const CoinPackedMatrix * matrix, bool copyIn=true);
284 
286  void setColSolution(const double * array, bool copyIn=true);
287 
289  void setRowPrice(const double * array, bool copyIn=true);
290 
292  void setReducedCost(const double * array, bool copyIn=true);
293 
295  void setRowActivity(const double * array, bool copyIn=true);
296 
298  void setDoNotSeparateThis(const double * array, bool copyIn=true);
299 
301  inline void setInfinity(double value)
302  { infinity_ = value;}
303 
305  inline void setObjValue(double value)
306  { objValue_ = value;}
307 
309  inline void setObjOffset(double value)
310  { objOffset_ = value;}
311 
313  inline void setDualTolerance(double value)
314  { dualTolerance_ = value;}
315 
317  inline void setPrimalTolerance(double value)
318  { primalTolerance_ = value;}
319 
321  inline void setIntegerTolerance(double value)
322  { integerTolerance_ = value;}
323 
325  inline void setIntegerUpperBound(double value)
326  { integerUpperBound_ = value;}
327 
329  inline void setIntegerLowerBound(double value)
330  { integerLowerBound_ = value;}
332 
333  //---------------------------------------------------------------------------
334 
336 
337 
338  CoinSnapshot();
339 
341  CoinSnapshot(const CoinSnapshot &);
342 
344  CoinSnapshot & operator=(const CoinSnapshot& rhs);
345 
347  virtual ~CoinSnapshot ();
348 
350 
351 private:
353 
354 
360  void gutsOfDestructor(int type);
362  void gutsOfCopy(const CoinSnapshot & rhs);
364 
366 
368  double objSense_;
369 
371  double infinity_;
372 
374  double objValue_;
375 
377  double objOffset_;
378 
381 
384 
387 
390 
393 
395  const double * colLower_;
396 
398  const double * colUpper_;
399 
401  const double * rowLower_;
402 
404  const double * rowUpper_;
405 
407  const double * rightHandSide_;
408 
410  const double * objCoefficients_;
411 
413  const char * colType_;
414 
417 
420 
423 
426 
428  const double * colSolution_;
429 
431  const double * rowPrice_;
432 
434  const double * reducedCost_;
435 
437  const double * rowActivity_;
438 
440  const double * doNotSeparateThis_;
441 
443  int numCols_;
444 
446  int numRows_;
447 
450 
453 
455  typedef struct {
456  unsigned int colLower:1;
457  unsigned int colUpper:1;
458  unsigned int rowLower:1;
459  unsigned int rowUpper:1;
460  unsigned int rightHandSide:1;
461  unsigned int objCoefficients:1;
462  unsigned int colType:1;
463  unsigned int matrixByRow:1;
464  unsigned int matrixByCol:1;
465  unsigned int originalMatrixByRow:1;
466  unsigned int originalMatrixByCol:1;
467  unsigned int colSolution:1;
468  unsigned int rowPrice:1;
469  unsigned int reducedCost:1;
470  unsigned int rowActivity:1;
471  unsigned int doNotSeparateThis:1;
472  } coinOwned;
475 };
476 #endif