BlisConGenerator.h
Go to the documentation of this file.
1 /*===========================================================================*
2  * This file is part of the Bcps Linear Solver (BLIS). *
3  * *
4  * BLIS is distributed under the Eclipse Public License as part of the *
5  * COIN-OR repository (http://www.coin-or.org). *
6  * *
7  * Authors: *
8  * *
9  * Yan Xu, Lehigh University *
10  * Ted Ralphs, Lehigh University *
11  * *
12  * Conceptual Design: *
13  * *
14  * Yan Xu, Lehigh University *
15  * Ted Ralphs, Lehigh University *
16  * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17  * Matthew Saltzman, Clemson University *
18  * *
19  * *
20  * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21  * All Rights Reserved. *
22  *===========================================================================*/
23 
24 
25 //#############################################################################
26 // This file is modified from COIN/Cbc/CbcCutGenerator.hpp
27 //#############################################################################
28 
29 
30 #ifndef BlisConGenerator_h_
31 #define BlisConGenerator_h_
32 
33 #include "OsiSolverInterface.hpp"
34 #include "OsiCuts.hpp"
35 
36 class BlisModel;
37 class OsiRowCut;
38 class OsiRowCutDebugger;
39 class CglCutGenerator;
40 
41 
42 //#############################################################################
43 
57 
58  private:
61 
64 
65  //------------------------------------------------------
66  // CON CONTROL
67  //------------------------------------------------------
68 
75  int strategy_;
76 
78  char * name_;
79 
81  bool normal_;
82 
85 
89 
90  //------------------------------------------------------
91  // CON STATISTICS
92  //------------------------------------------------------
93 
96 
99 
101  double time_;
102 
104  int calls_;
105 
108 
109  public:
110 
115  :
116  model_(NULL),
117  generator_(NULL),
118  strategy_(-1),
119  name_(NULL),
120  normal_(true),
121  atSolution_(false),
122  whenInfeasible_(false),
124  numConsUsed_(0),
125  time_(0),
126  calls_(0),
127  noConsCalls_(0)
128  {}
129 
131  BlisConGenerator(BlisModel * model,
133  const char * name = NULL,
134  int strategy = 0,
135  bool normal = true,
136  bool atSolution = false,
137  bool infeasible = false);
138 
141 
144 
147  {
148  free(name_);
149  name_= NULL;
150  if (generator_) {
151  delete generator_;
152  generator_ = NULL;
153  }
154  }
156 
172  bool generateCons(OsiCuts &cs, bool fullScan);
174 
181  void refreshModel(BlisModel * model);
182 
184  inline const char * name() const { return name_; }
185 
187  void setStrategy(int value) { strategy_ = value; }
188 
190  inline int strategy() const { return strategy_; }
191 
193  inline bool normal() const { return normal_; }
194 
196  inline void setNormal(bool value) { normal_ = value; }
197 
200  inline bool atSolution() const { return atSolution_; }
201 
204  inline void setAtSolution(bool value) { atSolution_ = value; }
205 
208  inline bool whenInfeasible() const { return whenInfeasible_; }
209 
212  inline void setWhenInfeasible(bool value) { whenInfeasible_ = value; }
213 
215  inline CglCutGenerator * generator() const { return generator_; }
216 
218  inline int numConsGenerated() { return numConsGenerated_; }
219 
221  inline void addNumConsGenerated(int n) { numConsGenerated_ += n; }
222 
224  inline int numConsUsed() { return numConsUsed_; }
225 
227  inline void addNumConsUsed(int n) { numConsUsed_ += n; }
228 
230  inline double time() { return time_; }
231 
233  inline void addTime(double t) { time_ += t; }
234 
236  inline int calls() { return calls_; }
237 
239  inline void addCalls(int n=1) { calls_ += n; }
240 
242  inline int noConsCalls() { return noConsCalls_; }
243 
245  inline void addNoConsCalls(int n=1) { noConsCalls_ += n; }
247 };
248 
249 #endif
int calls_
The times of calling this generator.
void addTime(double t)
Increase Cpu time used.
int numConsGenerated_
Number of cons generated.
void addCalls(int n=1)
Increase the number of called.
void setStrategy(int value)
Set the con generation strategy.
BlisModel * model_
The client model.
bool normal_
Whether to call the generator in the normal place.
bool whenInfeasible() const
Get whether the con generator should be called when the subproblem is found to be infeasible...
~BlisConGenerator()
Destructor.
bool whenInfeasible_
Whether to call generator when a subproblem is found to be infeasible.
Row Cut Class.
Definition: OsiRowCut.hpp:29
bool generateCons(OsiCuts &cs, bool fullScan)
Generate cons for the client model.
bool normal() const
Get whether the con generator should be called in the normal place.
BlisConGenerator & operator=(const BlisConGenerator &rhs)
Assignment operator.
char * name_
Name of generator.
void setNormal(bool value)
Set whether the con generator should be called in the normal place.
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
void refreshModel(BlisModel *model)
Set the client model.
int numConsGenerated()
Get number of generated cons.
Interface between Blis and Cut Generation Library.
int numConsUsed()
Get number of used cons.
void addNumConsUsed(int n)
Increase the number of generated cons.
BlisConGenerator()
Default constructor.
bool atSolution() const
Get whether the con generator should be called when a solution is found.
int strategy_
When to call CglCutGenerator::generateCuts routine.
int calls()
Number called.
void addNumConsGenerated(int n)
Increase the number of generated cons.
Cut Generator Base Class.
void setWhenInfeasible(bool value)
Set whether the con generator should be called when the subproblem is found to be infeasible...
bool atSolution_
Whether to call the generator when a new solution is found.
const char * name() const
return name of generator.
void addNoConsCalls(int n=1)
Increase the number of no cons called.
Validate cuts against a known solution.
double time()
Cpu time used.
void setAtSolution(bool value)
Set whether the con generator should be called when a solution is found.
double time_
Used CPU/User time.
int numConsUsed_
Number of cons used.
int strategy() const
Get the con generation interval.
int noConsCalls_
The times of calling this generator and no cons found.
CglCutGenerator * generator_
The CglCutGenerator object.
int noConsCalls()
Number called and no cons found.
CglCutGenerator * generator() const
Get the CglCutGenerator bound to this BlisConGenerator.