Dip  0.92.4
DecompCutPool.h
Go to the documentation of this file.
1 //===========================================================================//
2 // This file is part of the Decomp Solver Framework. //
3 // //
4 // Decomp is distributed under the Common Public License as part of the //
5 // COIN-OR repository (http://www.coin-or.org). //
6 // //
7 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) //
8 // //
9 // Copyright (C) 2002-2007, Lehigh University, Matthew Galati, and Ted Ralphs//
10 // All Rights Reserved. //
11 //===========================================================================//
12 
13 
14 #ifndef DECOMP_CUT_POOL_INCLUDE
15 #define DECOMP_CUT_POOL_INCLUDE
16 
17 #include "DecompWaitingRow.h"
18 
19 #include <functional>
20 using namespace std;
21 
23 
24 // --------------------------------------------------------------------- //
25 //TODO: switch to distance
26 class is_greater_thanD { //member of class instead??
27 public:
28  //TODO: design, waitingcol, rc is member of var, not waiting col,
29  //but for waitingrow, distance is member of wr, not of cut - why?
30  bool operator()( const DecompWaitingRow& x,
31  const DecompWaitingRow& y) {
32  return x.getViolation() > y.getViolation();
33  }
34 };
35 
36 // --------------------------------------------------------------------- //
37 class DecompCutPool : public std::vector<DecompWaitingRow> {
38 private:
40  DecompCutPool& operator=(const DecompCutPool&);
41 
42 private:
43  static const char* classTag;
44  bool m_rowsAreValid;
45 
46 public:
47  const inline bool rowsAreValid() const {
48  return m_rowsAreValid;
49  }
50  inline void setRowsAreValid(bool rowsAreValid) {
51  m_rowsAreValid = rowsAreValid;
52  }
53 
54  void print(ostream* os = &cout) const; //THINK: virtual??
55  void reExpand(const DecompVarList& vars,
56  const int n_corecols);
57 
58  CoinPackedVector* createRowReform(const int n_corecols,
59  const CoinPackedVector* row,
60  const DecompVarList& vars);
61 
62  //THINK
63  //bool isDuplicate(const DecompWaitingRow & wcol);
64 
65  bool calcViolations(const double* x,
66  DecompCutPool::iterator first,
67  DecompCutPool::iterator last);
68  bool calcViolations(const double* x) {
69  return calcViolations(x, begin(), end());
70  }
71 
72 public:
74  m_rowsAreValid(true) {}
75 
77  //---
78  //--- delete any memory that is left in the waiting rows
79  //---
80  vector<DecompWaitingRow>::iterator vi;
81 
82  for (vi = begin(); vi != end(); vi++) {
83  (*vi).deleteCut();
84  (*vi).deleteRow();
85  (*vi).deleteRowReform();
86  }
87  }
88 
89 };
90 
91 #endif
void setRowsAreValid(bool rowsAreValid)
Definition: DecompCutPool.h:50
const double getViolation() const
bool calcViolations(const double *x)
Definition: DecompCutPool.h:68
Sparse Vector.
bool operator()(const DecompWaitingRow &x, const DecompWaitingRow &y)
Definition: DecompCutPool.h:30
std::list< DecompVar * > DecompVarList
Definition: Decomp.h:91
const bool rowsAreValid() const
Definition: DecompCutPool.h:47