MineLink
 All Data Structures Functions Variables Pages
filtering.h
1 #ifndef __FILTERING_H__
2 #define __FILTERING_H__
3 
4 #include "../../data_structures/bm/blockmodel.h"
5 #include "constraint.h"
6 #include "../../data_structures/bm/blocksel.h"
7 #include "instance.h"
8 #include <vector>
9 #include <string>
10 
11 using std::vector;
12 using std::string;
13 
14 namespace delphos {
15 
21 {
22 public:
23 
24  //ForceMiningByConstraint(const string & name, const unsigned int& period,delphos::BlockModel& bm);
34  ForceMiningByConstraint(const string & name, const unsigned int& period, delphos::BlockSelection * bs);
41  virtual bool Check(const Schedule & sch) const;
42 #ifndef MAC
43 
51  virtual bool Check(const delphos::FractionalSchedule & sch) const;
52 #endif
53 protected:
54  virtual string XMLHeading(const unsigned int & identation_level=0) const;
55  virtual string XMLBody(const unsigned int & identation_level=0) const;
56  virtual string XMLFooting(const unsigned int & identation_level=0) const;
57 };
58 
64 {
65 public:
66 
67  //DoNotMineBeforeConstraint(const string & name, const unsigned int& period,delphos::BlockModel& bm);
68 
78  DoNotMineBeforeConstraint(const string & name, const unsigned int& period, delphos::BlockSelection * bs);
79 
86  virtual bool Check(const delphos::Schedule & sch) const;
87 #ifndef MAC
88 
96  virtual bool Check(const delphos::FractionalSchedule & sch) const;
97 #endif
98 protected:
99  virtual string XMLHeading(const unsigned int & identation_level=0) const;
100  virtual string XMLBody(const unsigned int & identation_level=0) const;
101  virtual string XMLFooting(const unsigned int & identation_level=0) const;
102 };
103 
108 
109  public BlockConstraint
110 {
111  private:
112  vector<unsigned int> _affdest;
113  public:
114 
115  //DoNotSendToConstraint(const string & name,const vector<int> & affdestinations,delphos::BlockModel& bm);
116 
126  DoNotSendToConstraint(const string & name,const vector<int> & affdestinations, delphos::BlockSelection * bs);
127 
134  const unsigned int NumAffectedDestinations() const;
135 
141  const unsigned int GetNumAffectedDestinations() const;
142 
148  const unsigned int GetAffectedDestination(const unsigned int i) const;
149 
156  virtual bool Check(const delphos::Schedule & sch) const;
157 #ifndef MAC
158 
166  virtual bool Check(const delphos::FractionalSchedule & sch) const;
167 #endif
168 
169 protected:
170  virtual string XMLHeading(const unsigned int & identation_level=0) const;
171  virtual string XMLBody(const unsigned int & identation_level=0) const;
172  virtual string XMLFooting(const unsigned int & identation_level=0) const;
173 };
174 
179 private:
180  vector<double> _capacities;
181  map<BlockIndexType,unsigned int> _min_extract_period;
182  map<BlockIndexType,float> _cone_val;
183  map<BlockIndexType,float> _cone_weight;
184 
185  Precedence* _prec;
186  BlockIndexType _attr_pos;
187  BlockModel* _bm;
188 
189  vector<string> _dest;
190  vector<string> _val_attr;
191 
192  typedef struct node2 {
193  set<BlockIndexType> precedenceSet;
194  set<BlockIndexType> succSet;
195  vector<bool> fullprecedenceSet;
196  BlockIndexType number;
197  float w;
198  }Node2;
199 
200  typedef struct node1 {
201  set<BlockIndexType> precedenceSet;
202  set<BlockIndexType> succSet;
203  set<BlockIndexType> fullprecedenceSet;
204  BlockIndexType number;
205  float w;
206  }Node1;
207 
208  typedef struct node3 {
209  set<BlockIndexType> precedenceSet;
210  set<BlockIndexType> succSet;
211  set<BlockIndexType> fullprecedenceSet;
212  BlockIndexType number;
213  float w;
214  float val;
215  }Node3;
216 
217 public:
227  MinExtractPeriodConstraint(const string& name,const string& attribute,const vector<double>& capacities,delphos::Precedence* prec, delphos::BlockModel& bm);
228 
240  MinExtractPeriodConstraint(const string& name,const string& attribute,const vector<double>& capacities,delphos::Precedence* prec, delphos::BlockModel& bm,const vector<string> & destinations,const vector<string>& val_attr);
241 
245  virtual ~MinExtractPeriodConstraint();
246 
251 
257  void SetMinExtractPeriod(const delphos::BlockIndexType id,const unsigned int period);
258 
263  unsigned int GetMinExtractPeriod(const delphos::BlockIndexType id) const;
264 
269  float GetConeVal(const delphos::BlockIndexType id) const;
270 
275  float GetConeWeight(const delphos::BlockIndexType id) const;
276 
281  const unsigned int NumPeriods() const;
282 
286  const unsigned int GetNumPeriods() const;
287 
292  const double GetCapacity(const unsigned int period) const;
293 
297  const Precedence& GetPrecedence() const;
304  virtual bool Check(const delphos::Schedule& sch) const;
305 
306 protected:
307  virtual string XMLHeading(const unsigned int & identation_level=0) const;
308  virtual string XMLBody(const unsigned int & identation_level=0) const;
309  virtual string XMLFooting(const unsigned int & identation_level=0) const;
310 };
311 
312 
313 }
314 
315 #endif
316 
Abstracts a set of blocks (subset of a blockmodel).
Definition: blocksel.h:33
bool ComputeMinExtractPeriod()
Computes the extracted period minimums for each block.
Definition: filtering.cpp:455
virtual ~MinExtractPeriodConstraint()
The destructor.
Definition: filtering.cpp:446
A constraint limiting the period at which a block should be mined.
Definition: filtering.h:62
virtual bool Check(const delphos::Schedule &sch) const
checks if the constraint is satisfied by the schedule.
Definition: filtering.cpp:900
const unsigned int NumPeriods() const
Returns the number of periods. Deprecated.
Definition: filtering.cpp:857
A constraint that prevents certain blocks to be sent to given processes.
Definition: filtering.h:107
const double GetCapacity(const unsigned int period) const
Returns the capacity of given period.
Definition: filtering.cpp:867
A base class for constraints that apply to subsets of blocks.
Definition: constraint.h:158
virtual bool Check(const delphos::Schedule &sch) const
checks if the constraint is satisfied by the schedule.
Definition: filtering.cpp:145
Abstracts a container of blocks as a table with arbitrary number of attributes that can be accessed b...
Definition: blockmodel.h:62
Implements a precedence as an explicit set of arcs between blocks. Provides utility functions...
Definition: precs.h:22
A constraint that forces a block to be mined before or at some period.
Definition: filtering.h:19
float GetConeVal(const delphos::BlockIndexType id) const
Returns the full precedence cone value of a given block.
Definition: filtering.cpp:843
virtual bool Check(const Schedule &sch) const
checks if the constraint is satisfied by the schedule.
Definition: filtering.cpp:40
Defines a fractional scheduling of blocks.
Definition: fractional_schedule.h:22
A constraint that prevents certain blocks that can't be extracted before a period due to capacities c...
Definition: filtering.h:178
const unsigned int GetNumPeriods() const
Returns the number of periods.
Definition: filtering.cpp:862
unsigned int GetMinExtractPeriod(const delphos::BlockIndexType id) const
Returns The extracted period minimum for a given block.
Definition: filtering.cpp:825
const unsigned int GetAffectedDestination(const unsigned int i) const
Return the index of the i-th destinations affected by the constraint.
Definition: filtering.cpp:265
DoNotSendToConstraint(const string &name, const vector< int > &affdestinations, delphos::BlockSelection *bs)
A constraints that prevents blocks to be sent to given processes.
Definition: filtering.cpp:251
float GetConeWeight(const delphos::BlockIndexType id) const
Returns the full precedence cone weight of a given block.
Definition: filtering.cpp:834
DoNotMineBeforeConstraint(const string &name, const unsigned int &period, delphos::BlockSelection *bs)
Creates a constraints limiting the period at which a block should be mined.
Definition: filtering.cpp:126
const unsigned int NumAffectedDestinations() const
Return the number of destinations affected by the constraint.
Definition: filtering.cpp:269
Defines a constraint that limits processing periods or destinations for blocks.
Definition: constraint.h:234
MinExtractPeriodConstraint(const string &name, const string &attribute, const vector< double > &capacities, delphos::Precedence *prec, delphos::BlockModel &bm)
Defines A constraint that prevents certain blocks that can't be extracted before a period due to capa...
Definition: filtering.cpp:414
void SetMinExtractPeriod(const delphos::BlockIndexType id, const unsigned int period)
Set a minimum extracted period for a block.
Definition: filtering.cpp:852
virtual bool Check(const delphos::Schedule &sch) const
checks if the constraint is satisfied by the schedule.
Definition: filtering.cpp:297
ForceMiningByConstraint(const string &name, const unsigned int &period, delphos::BlockSelection *bs)
Creates a constraint limiting the period at which a block should be mined.
Definition: filtering.cpp:21
Defines a scheduling of blocks.
Definition: schedule.h:23
const unsigned int GetNumAffectedDestinations() const
Return the number of destinations affected by the constraint.
Definition: filtering.cpp:273
const Precedence & GetPrecedence() const
Returns The precedence.
Definition: filtering.cpp:874