- 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 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 * Corporation, Lehigh University, Yan Xu, Ted Ralphs, Matthew Salzman and *
21 * others. 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 class BlisModel;
40
41
42 //#############################################################################
43
44
46 class BlisHeuristic {
47
48 private:
49
51 BlisHeuristic & operator = (const BlisHeuristic& rhs);
52
53 protected:
54
56 BlisModel *model_;
57
59 char *name_;
60
67 int strategy_;
68
70 int numSolutions_;
71
73 double time_;
74
76 int calls_;
77
78 public:
79
81 BlisHeuristic() {
82 model_ = NULL;
83 name_ = strdup("Unknown");
84 strategy_ = 0;
85 numSolutions_ = 0;
86 time_ = 0.0;
87 calls_ = 0;
88 }
89
91 BlisHeuristic(BlisModel *model, const char *name, int strategy) {
92 model_ = model;
93 if (name) {
94 name_ = strdup(name);
95 }
96 else {
97 name_ = strdup("Unknown");
98 }
99 strategy_ = strategy;
100 numSolutions_ = 0;
101 time_ = 0.0;
102 calls_ = 0;
103 }
104
106 virtual ~BlisHeuristic() { if (name_) free(name_); }
107
109 BlisHeuristic(const BlisHeuristic & rhs) {
110 model_ = rhs.model_;
111 name_ = strdup(rhs.name_);
112 strategy_ = rhs.strategy_; // What if disabled?
113 numSolutions_ = 0;
114 time_ = 0.0;
115 calls_ = 0;
116 }
117
119 virtual void setModel(BlisModel * model) { model_ = model ;}
120
123 virtual void setStrategy(int strategy) { strategy_ = strategy; }
124 virtual int strategy() { return strategy_; }
125 //@]
126
128 virtual BlisHeuristic * clone() const = 0;
129
135 virtual bool searchSolution(double & objectiveValue,
136 double * newSolution)=0;
137
146 virtual int searchSolution(double & objectiveValue,
147 double * newSolution,
148 OsiCuts & cs) { return 0; }
149
151 int numSolutions() { return numSolutions_; }
152
154 inline double time() { return time_; }
155
157 inline int calls() { return calls_; }
158 };
159
160 #endif
161
BlisModel
Definition: BlisModel.h:60
CoinPackedMatrix.hpp
BlisHeuristic::time
double time()
Cpu time used.
Definition: BlisHeuristic.h:154
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:119
BlisHeuristic::strategy_
int strategy_
When to call findSolution() routine.
Definition: BlisHeuristic.h:67
OsiCuts
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
BlisHeuristic::~BlisHeuristic
virtual ~BlisHeuristic()
Distructor.
Definition: BlisHeuristic.h:106
BlisHeuristic::BlisHeuristic
BlisHeuristic(const BlisHeuristic &rhs)
Copy constructor.
Definition: BlisHeuristic.h:109
BlisHeuristic::numSolutions_
int numSolutions_
Number of solutions found.
Definition: BlisHeuristic.h:70
BlisHeuristic::numSolutions
int numSolutions()
Number of solutions found.
Definition: BlisHeuristic.h:151
BlisHeuristic::time_
double time_
Used CPU/User time.
Definition: BlisHeuristic.h:73
BlisHeuristic::BlisHeuristic
BlisHeuristic(BlisModel *model, const char *name, int strategy)
Useful constructor.
Definition: BlisHeuristic.h:91
BlisHeuristic::name
const char * name() const
return name of generator.
Definition: BlisHeuristic.h:177
BlisHeuristic::searchSolution
virtual int 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:146
BlisHeuristic::model_
BlisModel * model_
Pointer to the model.
Definition: BlisHeuristic.h:56
BlisHeuristic::name_
char * name_
Heuristics name.
Definition: BlisHeuristic.h:59
BlisHeuristic::calls
int calls()
Cpu time used.
Definition: BlisHeuristic.h:157
OsiCuts.hpp
BlisHeuristic::calls_
int calls_
The times of calling this heuristic.
Definition: BlisHeuristic.h:76
BlisHeuristic::clone
virtual BlisHeuristic * clone() const =0
Clone a heuristic.
BlisHeuristic::setStrategy
virtual void setStrategy(int strategy)
Get/set strategy.
Definition: BlisHeuristic.h:123
BlisHeuristic::BlisHeuristic
BlisHeuristic()
Default Constructor.
Definition: BlisHeuristic.h:81
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