Generated on Fri Aug 24 2012 04:52:11 for Gecode by doxygen 1.8.1.2
unary.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-14 04:01:39 +1000 (Thu, 14 Jul 2011) $ by $Author: schulte $
13  * $Revision: 12197 $
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_UNARY_HH__
41 #define __GECODE_INT_UNARY_HH__
42 
43 #include <gecode/int/task.hh>
44 
55 namespace Gecode { namespace Int { namespace Unary {
56 
58  class ManFixPTask {
59  protected:
63  int _p;
64  public:
66 
67 
68  ManFixPTask(void);
70  ManFixPTask(IntVar s, int p);
72  void init(IntVar s, int p);
74  void init(const ManFixPTask& t);
76 
78 
79 
80  int est(void) const;
82  int ect(void) const;
84  int lst(void) const;
86  int lct(void) const;
88  int pmin(void) const;
90  int pmax(void) const;
92  IntVar st(void) const;
94  bool mandatory(void) const;
96  bool excluded(void) const;
98  bool optional(void) const;
100 
102 
103 
104  bool assigned(void) const;
106 
108 
109 
110  ModEvent est(Space& home, int n);
112  ModEvent ect(Space& home, int n);
114  ModEvent lst(Space& home, int n);
116  ModEvent lct(Space& home, int n);
118  ModEvent norun(Space& home, int e, int l);
120  ModEvent mandatory(Space& home);
122  ModEvent excluded(Space& home);
124 
126 
127 
128  void update(Space& home, bool share, ManFixPTask& t);
130 
132 
133 
134  void subscribe(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
136  void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
138 
139  };
140 
145  template<class Char, class Traits>
146  std::basic_ostream<Char,Traits>&
147  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t);
148 
150  class ManFixPSETask : public ManFixPTask {
151  protected:
154  public:
156 
157 
158  ManFixPSETask(void);
165  ManFixPSETask(TaskType t, IntVar s, int p);
172  void init(TaskType t, IntVar s, int p);
174  void init(const ManFixPSETask& t);
176 
178 
179 
180  int est(void) const;
182  int ect(void) const;
184  int lst(void) const;
186  int lct(void) const;
188  int pmin(void) const;
190  int pmax(void) const;
192 
194 
195 
196  ModEvent est(Space& home, int n);
198  ModEvent ect(Space& home, int n);
200  ModEvent lst(Space& home, int n);
202  ModEvent lct(Space& home, int n);
204  ModEvent norun(Space& home, int e, int l);
206 
208 
209 
210  void update(Space& home, bool share, ManFixPSETask& t);
212 
213  };
214 
219  template<class Char, class Traits>
220  std::basic_ostream<Char,Traits>&
221  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETask& t);
222 
224  class OptFixPTask : public ManToOptTask<ManFixPTask> {
225  protected:
227  public:
229 
230 
231  OptFixPTask(void);
233  OptFixPTask(IntVar s, int p, BoolVar m);
235  void init(IntVar s, int p, BoolVar m);
237  };
238 
243  template<class Char, class Traits>
244  std::basic_ostream<Char,Traits>&
245  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t);
246 
248  class OptFixPSETask : public ManToOptTask<ManFixPSETask> {
249  protected:
251  public:
253 
254 
255  OptFixPSETask(void);
257  OptFixPSETask(TaskType t, IntVar s, int p, BoolVar m);
259  void init(TaskType t, IntVar s, int p, BoolVar m);
261  };
262 
267  template<class Char, class Traits>
268  std::basic_ostream<Char,Traits>&
269  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t);
270 
272  class ManFlexTask {
273  protected:
280  public:
282 
283 
284  ManFlexTask(void);
288  void init(IntVar s, IntVar p, IntVar e);
290  void init(const ManFlexTask& t);
292 
294 
295 
296  int est(void) const;
298  int ect(void) const;
300  int lst(void) const;
302  int lct(void) const;
304  int pmin(void) const;
306  int pmax(void) const;
308  IntVar st(void) const;
310  IntVar p(void) const;
312  IntVar e(void) const;
314  bool mandatory(void) const;
316  bool excluded(void) const;
318  bool optional(void) const;
320 
322 
323 
324  bool assigned(void) const;
326 
328 
329 
330  ModEvent est(Space& home, int n);
332  ModEvent ect(Space& home, int n);
334  ModEvent lst(Space& home, int n);
336  ModEvent lct(Space& home, int n);
338  ModEvent norun(Space& home, int e, int l);
340  ModEvent mandatory(Space& home);
342  ModEvent excluded(Space& home);
344 
346 
347 
348  void update(Space& home, bool share, ManFlexTask& t);
350 
352 
353 
356  void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
358 
359  };
360 
365  template<class Char, class Traits>
366  std::basic_ostream<Char,Traits>&
367  operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t);
368 
370  class OptFlexTask : public ManToOptTask<ManFlexTask> {
371  protected:
373  public:
375 
376 
377  OptFlexTask(void);
381  void init(IntVar s, IntVar p, IntVar e, BoolVar m);
383  };
384 
389  template<class Char, class Traits>
390  std::basic_ostream<Char,Traits>&
391  operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t);
392 
393 }}}
394 
395 #include <gecode/int/unary/task.hpp>
396 
397 namespace Gecode { namespace Int { namespace Unary {
398 
401 
404 
407 
410 
413 
416 
419 
422 
425 
428 
431 
434 
435 
440  template<class Char, class Traits>
441  std::basic_ostream<Char,Traits>&
442  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTaskBwd& t);
443 
448  template<class Char, class Traits>
449  std::basic_ostream<Char,Traits>&
450  operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETaskBwd& t);
451 
456  template<class Char, class Traits>
457  std::basic_ostream<Char,Traits>&
458  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTaskBwd& t);
459 
464  template<class Char, class Traits>
465  std::basic_ostream<Char,Traits>&
466  operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETaskBwd& t);
467 
472  template<class Char, class Traits>
473  std::basic_ostream<Char,Traits>&
474  operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTaskBwd& t);
475 
482  template<class Char, class Traits>
483  std::basic_ostream<Char,Traits>&
484  operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTaskBwd& t);
485 
486 }}}
487 
489 
490 namespace Gecode { namespace Int {
491 
493  template<>
495  public:
498  };
499 
501  template<>
503  public:
506  };
507 
509  template<>
511  public:
514  };
515 
517  template<>
519  public:
522  };
523 
525  template<>
527  public:
530  };
531 
533  template<>
535  public:
538  };
539 
541  template<>
543  public:
546  };
547 
549  template<>
551  public:
554  };
555 
557  template<>
559  public:
562  };
563 
565  template<>
567  public:
570  };
571 
573  template<>
575  public:
578  };
579 
581  template<>
583  public:
586  };
587 
588 
590  template<>
591  class TaskTraits<Unary::ManFixPTask> {
592  public:
597  };
598 
600  template<>
601  class TaskTraits<Unary::ManFixPSETask> {
602  public:
607  };
608 
610  template<>
611  class TaskTraits<Unary::OptFixPTask> {
612  public:
619  };
620 
622  template<>
623  class TaskTraits<Unary::OptFixPSETask> {
624  public:
631  };
632 
634  template<>
635  class TaskTraits<Unary::ManFlexTask> {
636  public:
641  };
642 
644  template<>
645  class TaskTraits<Unary::OptFlexTask> {
646  public:
653  };
654 
655 }}
656 
657 namespace Gecode { namespace Int { namespace Unary {
658 
660  class OmegaNode {
661  public:
663  int p;
665  int ect;
667  void init(const OmegaNode& l, const OmegaNode& r);
669  void update(const OmegaNode& l, const OmegaNode& r);
670  };
671 
673  template<class TaskView>
674  class OmegaTree : public TaskTree<TaskView,OmegaNode> {
675  protected:
681  public:
685  void insert(int i);
687  void remove(int i);
689  int ect(void) const;
691  int ect(int i) const;
692  };
693 
695  class OmegaLambdaNode : public OmegaNode {
696  public:
698  static const int undef = -1;
700  int lp;
702  int lect;
704  int resEct;
706  int resLp;
708  void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
710  void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
711  };
712 
714  template<class TaskView>
715  class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
716  protected:
722  public:
725  bool inc=true);
727  void shift(int i);
729  void oinsert(int i);
731  void linsert(int i);
733  void lremove(int i);
735  bool lempty(void) const;
737  int responsible(void) const;
739  int ect(void) const;
741  int lect(void) const;
742  };
743 
744 }}}
745 
746 #include <gecode/int/unary/tree.hpp>
747 
748 namespace Gecode { namespace Int { namespace Unary {
749 
751  template<class ManTask>
752  ExecStatus overload(Space& home, TaskArray<ManTask>& t);
754  template<class OptTask>
755  ExecStatus overload(Space& home, Propagator& p, TaskArray<OptTask>& t);
756 
758  template<class Task>
759  ExecStatus subsumed(Space& home, Propagator& p, TaskArray<Task>& t);
760 
762  template<class ManTask>
763  ExecStatus detectable(Space& home, TaskArray<ManTask>& t);
765  template<class OptTask>
766  ExecStatus detectable(Space& home, Propagator& p, TaskArray<OptTask>& t);
767 
769  template<class ManTask>
770  ExecStatus notfirstnotlast(Space& home, TaskArray<ManTask>& t);
772  template<class OptTask>
773  ExecStatus notfirstnotlast(Space& home, Propagator& p, TaskArray<OptTask>& t);
774 
776  template<class Task>
777  ExecStatus edgefinding(Space& home, TaskArray<Task>& t);
778 
779 
786  template<class ManTask>
787  class ManProp : public TaskProp<ManTask,Int::PC_INT_BND> {
788  protected:
793  ManProp(Space& home, bool shared, ManProp& p);
794  public:
796  virtual Actor* copy(Space& home, bool share);
798  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
800  static ExecStatus post(Home home, TaskArray<ManTask>& t);
801  };
802 
809  template<class OptTask>
810  class OptProp : public TaskProp<OptTask,Int::PC_INT_BND> {
811  protected:
816  OptProp(Space& home, bool shared, OptProp& p);
817  public:
819  virtual Actor* copy(Space& home, bool share);
821  virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
823  static ExecStatus post(Home home, TaskArray<OptTask>& t);
824  };
825 
826 }}}
827 
833 
836 
837 #endif
838 
839 // STATISTICS: int-prop