Generated on Thu Feb 14 2013 20:59:32 for Gecode by doxygen 1.8.3.1
cumulative.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  * Guido Tack <tack@gecode.org>
6  *
7  * Copyright:
8  * Christian Schulte, 2009
9  * Guido Tack, 2010
10  *
11  * Last modified:
12  * $Date: 2011-07-13 20:11:00 +1000 (Wed, 13 Jul 2011) $ by $Author: tack $
13  * $Revision: 12181 $
14  *
15  * This file is part of Gecode, the generic constraint
16  * development environment:
17  * http://www.gecode.org
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining
20  * a copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be
28  * included in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  *
38  */
39 
40 #ifndef __GECODE_INT_CUMULATIVE_HH__
41 #define __GECODE_INT_CUMULATIVE_HH__
42 
43 #include <gecode/int/task.hh>
44 #include <gecode/int/unary.hh>
45 
59 namespace Gecode { namespace Int { namespace Cumulative {
60 
63  protected:
65  int _c;
66  public:
68 
69 
70  ManFixPTask(void);
72  ManFixPTask(IntVar s, int p, int c);
74  void init(IntVar s, int p, int c);
76  void init(const ManFixPTask& t);
78 
80 
81 
82  int c(void) const;
84  double e(void) const;
86 
88 
89 
90  void update(Space& home, bool share, ManFixPTask& t);
92 
93  };
94 
99  template<class Char, class Traits>
100  std::basic_ostream<Char,Traits>&
101  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t);
102 
105  protected:
107  int _c;
108  public:
110 
111 
112  ManFixPSETask(void);
120  ManFixPSETask(TaskType t, IntVar s, int p, int c);
128  void init(TaskType t, IntVar s, int p, int c);
130  void init(const ManFixPSETask& t);
132 
134 
135 
136  int c(void) const;
138  double e(void) const;
140 
142 
143 
144  void update(Space& home, bool share, ManFixPSETask& t);
146 
147  };
148 
153  template<class Char, class Traits>
154  std::basic_ostream<Char,Traits>&
155  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETask& t);
156 
159  protected:
161  int _c;
162  public:
164 
165 
166  ManFlexTask(void);
168  ManFlexTask(IntVar s, IntVar p, IntVar e, int c);
170  void init(IntVar s, IntVar p, IntVar e, int c);
172  void init(const ManFlexTask& t);
174 
176 
177 
178  int c(void) const;
180  double e(void) const;
182 
184 
185 
186  void update(Space& home, bool share, ManFlexTask& t);
188 
189  };
190 
195  template<class Char, class Traits>
196  std::basic_ostream<Char,Traits>&
197  operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t);
198 
199 
201  class OptFixPTask : public ManToOptTask<ManFixPTask> {
202  protected:
204  public:
206 
207 
208  OptFixPTask(void);
210  OptFixPTask(IntVar s, int p, int c, BoolVar m);
212  void init(IntVar s, int p, int c, BoolVar m);
214 
215  operator Unary::OptFixPTask (void);
216  };
217 
222  template<class Char, class Traits>
223  std::basic_ostream<Char,Traits>&
224  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t);
225 
227  class OptFixPSETask : public ManToOptTask<ManFixPSETask> {
228  protected:
230  public:
232 
233 
234  OptFixPSETask(void);
236  OptFixPSETask(TaskType t, IntVar s, int p, int c, BoolVar m);
238  void init(TaskType t, IntVar s, int p, int c, BoolVar m);
240 
241  operator Unary::OptFixPSETask (void);
242  };
243 
248  template<class Char, class Traits>
249  std::basic_ostream<Char,Traits>&
250  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t);
251 
253  class OptFlexTask : public ManToOptTask<ManFlexTask> {
254  protected:
256  public:
258 
259 
260  OptFlexTask(void);
262  OptFlexTask(IntVar s, IntVar p, IntVar e, int c, BoolVar m);
264  void init(IntVar s, IntVar p, IntVar e, int c, BoolVar m);
266 
267  operator Unary::OptFlexTask (void);
268  };
269 
274  template<class Char, class Traits>
275  std::basic_ostream<Char,Traits>&
276  operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t);
277 
278 }}}
279 
281 
282 namespace Gecode { namespace Int { namespace Cumulative {
283 
286 
289 
292 
295 
298 
301 
304 
307 
310 
313 
316 
319 
320 
325  template<class Char, class Traits>
326  std::basic_ostream<Char,Traits>&
327  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTaskBwd& t);
328 
333  template<class Char, class Traits>
334  std::basic_ostream<Char,Traits>&
335  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETaskBwd& t);
336 
341  template<class Char, class Traits>
342  std::basic_ostream<Char,Traits>&
343  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTaskBwd& t);
344 
349  template<class Char, class Traits>
350  std::basic_ostream<Char,Traits>&
351  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETaskBwd& t);
352 
353 }}}
354 
356 
357 namespace Gecode { namespace Int {
358 
360  template<>
361  class TaskViewTraits<Cumulative::ManFixPTaskFwd> {
362  public:
365  };
366 
368  template<>
369  class TaskViewTraits<Cumulative::ManFixPTaskBwd> {
370  public:
373  };
374 
376  template<>
377  class TaskViewTraits<Cumulative::ManFixPSETaskFwd> {
378  public:
381  };
382 
384  template<>
385  class TaskViewTraits<Cumulative::ManFixPSETaskBwd> {
386  public:
389  };
390 
392  template<>
393  class TaskViewTraits<Cumulative::OptFixPTaskFwd> {
394  public:
397  };
398 
400  template<>
401  class TaskViewTraits<Cumulative::OptFixPTaskBwd> {
402  public:
405  };
406 
408  template<>
409  class TaskViewTraits<Cumulative::OptFixPSETaskFwd> {
410  public:
413  };
414 
416  template<>
417  class TaskViewTraits<Cumulative::OptFixPSETaskBwd> {
418  public:
421  };
422 
424  template<>
425  class TaskViewTraits<Cumulative::ManFlexTaskFwd> {
426  public:
429  };
430 
432  template<>
433  class TaskViewTraits<Cumulative::ManFlexTaskBwd> {
434  public:
437  };
438 
440  template<>
441  class TaskViewTraits<Cumulative::OptFlexTaskFwd> {
442  public:
445  };
446 
448  template<>
449  class TaskViewTraits<Cumulative::OptFlexTaskBwd> {
450  public:
453  };
454 
455 
457  template<>
458  class TaskTraits<Cumulative::ManFixPTask> {
459  public:
466  };
467 
469  template<>
470  class TaskTraits<Cumulative::ManFixPSETask> {
471  public:
478  };
479 
481  template<>
482  class TaskTraits<Cumulative::OptFixPTask> {
483  public:
492  };
493 
495  template<>
496  class TaskTraits<Cumulative::OptFixPSETask> {
497  public:
506  };
507 
509  template<>
510  class TaskTraits<Cumulative::ManFlexTask> {
511  public:
518  };
519 
521  template<>
522  class TaskTraits<Cumulative::OptFlexTask> {
523  public:
532  };
533 
534 }}
535 
536 namespace Gecode { namespace Int { namespace Cumulative {
537 
539  class OmegaNode {
540  public:
542  double e;
544  double env;
546  void init(const OmegaNode& l, const OmegaNode& r);
548  void update(const OmegaNode& l, const OmegaNode& r);
549  };
550 
552  template<class TaskView>
553  class OmegaTree : public TaskTree<TaskView,OmegaNode> {
554  protected:
561  int c;
562  public:
564  OmegaTree(Region& r, int c, const TaskViewArray<TaskView>& t);
566  void insert(int i);
568  void remove(int i);
570  double env(void) const;
571  };
572 
574  class ExtOmegaNode : public OmegaNode {
575  public:
577  double cenv;
579  void init(const ExtOmegaNode& l, const ExtOmegaNode& r);
581  void update(const ExtOmegaNode& l, const ExtOmegaNode& r);
582  };
583 
585  template<class TaskView>
586  class ExtOmegaTree : public TaskTree<TaskView,ExtOmegaNode> {
587  protected:
604  int c, ci;
605  public:
607  template<class Node>
608  ExtOmegaTree(Region& r, int c, const TaskTree<TaskView,Node>& t);
610  void init(int ci);
612  double env(int i);
613  };
614 
615 
617  class OmegaLambdaNode : public OmegaNode {
618  public:
620  static const int undef = -1;
622  double le;
624  double lenv;
626  int resLe;
628  int resLenv;
630  void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
632  void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
633  };
634 
636  template<class TaskView>
637  class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
638  protected:
645  int c;
646  public:
650  void shift(int i);
652  void lremove(int i);
654  bool lempty(void) const;
656  int responsible(void) const;
658  double env(void) const;
660  double lenv(void) const;
661  };
662 
663 }}}
664 
666 
667 namespace Gecode { namespace Int { namespace Cumulative {
668 
670  template<class Task, class Cap>
671  ExecStatus basic(Space& home, bool& subsumed, Cap c, TaskArray<Task>& t);
672 
674  template<class ManTask>
675  ExecStatus overload(Space& home, int c, TaskArray<ManTask>& t);
676 
678  template<class Task>
679  ExecStatus edgefinding(Space& home, int c, TaskArray<Task>& t);
680 
687  template<class ManTask, class Cap>
688  class ManProp : public TaskProp<ManTask,Int::PC_INT_DOM> {
689  protected:
692  Cap c;
694  ManProp(Home home, Cap c, TaskArray<ManTask>& t);
696  ManProp(Space& home, bool shared, ManProp& p);
697  public:
699  virtual Actor* copy(Space& home, bool share);
701  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
703  static ExecStatus post(Home home, Cap c, TaskArray<ManTask>& t);
705  virtual size_t dispose(Space& home);
706  };
707 
714  template<class OptTask, class Cap>
715  class OptProp : public TaskProp<OptTask,Int::PC_INT_DOM> {
716  protected:
719  Cap c;
721  OptProp(Home home, Cap c, TaskArray<OptTask>& t);
723  OptProp(Space& home, bool shared, OptProp& p);
724  public:
726  virtual Actor* copy(Space& home, bool share);
728  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
730  static ExecStatus post(Home home, Cap c, TaskArray<OptTask>& t);
732  virtual size_t dispose(Space& home);
733  };
734 
735 }}}
736 
742 
743 #endif
744 
745 // STATISTICS: int-prop