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 
47 
48  private:
49 
52 
53  protected:
54 
57 
59  char *name_;
60 
67  int strategy_;
68 
71 
73  double time_;
74 
76  int calls_;
77 
78  public:
79 
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  }
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 
double time()
Cpu time used.
BlisHeuristic & operator=(const BlisHeuristic &rhs)
Illegal Assignment operator.
Heuristic base class.
Definition: BlisHeuristic.h:46
virtual void setModel(BlisModel *model)
update model (This is needed if cliques update matrix etc).
int strategy_
When to call findSolution() routine.
Definition: BlisHeuristic.h:67
Collections of row cuts and column cuts.
Definition: OsiCuts.hpp:19
virtual ~BlisHeuristic()
Distructor.
BlisHeuristic(const BlisHeuristic &rhs)
Copy constructor.
int numSolutions_
Number of solutions found.
Definition: BlisHeuristic.h:70
int numSolutions()
Number of solutions found.
double time_
Used CPU/User time.
Definition: BlisHeuristic.h:73
BlisHeuristic(BlisModel *model, const char *name, int strategy)
Useful constructor.
Definition: BlisHeuristic.h:91
const char * name() const
return name of generator.
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...
BlisModel * model_
Pointer to the model.
Definition: BlisHeuristic.h:56
char * name_
Heuristics name.
Definition: BlisHeuristic.h:59
int calls()
Cpu time used.
int calls_
The times of calling this heuristic.
Definition: BlisHeuristic.h:76
virtual BlisHeuristic * clone() const =0
Clone a heuristic.
virtual void setStrategy(int strategy)
Get/set strategy.
BlisHeuristic()
Default Constructor.
Definition: BlisHeuristic.h:81
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...
virtual int strategy()
Get/set strategy.