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

- File List
- File Members

BlisHeuristic.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/CbcHeuristic.hpp
27 //#############################################################################
28
29
30 #ifndef BlisHeuristic_h_
31 #define BlisHeuristic_h_
32
33 #include <string>
34 #include <vector>
35
36 #include "CoinPackedMatrix.hpp"
37 #include "OsiCuts.hpp"
38
39 #include "Blis.h"
40
41 class BlisModel;
42
43
44 //#############################################################################
45
46
48 class BlisHeuristic {
49
50 private:
51
53 BlisHeuristic & operator = (const BlisHeuristic& rhs);
54
55 protected:
56
58 BlisModel *model_;
59
61 char *name_;
62
70 BlisHeurStrategy strategy_;
71
73 int heurCallFrequency_;
74
76 int numSolutions_;
77
79 double time_;
80
82 int calls_;
83
85 int noSolsCalls_;
86
87 public:
88
90 BlisHeuristic() {
91 model_ = NULL;
92 name_ = strdup("Unknown");
93 strategy_ = BlisHeurStrategyAuto;
94 heurCallFrequency_ = 1;
95 numSolutions_ = 0;
96 time_ = 0.0;
97 calls_ = 0;
98 noSolsCalls_ = 0;
99 }
100
102 BlisHeuristic(BlisModel *model, const char *name,
103 BlisHeurStrategy strategy, int heurCallFrequency) {
104 model_ = model;
105 if (name) {
106 name_ = strdup(name);
107 }
108 else {
109 name_ = strdup("Unknown");
110 }
111 strategy_ = strategy;
112 heurCallFrequency_ = heurCallFrequency;
113 numSolutions_ = 0;
114 time_ = 0.0;
115 calls_ = 0;
116 noSolsCalls_ = 0;
117 }
118
120 virtual ~BlisHeuristic() { if (name_) free(name_); }
121
123 BlisHeuristic(const BlisHeuristic & rhs) {
124 model_ = rhs.model_;
125 name_ = strdup(rhs.name_);
126 strategy_ = rhs.strategy_; // What if disabled?
127 heurCallFrequency_ = rhs.heurCallFrequency_;
128 numSolutions_ = 0;
129 time_ = 0.0;
130 calls_ = 0;
131 noSolsCalls_ = 0;
132 }
133
135 virtual void setModel(BlisModel * model) { model_ = model ;}
136
139 virtual void setStrategy(BlisHeurStrategy strategy) {strategy_ = strategy;}
140 virtual BlisHeurStrategy strategy() const { return strategy_; }
141 //@]
142
145 virtual void setHeurCallFrequency(int freq) { heurCallFrequency_ = freq; }
146 virtual int heurCallFrequency() const { return heurCallFrequency_; }
147 //@]
148
150 virtual BlisHeuristic * clone() const {
151 BlisHeuristic *h = NULL;
152 assert(0);
153 return h;
154 }
155
161 virtual bool searchSolution(double & objectiveValue,
162 double * newSolution)=0;
163
172 virtual bool searchSolution(double & objectiveValue,
173 double * newSolution,
174 OsiCuts & cs) { return 0; }
175
177 inline const char * name() const { return name_; }
178
180 inline void addNumSolutions(int num=1) { numSolutions_ += num; }
181
183 inline int numSolutions() const { return numSolutions_; }
184
186 inline void addTime(double t=0.0) { time_ += t; }
187
189 inline double time() const { return time_; }
190
192 inline void addCalls(int c=1) { calls_ += c; }
193
195 inline int calls() const { return calls_; }
196
198 inline int noSolCalls() const { return noSolsCalls_; }
199
201 inline void addNoSolCalls(int n=1) { noSolsCalls_ += n; }
202 };
203
204 #endif
205
BlisHeurStrategy
BlisHeurStrategy
Definition: Blis.h:77
BlisModel
Definition: BlisModel.h:60
CoinPackedMatrix.hpp
BlisHeuristic::addNumSolutions
void addNumSolutions(int num=1)
Record number of solutions found.
Definition: BlisHeuristic.h:180
BlisHeuristic::searchSolution
virtual bool searchSolution(double &objectiveValue, double *newSolution, OsiCuts &cs)
returns 0 if no solution, 1 if valid solution, -1 if just returning an estimate of best possible solu...
Definition: BlisHeuristic.h:172
BlisHeuristic::heurCallFrequency
virtual int heurCallFrequency() const
Get/set strategy.
Definition: BlisHeuristic.h:146
BlisHeuristic::operator=
BlisHeuristic & operator=(const BlisHeuristic &rhs)
Illegal Assignment operator.
BlisHeuristic
Heuristic base class.
Definition: BlisHeuristic.h:46
BlisHeuristic::setModel
virtual void setModel(BlisModel *model)
update model (This is needed if cliques update matrix etc).
Definition: BlisHeuristic.h:135
BlisHeuristic::noSolsCalls_
int noSolsCalls_
The times of calling this heuristic and no solutions found.
Definition: BlisHeuristic.h:85
BlisHeuristic::noSolCalls
int noSolCalls() const
Number called and no cons found.
Definition: BlisHeuristic.h:198
BlisHeuristic::addNoSolCalls
void addNoSolCalls(int n=1)
Increase the number of no cons called.
Definition: BlisHeuristic.h:201
BlisHeuristic::calls
int calls() const
Number of times called.
Definition: BlisHeuristic.h:195
BlisHeuristic::strategy_
int strategy_
When to call findSolution() routine.
Definition: BlisHeuristic.h:67
BlisHeuristic::strategy
virtual BlisHeurStrategy strategy() const
Get/set strategy.
Definition: BlisHeuristic.h:140
BlisHeuristic::heurCallFrequency_
int heurCallFrequency_
The frequency with which to call the heuristic.
Definition: BlisHeuristic.h:73
BlisHeuristic::clone
virtual BlisHeuristic * clone() const
Clone a heuristic.
Definition: BlisHeuristic.h:150
OsiCuts
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
BlisHeuristic::strategy_
BlisHeurStrategy strategy_
When to call findSolution() routine.
Definition: BlisHeuristic.h:70
BlisHeuristic::setHeurCallFrequency
virtual void setHeurCallFrequency(int freq)
Get/set call frequency.
Definition: BlisHeuristic.h:145
BlisHeuristic::~BlisHeuristic
virtual ~BlisHeuristic()
Distructor.
Definition: BlisHeuristic.h:120
BlisHeuristic::BlisHeuristic
BlisHeuristic(const BlisHeuristic &rhs)
Copy constructor.
Definition: BlisHeuristic.h:123
BlisHeuristic::numSolutions_
int numSolutions_
Number of solutions found.
Definition: BlisHeuristic.h:70
BlisHeuristic::setStrategy
virtual void setStrategy(BlisHeurStrategy strategy)
Get/set strategy.
Definition: BlisHeuristic.h:139
Blis.h
BlisHeuristic::time
double time() const
Cpu time used.
Definition: BlisHeuristic.h:189
BlisHeuristic::time_
double time_
Used CPU/User time.
Definition: BlisHeuristic.h:73
BlisHeuristic::numSolutions
int numSolutions() const
Number of solutions found.
Definition: BlisHeuristic.h:183
BlisHeuristic::name
const char * name() const
return name of generator.
Definition: BlisHeuristic.h:177
BlisHeurStrategyAuto
Definition: Blis.h:81
BlisHeuristic::model_
BlisModel * model_
Pointer to the model.
Definition: BlisHeuristic.h:56
BlisHeuristic::name_
char * name_
Heuristics name.
Definition: BlisHeuristic.h:59
BlisHeuristic::addCalls
void addCalls(int c=1)
Record number of times called.
Definition: BlisHeuristic.h:192
BlisHeuristic::addTime
void addTime(double t=0.0)
Record Cpu time used.
Definition: BlisHeuristic.h:186
OsiCuts.hpp
BlisHeuristic::calls_
int calls_
The times of calling this heuristic.
Definition: BlisHeuristic.h:76
BlisHeuristic::BlisHeuristic
BlisHeuristic()
Default Constructor.
Definition: BlisHeuristic.h:90
BlisHeuristic::BlisHeuristic
BlisHeuristic(BlisModel *model, const char *name, BlisHeurStrategy strategy, int heurCallFrequency)
Useful constructor.
Definition: BlisHeuristic.h:102
BlisHeuristic::searchSolution
virtual bool searchSolution(double &objectiveValue, double *newSolution)=0
returns 0 if no solution, 1 if valid solution with better objective value than one passed in Sets sol...
BlisHeuristic::strategy
virtual int strategy()
Get/set strategy.
Definition: BlisHeuristic.h:124