MineLink
 All Data Structures Functions Variables Pages
aggheuristics.h
1 #ifndef __AGGHEURISTICS_H__
2 #define __AGGHEURISTICS_H__
3 
4 #include "../heuristics.h"
5 #include "../../../../data_structures/bm/functors.h"
6 #include "../../../../data_structures/precs/slopes.h"
7 #include <map>
8 #include <typeinfo>
9 
10 using namespace std;
11 
12 
13 
14 namespace delphos {
15 
16 //void mycallback(const double& percentage);
17 
29 class HReb : public SchedulingHeuristic {
30  private:
31  double _rx;
32  double _ry;
33  double _rz;
34  string _agg_sched_name;
35  string _desagg_sched_name;
36  Precedence* _prec;
37  SlopePrecedence* _agg_prec;
38 
39  Schedule* _agg_schedule;
40  Schedule* _desagg_schedule;
41 
42  BlockModel* _agg_bm;
43  SchedulingInstance* _agg_si;
44 
45  double _slope_ang;
46  const unsigned int _nblevels;
47  double _agg_obj;
48  double _obj;
49  double _gap;
50  vector<RelativeCoordinatesIndex>* _patterni;
51 
52  bool RunAggregation();
53  bool RunDesAggregation();
54  int _last_period;
55  unsigned int _numthread;
56  bool _verbose;
57 
58  unsigned int _swh_window_size[2];
59  unsigned int _swh_sub_window_size[2];
60  unsigned int _swh_step[2];
61 
62  public:
78  HReb(delphos::SchedulingInstance& si,const double& slope_ang,const unsigned int& nblevels
79 #ifndef NO_GUROBI
80  ,const string& agg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
81  ,const string& desagg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
82 #else
83  ,const string& agg_sched_name=Scheduler::CBC_SlidingTimeWindowHeuristic
84  ,const string& desagg_sched_name=Scheduler::CBC_SlidingTimeWindowHeuristic
85 #endif
86  ,const double& rx=0.0,const double& ry=0.0,const double& rz=0.0);
87  /*HReb(delphos::SchedulingInstance& si,const double& slope_ang,const unsigned int& nblevels
88  ,const vector<double>& pattern
89  ,const string& agg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
90  ,const string& desagg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
91  ,const double& rx=0.0,const double& ry=0.0,const double& rz=0.0);*/
92  /* HReb(delphos::SchedulingInstance& si
93  ,const string& agg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
94  ,const string& desagg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
95  ,const double& rx=0.0,const double& ry=0.0,const double& rz=0.0); */
96 
100  virtual ~HReb();
101 
105  bool Run();
106 
111  void SetGap(const float& gap);
112 
120  void SetSTWHParam(const unsigned int & window_size, const unsigned int & sub_window_size,const unsigned int & step,const bool& backward=true);
121 
125  double GetObjective();
126 
130  double GetAggregatedObjective();
131 
136  void SetLastFixedPeriod(const unsigned int& lastperiod);
137 
141  delphos::BlockModel& GetAggregatedModel();
142 
146  void SetNumThread(const unsigned int& nthread);
147 
151  void SetVerbose();
152 };
153 
154 #ifndef DOXYGEN
155 
163 class HDiv2 : public SchedulingHeuristic {
164 private:
165  //const double& _delta;
166  string _agg_sched_name;
167  string _desagg_sched_name;
168  unsigned int _swh_win_size;
169 
170  Schedule* _agg_schedule;
171  unsigned int _nb_aggreg_sub_part;
172  vector<int> _period_unit;
173 
174  SchedulingInstance* _agg_si;
175 
176  double _agg_obj;
177  double _obj;
178  double _gap;
179  bool _use_min_time;
180 
181  bool RunAggregation();
182  bool RunDesAggregation();
183 
184 public:
196 #ifndef NO_GUROBI
197  ,const string& agg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
198  ,const string& desagg_sched_name=Scheduler::GUROBI_SlidingTimeWindowHeuristic
199 #else
200  ,const string& agg_sched_name=Scheduler::CBC_SlidingTimeWindowHeuristic
201  ,const string& desagg_sched_name=Scheduler::CBC_SlidingTimeWindowHeuristic
202 #endif
203  , bool bUseMinTime=false);
204 
208  virtual ~HDiv2();
209 
213  virtual bool Run();
214 
219  void SetGap(const float& gap);
220 
225  void SetSWHWindowSize(const unsigned int& ws);
226 
230  double GetObjective();
231 
235  double GetAggregatedObjective();
236 };
237 #endif
238 
239 
240 /*class HDiv : public SchedulingHeuristic {
241 private:
242  unsigned int _nb_div_part;
243  const double& _delta;
244  const unsigned int _tmin;
245 
246 class AggregatedSchedulingInstance : public SchedulingInstance {
247 
248 private:
249 
250  const unsigned int _period_unit;
251  const unsigned int _last_period_unit;
252  const unsigned int _start_period;
253 
254 
255 
256 public:
257  vector<BlockIndexType> _corresp;
258 
259  AggregatedSchedulingInstance(delphos::SchedulingInstance& si,const unsigned int& period_unit_value,const unsigned int& last_period_unit_value,const unsigned int& startperiod);
260  AggregatedSchedulingInstance(delphos::BlockModel & bm, const unsigned int & horizon,const unsigned int& period_unit_value,const unsigned int& last_period_unit_value,const unsigned int& startperiod, const double discount_rate = 0.0);
261 
262  virtual ~AggregatedSchedulingInstance();
263  const unsigned int& GetPeriodUnit() const;
264  const unsigned int& GetLastPeriodUnit() const;
265  const unsigned int& GetStartPeriod() const;
266 
267 
268 
269  virtual void Report();
270 };
271  AggregatedSchedulingInstance* AggregateTime(SchedulingInstance& si,const unsigned int& startperiod);
272  bool RunAggregatedInstance(AggregatedSchedulingInstance& si);
273 
274 public:
275  const unsigned int& GetTMin() const;
276  HDiv(delphos::SchedulingInstance& si,const unsigned int& nb_div_part,const unsigned int& tmin,const double& delta=0.0);
277  virtual bool Run();
278 };*/
279 
280 
281 
282 
283 /*class MinPeriodHeur: public Heuristic {
284 private:
285  vector<double> _capacities;
286  string _weight_attr;
287  Schedule * _schedule;
288  double _obj_val;
289  double _mipgap;
290 public:
291  MinPeriodHeur(SchedulingInstance& si,const string& attribute,const vector<double>& capacities);
292  virtual bool Run();
293  double GetObjValue();
294  const Schedule& GetSchedule();
295  void SetGap(const float& gap);
296 };*/
297 
298 }
299 #endif
Class that defines a twos phase Reblocking heuristic that solve a scheduling instance. First phase is a topological aggregation. The second phase is a topoligcal desaggregation that permit to obtain a feasible solution to original problem. This implementation of the heuristic is not working for a model that got multi fractional destination variables. If the scheduling instance has got the PCPSP flag on, an exception is thrown. This implementation of the heuristic is working only for a simple slope precedence. RampPrecedenceConstaint, sinking constraints, GeometricConstraint and BlockSelectionPrecedenceConstraint not implemented. Use of BlockSelection not null in all Constraints not implemented.
Definition: aggheuristics.h:29
Defines a scheduling instance to be solved.
Definition: instance.h:41
Vertical precedence class with utility methods for constant slope precedences.
Definition: slopes.h:62
Abstracts a container of blocks as a table with arbitrary number of attributes that can be accessed b...
Definition: blockmodel.h:62
Dummy class that define required methods for a heuristic that solve a scheduling instance.
Definition: heuristics.h:18
Implements a precedence as an explicit set of arcs between blocks. Provides utility functions...
Definition: precs.h:22
Defines a scheduling of blocks.
Definition: schedule.h:23