- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

BlisConGenerator.h
Go to the documentation of this file.
1 /*===========================================================================*
2 * This file is part of the BiCePS Linear Integer 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
37 class BlisModel;
38
39 class OsiRowCut;
40 class OsiRowCutDebugger;
41 class CglCutGenerator;
42
43
44 //#############################################################################
45
58 class BlisConGenerator {
59
60 protected:
62 BlisModel *model_;
63
65 CglCutGenerator * generator_;
66
67 //------------------------------------------------------
68 // CON CONTROL
69 //------------------------------------------------------
70
77 BlisCutStrategy strategy_;
78
80 int cutGenerationFrequency_;
81
83 std::string name_;
84
86 bool normal_;
87
89 bool atSolution_;
90
93 bool whenInfeasible_;
94
95 //------------------------------------------------------
96 // CON STATISTICS
97 //------------------------------------------------------
98
100 int numConsGenerated_;
101
103 int numConsUsed_;
104
106 double time_;
107
109 int calls_;
110
112 int noConsCalls_;
113
114 public:
115
119 BlisConGenerator()
120 :
121 model_(NULL),
122 generator_(NULL),
123 strategy_(BlisCutStrategyAuto),
124 cutGenerationFrequency_(1),
125 normal_(true),
126 atSolution_(false),
127 whenInfeasible_(false),
128 numConsGenerated_(0),
129 numConsUsed_(0),
130 time_(0),
131 calls_(0),
132 noConsCalls_(0)
133 { name_ = "UNKNOWN"; }
134
136 BlisConGenerator(BlisModel * model,
137 CglCutGenerator * generator,
138 const char * name = NULL,
139 BlisCutStrategy strategy = BlisCutStrategyAuto,
140 int cutGenerationFrequency_ = 1,
141 bool normal = true,
142 bool atSolution = false,
143 bool infeasible = false);
144
146 BlisConGenerator (const BlisConGenerator &);
147
149 BlisConGenerator & operator=(const BlisConGenerator& rhs);
150
152 virtual ~BlisConGenerator()
153 {
154 if (generator_) {
155 delete generator_;
156 generator_ = NULL;
157 }
158 }
160
172 virtual bool generateConstraints(BcpsConstraintPool &conPool);
174
182 inline BlisModel *getModel() { return model_; }
183
185 inline void setModel(BlisModel *m) { model_ = m; }
186
188 void refreshModel(BlisModel * model);
189
191 void setName(const char *str) { name_ = str; }
192
194 inline std::string name() const { return name_; }
195
197 void setStrategy(BlisCutStrategy value) { strategy_ = value; }
198
200 inline BlisCutStrategy strategy() const { return strategy_; }
201
203 void setCutGenerationFreq(int freq) { cutGenerationFrequency_ = freq; }
204
206 inline int cutGenerationFreq() const { return cutGenerationFrequency_; }
207
209 inline bool normal() const { return normal_; }
210
212 inline void setNormal(bool value) { normal_ = value; }
213
216 inline bool atSolution() const { return atSolution_; }
217
220 inline void setAtSolution(bool value) { atSolution_ = value; }
221
224 inline bool whenInfeasible() const { return whenInfeasible_; }
225
228 inline void setWhenInfeasible(bool value) { whenInfeasible_ = value; }
229
231 inline CglCutGenerator * generator() const { return generator_; }
232
234 inline int numConsGenerated() { return numConsGenerated_; }
235
237 inline void addNumConsGenerated(int n) { numConsGenerated_ += n; }
238
240 inline int numConsUsed() { return numConsUsed_; }
241
243 inline void addNumConsUsed(int n) { numConsUsed_ += n; }
244
246 inline double time() const { return time_; }
247
249 inline void addTime(double t) { time_ += t; }
250
252 inline int calls() const { return calls_; }
253
255 inline void addCalls(int n=1) { calls_ += n; }
256
258 inline int noConsCalls() const { return noConsCalls_; }
259
261 inline void addNoConsCalls(int n=1) { noConsCalls_ += n; }
263 };
264
265 #endif
BlisConGenerator::setCutGenerationFreq
void setCutGenerationFreq(int freq)
Set the con generation strategy.
Definition: BlisConGenerator.h:203
BlisModel
Definition: BlisModel.h:60
BlisConGenerator::calls_
int calls_
The times of calling this generator.
Definition: BlisConGenerator.h:104
BlisConGenerator::cutGenerationFreq
int cutGenerationFreq() const
Get the con generation interval.
Definition: BlisConGenerator.h:206
BlisConGenerator::addTime
void addTime(double t)
Increase Cpu time used.
Definition: BlisConGenerator.h:249
BlisConGenerator::numConsGenerated_
int numConsGenerated_
Number of cons generated.
Definition: BlisConGenerator.h:95
BlisConGenerator::addCalls
void addCalls(int n=1)
Increase the number of called.
Definition: BlisConGenerator.h:255
BlisConGenerator::model_
BlisModel * model_
The client model.
Definition: BlisConGenerator.h:60
BlisConGenerator::normal_
bool normal_
Whether to call the generator in the normal place.
Definition: BlisConGenerator.h:81
BlisConGenerator::whenInfeasible
bool whenInfeasible() const
Get whether the con generator should be called when the subproblem is found to be infeasible...
Definition: BlisConGenerator.h:224
BlisConGenerator::cutGenerationFrequency_
int cutGenerationFrequency_
The frequency of calls to the cut generator.
Definition: BlisConGenerator.h:80
BlisConGenerator::whenInfeasible_
bool whenInfeasible_
Whether to call generator when a subproblem is found to be infeasible.
Definition: BlisConGenerator.h:88
OsiRowCut
Row Cut Class.
Definition: OsiRowCut.hpp:29
BlisConGenerator::time
double time() const
Cpu time used.
Definition: BlisConGenerator.h:246
BlisConGenerator::normal
bool normal() const
Get whether the con generator should be called in the normal place.
Definition: BlisConGenerator.h:193
BlisConGenerator::operator=
BlisConGenerator & operator=(const BlisConGenerator &rhs)
Assignment operator.
BlisConGenerator::name_
char * name_
Name of generator.
Definition: BlisConGenerator.h:78
BlisConGenerator::setNormal
void setNormal(bool value)
Set whether the con generator should be called in the normal place.
Definition: BlisConGenerator.h:212
BlisConGenerator::getModel
BlisModel * getModel()
Set the client model.
Definition: BlisConGenerator.h:182
BlisConGenerator::refreshModel
void refreshModel(BlisModel *model)
Set the client model.
BlisConGenerator::~BlisConGenerator
virtual ~BlisConGenerator()
Destructor.
Definition: BlisConGenerator.h:152
BlisConGenerator::name
std::string name() const
return name of generator.
Definition: BlisConGenerator.h:194
BlisConGenerator::numConsGenerated
int numConsGenerated()
Get number of generated cons.
Definition: BlisConGenerator.h:234
BlisConGenerator
Interface between Blis and Cut Generation Library.
Definition: BlisConGenerator.h:56
BlisCutStrategy
BlisCutStrategy
Definition: Blis.h:69
BlisConGenerator::calls
int calls() const
Number called.
Definition: BlisConGenerator.h:252
BlisConGenerator::numConsUsed
int numConsUsed()
Get number of used cons.
Definition: BlisConGenerator.h:240
BlisConGenerator::addNumConsUsed
void addNumConsUsed(int n)
Increase the number of generated cons.
Definition: BlisConGenerator.h:243
BlisConGenerator::BlisConGenerator
BlisConGenerator()
Default constructor.
Definition: BlisConGenerator.h:119
BcpsConstraintPool
Definition: BcpsObjectPool.h:104
BlisConGenerator::atSolution
bool atSolution() const
Get whether the con generator should be called when a solution is found.
Definition: BlisConGenerator.h:200
BlisConGenerator::strategy_
int strategy_
When to call CglCutGenerator::generateCuts routine.
Definition: BlisConGenerator.h:75
BlisConGenerator::setStrategy
void setStrategy(BlisCutStrategy value)
Set the con generation strategy.
Definition: BlisConGenerator.h:197
BlisConGenerator::addNumConsGenerated
void addNumConsGenerated(int n)
Increase the number of generated cons.
Definition: BlisConGenerator.h:237
OsiSolverInterface.hpp
BlisConGenerator::strategy
BlisCutStrategy strategy() const
Get the con generation interval.
Definition: BlisConGenerator.h:200
CglCutGenerator
Cut Generator Base Class.
Definition: CglCutGenerator.hpp:23
BlisConGenerator::setName
void setName(const char *str)
return name of generator.
Definition: BlisConGenerator.h:191
BlisConGenerator::setWhenInfeasible
void setWhenInfeasible(bool value)
Set whether the con generator should be called when the subproblem is found to be infeasible...
Definition: BlisConGenerator.h:228
BlisConGenerator::atSolution_
bool atSolution_
Whether to call the generator when a new solution is found.
Definition: BlisConGenerator.h:84
BlisConGenerator::name
const char * name() const
return name of generator.
Definition: BlisConGenerator.h:184
BlisConGenerator::addNoConsCalls
void addNoConsCalls(int n=1)
Increase the number of no cons called.
Definition: BlisConGenerator.h:261
BlisConGenerator::noConsCalls
int noConsCalls() const
Number called and no cons found.
Definition: BlisConGenerator.h:258
BlisCutStrategyAuto
Definition: Blis.h:73
OsiRowCutDebugger
Validate cuts against a known solution.
Definition: OsiRowCutDebugger.hpp:42
BlisConGenerator::setAtSolution
void setAtSolution(bool value)
Set whether the con generator should be called when a solution is found.
Definition: BlisConGenerator.h:220
BlisConGenerator::time_
double time_
Used CPU/User time.
Definition: BlisConGenerator.h:101
BlisConGenerator::setModel
void setModel(BlisModel *m)
Set the model.
Definition: BlisConGenerator.h:185
BlisConGenerator::numConsUsed_
int numConsUsed_
Number of cons used.
Definition: BlisConGenerator.h:98
OsiCuts.hpp
BlisConGenerator::strategy
int strategy() const
Get the con generation interval.
Definition: BlisConGenerator.h:190
BlisConGenerator::noConsCalls_
int noConsCalls_
The times of calling this generator and no cons found.
Definition: BlisConGenerator.h:107
BlisConGenerator::generateConstraints
virtual bool generateConstraints(BcpsConstraintPool &conPool)
Generate cons for the client model.
BlisConGenerator::generator_
CglCutGenerator * generator_
The CglCutGenerator object.
Definition: BlisConGenerator.h:63
BlisConGenerator::name_
std::string name_
Name of generator.
Definition: BlisConGenerator.h:83
BlisConGenerator::generator
CglCutGenerator * generator() const
Get the CglCutGenerator bound to this BlisConGenerator.
Definition: BlisConGenerator.h:215
BlisConGenerator::strategy_
BlisCutStrategy strategy_
When to call CglCutGenerator::generateCuts routine.
Definition: BlisConGenerator.h:77