00001 //===========================================================================// 00002 // This file is part of the Decomp Solver Framework. // 00003 // // 00004 // Decomp is distributed under the Common Public License as part of the // 00005 // COIN-OR repository (http://www.coin-or.org). // 00006 // // 00007 // Author: Matthew Galati, SAS Institute Inc. (matthew.galati@sas.com) // 00008 // // 00009 // Copyright (C) 2002-2007, Lehigh University, Matthew Galati, and Ted Ralphs// 00010 // All Rights Reserved. // 00011 //===========================================================================// 00012 00013 00014 #ifndef DECOMP_CUT_POOL_INCLUDE 00015 #define DECOMP_CUT_POOL_INCLUDE 00016 00017 #include "DecompWaitingRow.h" 00018 00019 #include <functional> 00020 using namespace std; 00021 00022 class DecompConstraintSet; 00023 00024 // --------------------------------------------------------------------- // 00025 //TODO: switch to distance 00026 class is_greater_thanD { //member of class instead?? 00027 public: 00028 //TODO: design, waitingcol, rc is member of var, not waiting col, 00029 //but for waitingrow, distance is member of wr, not of cut - why? 00030 bool operator()( const DecompWaitingRow& x, 00031 const DecompWaitingRow& y) { 00032 return x.getViolation() > y.getViolation(); 00033 } 00034 }; 00035 00036 // --------------------------------------------------------------------- // 00037 class DecompCutPool : public std::vector<DecompWaitingRow> { 00038 private: 00039 DecompCutPool(const DecompCutPool&); 00040 DecompCutPool& operator=(const DecompCutPool&); 00041 00042 private: 00043 static const char* classTag; 00044 bool m_rowsAreValid; 00045 00046 public: 00047 const inline bool rowsAreValid() const { 00048 return m_rowsAreValid; 00049 } 00050 inline void setRowsAreValid(bool rowsAreValid) { 00051 m_rowsAreValid = rowsAreValid; 00052 } 00053 00054 void print(ostream* os = &cout) const; //THINK: virtual?? 00055 void reExpand(const DecompVarList& vars, 00056 const int n_corecols); 00057 00058 CoinPackedVector* createRowReform(const int n_corecols, 00059 const CoinPackedVector* row, 00060 const DecompVarList& vars); 00061 00062 //THINK 00063 //bool isDuplicate(const DecompWaitingRow & wcol); 00064 00065 bool calcViolations(const double* x, 00066 DecompCutPool::iterator first, 00067 DecompCutPool::iterator last); 00068 bool calcViolations(const double* x) { 00069 return calcViolations(x, begin(), end()); 00070 } 00071 00072 public: 00073 DecompCutPool() : 00074 m_rowsAreValid(true) {} 00075 00076 ~DecompCutPool() { 00077 //--- 00078 //--- delete any memory that is left in the waiting rows 00079 //--- 00080 vector<DecompWaitingRow>::iterator vi; 00081 00082 for (vi = begin(); vi != end(); vi++) { 00083 (*vi).deleteCut(); 00084 (*vi).deleteRow(); 00085 (*vi).deleteRowReform(); 00086 } 00087 } 00088 00089 }; 00090 00091 #endif