coin-Cgl
CglLandP.hpp
Go to the documentation of this file.
1 // Copyright (C) 2005, Pierre Bonami and others. All Rights Reserved.
2 // Author: Pierre Bonami
3 // Tepper School of Business
4 // Carnegie Mellon University, Pittsburgh, PA 15213
5 // Date: 07/21/05
6 //---------------------------------------------------------------------------
7 #ifndef CglLandP_H
8 #define CglLandP_H
9 
10 //Several level of Debug
11 // 1 - A few simple sanity check
12 // 2 - do extra computations on cut quality
13 // 3 - Output cut in initial non-basic space (only if logLevel >= 3 )
14 // 4 - Double check (compute in two different ways) reduced cost and f+ f-
15 //#define LandP_DEBUG 1
16 
17 
18 #include "CglLandPValidator.hpp"
19 #include "CglCutGenerator.hpp"
20 #include "CglParam.hpp"
21 
22 #ifdef DO_STAT
23 #include "CglLandPStats.hpp"
24 #endif
25 #include <iostream>
26 class CoinWarmStartBasis;
31 namespace LAP
32 {
41 };
43 class LapMessages : public CoinMessages
44 {
45 public:
47  LapMessages( );
49  virtual ~LapMessages(){}
50 };
51 class CglLandPSimplex;
52 }
53 
54 class CglLandP : public CglCutGenerator
55 {
56  friend void CglLandPUnitTest(OsiSolverInterface *si, const std::string & mpsDir);
57 
58  friend class LAP::CglLandPSimplex;
59  friend class CftCglp;
60 
61 public:
62 
67  };
68 
74  };
75 
81  };
82 
89  };
90 
91  enum LHSnorm {
92  L1 = 0,
93  L2,
98  };
101  Fixed = 0 ,
103  };
106 class Parameters : public CglParam
107  {
108  public:
110  Parameters();
112  Parameters(const Parameters &other);
114  Parameters & operator=(const Parameters &other);
117 
136 
137  double pivotTol;
139  double away;
141  mutable double timeLimit;
145  double rhsWeight;
147 
150 
161  bool perturb;
173  };
174 
175 
180  ~CglLandP();
182  CglLandP(const CglLandP &source);
184  CglLandP& operator=(const CglLandP &rhs);
186  CglCutGenerator * clone() const;
187 
188 #ifdef DO_STAT
189  void setIdString(const std::string &id) {
190  roundsStats_.setIdString(id);
191  }
192 #endif
193 
196 
197  virtual void generateCuts(const OsiSolverInterface & si, OsiCuts & cs,
198  const CglTreeInfo info = CglTreeInfo()) const;
199 
201 
202  virtual bool needsOptimalBasis() const {
203  return true;
204  }
205 
207  return validator_;
208  }
216  void setLogLevel(int level) {
217  handler_->setLogLevel(level);
218  }
219 
220 class NoBasisError : public CoinError
221  {
222  public:
223  NoBasisError(): CoinError("No basis available","LandP","") {}
224  };
225 
226 class SimplexInterfaceError : public CoinError
227  {
228  public:
229  SimplexInterfaceError(): CoinError("Invalid conversion to simplex interface", "CglLandP","CglLandP") {}
230  };
232  return params_;
233  }
234 private:
235 
236 
237  void scanExtraCuts(OsiCuts& cs, const double * colsol) const;
238 
240 
242  struct CachedData {
243  CachedData(int nBasics = 0 , int nNonBasics = 0);
244  CachedData(const CachedData & source);
245 
246  CachedData& operator=(const CachedData &source);
248  void getData(const OsiSolverInterface &si);
249  ~CachedData();
251  int * basics_;
255  int nBasics_;
259  CoinWarmStartBasis * basis_;
261  double * colsol_;
263  double * slacks_;
265  bool * integers_;
266  };
269  int getSortedFractionals(CoinPackedVector &xFrac,
270  const CachedData & data,
271  const CglLandP::Parameters& params) const;
274  void getSortedFractionalIndices(std::vector<int>& indices,
275  const CachedData &data,
276  const CglLandP::Parameters & params) const;
280  CoinMessageHandler * handler_;
282  CoinMessages messages_;
286  mutable int numrows_;
288  mutable int numcols_;
290  mutable double * originalColLower_;
292  mutable double * originalColUpper_;
294  mutable bool canLift_;
296  mutable OsiCuts extraCuts_;
297 #ifdef DO_STAT
298 public:
300  mutable roundsStatistics roundsStats_;
301 #endif
302 };
303 void CglLandPUnitTest(OsiSolverInterface *si, const std::string & mpsDir);
304 
305 #endif
306