Generated on Fri Aug 24 2012 04:52:11 for Gecode by doxygen 1.8.1.2
task.hh
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2009
8  *
9  * Last modified:
10  * $Date: 2011-07-13 02:03:22 +1000 (Wed, 13 Jul 2011) $ by $Author: tack $
11  * $Revision: 12176 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 #ifndef __GECODE_INT_TASK_HH__
39 #define __GECODE_INT_TASK_HH__
40 
41 #include <gecode/int.hh>
42 
43 namespace Gecode { namespace Int {
44 
46  template<class ManTask>
47  class ManToOptTask : public ManTask {
48  protected:
51  public:
53 
54 
55  ManToOptTask(void);
57 
59 
60 
61  bool mandatory(void) const;
63  bool excluded(void) const;
65  bool optional(void) const;
67 
69 
70  bool assigned(void) const;
72 
74 
75 
76  ModEvent mandatory(Space& home);
78  ModEvent excluded(Space& home);
80 
82 
83 
84  void update(Space& home, bool share, ManToOptTask& t);
86 
88 
89 
90  void subscribe(Space& home, Propagator& p, PropCond pc);
92  void cancel(Space& home, Propagator& p, PropCond pc);
94  };
95 
96 }}
97 
99 
100 namespace Gecode { namespace Int {
101 
103  template<class TaskView>
104  class FwdToBwd : public TaskView {
105  public:
107 
108 
109  int est(void) const;
111  int ect(void) const;
113  int lst(void) const;
115  int lct(void) const;
117  int pmin(void) const;
119  int pmax(void) const;
121 
123 
124 
125  ModEvent est(Space& home, int n);
127  ModEvent ect(Space& home, int n);
129  ModEvent lst(Space& home, int n);
131  ModEvent lct(Space& home, int n);
133  ModEvent norun(Space& home, int e, int l);
135  };
136 
137 }}
138 
140 
141 namespace Gecode { namespace Int {
142 
149  template<class TaskView>
150  class TaskViewTraits {};
151 
158  template<class Task>
159  class TaskTraits {};
160 
161 }}
162 
163 namespace Gecode { namespace Int {
164 
166  template<class Task>
167  class TaskArray {
168  private:
170  int n;
172  Task* t;
173  public:
175 
176 
177  TaskArray(void);
179  TaskArray(Space& home, int n);
181  TaskArray(const TaskArray<Task>& a);
183  const TaskArray<Task>& operator =(const TaskArray<Task>& a);
185 
187 
188 
189  int size(void) const;
191  void size(int n);
193 
195 
196 
197  Task& operator [](int i);
199  const Task& operator [](int i) const;
201 
203 
204 
205  void subscribe(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
207  void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
209 
211 
212 
213  void update(Space&, bool share, TaskArray& a);
215 
216  private:
217  static void* operator new(size_t);
218  static void operator delete(void*,size_t);
219  };
220 
225  template<class Char, class Traits, class Task>
226  std::basic_ostream<Char,Traits>&
227  operator <<(std::basic_ostream<Char,Traits>& os,
228  const TaskArray<Task>& t);
229 
230 
232  template<class TaskView>
234  protected:
239  public:
241 
242 
245 
247 
248 
249  int size(void) const;
251  void size(int n);
253 
255 
256 
257  TaskView& operator [](int i);
259  const TaskView& operator [](int i) const;
261  private:
262  static void* operator new(size_t);
263  static void operator delete(void*,size_t);
264  };
265 
270  template<class Char, class Traits, class TaskView>
271  std::basic_ostream<Char,Traits>&
272  operator <<(std::basic_ostream<Char,Traits>& os,
273  const TaskViewArray<TaskView>& t);
274 
275 }}
276 
277 #include <gecode/int/task/array.hpp>
278 
279 namespace Gecode { namespace Int {
280 
287  };
288 
290  template<class TaskView, SortTaskOrder sto, bool inc>
291  void sort(TaskViewArray<TaskView>& t);
292 
294  template<class TaskView, SortTaskOrder sto, bool inc>
295  void sort(int* map, const TaskViewArray<TaskView>& t);
296 
298  template<class TaskView, SortTaskOrder sto, bool inc>
299  void sort(int* map, int n, const TaskViewArray<TaskView>& t);
300 
301 }}
302 
303 #include <gecode/int/task/sort.hpp>
304 
305 namespace Gecode { namespace Int {
306 
308  template<class TaskView, SortTaskOrder sto, bool inc>
309  class TaskViewIter {
310  protected:
312  int* map;
314  int i;
316  TaskViewIter(void);
317  public:
321 
322 
323  bool operator ()(void) const;
325  int left(void) const;
327  void operator ++(void);
329 
331 
332 
333  int task(void) const;
335  };
336 
338  template<class OptTaskView, SortTaskOrder sto, bool inc>
339  class ManTaskViewIter : public TaskViewIter<OptTaskView,sto,inc> {
340  protected:
343  public:
346  };
347 
348 }}
349 
350 #include <gecode/int/task/iter.hpp>
351 
352 namespace Gecode { namespace Int {
353 
355  int plus(int x, int y);
356 
358  double plus(double x, double y);
359 
361  double div(double x, double y);
362 
364  template<class TaskView, class Node>
365  class TaskTree {
366  template<class,class> friend class TaskTree;
367  protected:
371  Node* node;
373  int* _leaf;
374 
376  int n_inner(void) const;
378  int n_nodes(void) const;
380  static bool n_root(int i);
382  bool n_leaf(int i) const;
384  static int n_left(int i);
386  static bool left(int i);
388  static int n_right(int i);
390  static bool right(int i);
392  static int n_parent(int i);
393  protected:
395  Node& leaf(int i);
397  const Node& root(void) const;
399  void update(int i, bool l=true);
401  void init(void);
403  void update(void);
407  template<class Node2> TaskTree(Region& r,
408  const TaskTree<TaskView,Node2>& t);
409  };
410 
411 }}
412 
413 #include <gecode/int/task/tree.hpp>
414 
415 namespace Gecode { namespace Int {
416 
423  template<class Task, PropCond pc>
424  class TaskProp : public Propagator {
425  protected:
429  TaskProp(Home home, TaskArray<Task>& t);
431  TaskProp(Space& home, bool shared, TaskProp<Task,pc>& p);
432  public:
434  virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
436  virtual size_t dispose(Space& home);
437  };
438 
440  template<class OptTask,PropCond pc>
442 
444  template<class OptTask,PropCond pc,class Cap>
445  ExecStatus purge(Space& home, Propagator& p, TaskArray<OptTask>& t, Cap c);
446 
447 }}
448 
449 #include <gecode/int/task/prop.hpp>
450 #include <gecode/int/task/purge.hpp>
451 
452 #endif
453 
454 // STATISTICS: scheduling-prop