Blis 0.95.0
Loading...
Searching...
No Matches
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-2023, 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#include "BlisConfig.h"
37
38class BlisModel;
39
40class OsiRowCut;
41class OsiRowCutDebugger;
42class CglCutGenerator;
43
44
45//#############################################################################
46
60
61protected:
64
66 CglCutGenerator * generator_;
67
68 //------------------------------------------------------
69 // CON CONTROL
70 //------------------------------------------------------
71
79
82
84 std::string name_;
85
87 bool normal_;
88
91
95
96 //------------------------------------------------------
97 // CON STATISTICS
98 //------------------------------------------------------
99
102
105
107 double time_;
108
111
114
115 public:
116
121 :
122 model_(NULL),
123 generator_(NULL),
124 strategy_(BlisCutStrategyAuto),
125 cutGenerationFrequency_(1),
126 normal_(true),
127 atSolution_(false),
128 whenInfeasible_(false),
129 numConsGenerated_(0),
130 numConsUsed_(0),
131 time_(0),
132 calls_(0),
133 noConsCalls_(0)
134 { name_ = "UNKNOWN"; }
135
138 CglCutGenerator * generator,
139 const char * name = NULL,
141 int cutGenerationFrequency_ = 1,
142 bool normal = true,
143 bool atSolution = false,
144 bool infeasible = false);
145
148
151
154 {
155 if (generator_) {
156 delete generator_;
157 generator_ = NULL;
158 }
159 }
161
173 virtual bool generateConstraints(BcpsConstraintPool &conPool);
175
183 inline BlisModel *getModel() { return model_; }
184
186 inline void setModel(BlisModel *m) { model_ = m; }
187
189 void refreshModel(BlisModel * model);
190
192 void setName(const char *str) { name_ = str; }
193
195 inline std::string name() const { return name_; }
196
198 void setStrategy(BlisCutStrategy value) { strategy_ = value; }
199
201 inline BlisCutStrategy strategy() const { return strategy_; }
202
204 void setCutGenerationFreq(int freq) { cutGenerationFrequency_ = freq; }
205
207 inline int cutGenerationFreq() const { return cutGenerationFrequency_; }
208
210 inline bool normal() const { return normal_; }
211
213 inline void setNormal(bool value) { normal_ = value; }
214
217 inline bool atSolution() const { return atSolution_; }
218
221 inline void setAtSolution(bool value) { atSolution_ = value; }
222
225 inline bool whenInfeasible() const { return whenInfeasible_; }
226
229 inline void setWhenInfeasible(bool value) { whenInfeasible_ = value; }
230
232 inline CglCutGenerator * generator() const { return generator_; }
233
235 inline int numConsGenerated() { return numConsGenerated_; }
236
238 inline void addNumConsGenerated(int n) { numConsGenerated_ += n; }
239
241 inline int numConsUsed() { return numConsUsed_; }
242
244 inline void addNumConsUsed(int n) { numConsUsed_ += n; }
245
247 inline double time() const { return time_; }
248
250 inline void addTime(double t) { time_ += t; }
251
253 inline int calls() const { return calls_; }
254
256 inline void addCalls(int n=1) { calls_ += n; }
257
259 inline int noConsCalls() const { return noConsCalls_; }
260
262 inline void addNoConsCalls(int n=1) { noConsCalls_ += n; }
264};
265
266#endif
BlisCutStrategy
Definition Blis.h:69
@ BlisCutStrategyAuto
Definition Blis.h:73
Interface between Blis and Cut Generation Library.
int calls() const
Number called.
bool whenInfeasible_
Whether to call generator when a subproblem is found to be infeasible.
void setWhenInfeasible(bool value)
Set whether the con generator should be called when the subproblem is found to be infeasible.
void setName(const char *str)
return name of generator.
void addTime(double t)
Increase Cpu time used.
void setAtSolution(bool value)
Set whether the con generator should be called when a solution is found.
BlisConGenerator(const BlisConGenerator &)
Copy constructor.
void addNoConsCalls(int n=1)
Increase the number of no cons called.
int cutGenerationFreq() const
Get the con generation interval.
BlisModel * model_
The client model.
bool normal_
Whether to call the generator in the normal place.
std::string name() const
return name of generator.
int calls_
The times of calling this generator.
bool normal() const
Get whether the con generator should be called in the normal place.
int noConsCalls() const
Number called and no cons found.
void setModel(BlisModel *m)
Set the model.
void addNumConsUsed(int n)
Increase the number of generated cons.
BlisCutStrategy strategy() const
Get the con generation interval.
BlisConGenerator(BlisModel *model, CglCutGenerator *generator, const char *name=NULL, BlisCutStrategy strategy=BlisCutStrategyAuto, int cutGenerationFrequency_=1, bool normal=true, bool atSolution=false, bool infeasible=false)
Useful constructor.
bool atSolution_
Whether to call the generator when a new solution is found.
int noConsCalls_
The times of calling this generator and no cons found.
void setCutGenerationFreq(int freq)
Set the con generation strategy.
int numConsGenerated()
Get number of generated cons.
double time_
Used CPU/User time.
int numConsGenerated_
Number of cons generated.
void setNormal(bool value)
Set whether the con generator should be called in the normal place.
void addNumConsGenerated(int n)
Increase the number of generated cons.
BlisConGenerator & operator=(const BlisConGenerator &rhs)
Assignment operator.
virtual ~BlisConGenerator()
Destructor.
CglCutGenerator * generator_
The CglCutGenerator object.
BlisConGenerator()
Default constructor.
void refreshModel(BlisModel *model)
Refresh the model.
BlisModel * getModel()
Set the client model.
bool atSolution() const
Get whether the con generator should be called when a solution is found.
std::string name_
Name of generator.
int cutGenerationFrequency_
The frequency of calls to the cut generator.
virtual bool generateConstraints(BcpsConstraintPool &conPool)
Generate cons for the client model.
int numConsUsed_
Number of cons used.
BlisCutStrategy strategy_
When to call CglCutGenerator::generateCuts routine.
void addCalls(int n=1)
Increase the number of called.
void setStrategy(BlisCutStrategy value)
Set the con generation strategy.
CglCutGenerator * generator() const
Get the CglCutGenerator bound to this BlisConGenerator.
bool whenInfeasible() const
Get whether the con generator should be called when the subproblem is found to be infeasible.
double time() const
Cpu time used.
int numConsUsed()
Get number of used cons.
#define BLISLIB_EXPORT
Definition config.h:5