Generated on Thu Mar 22 10:39:41 2012 for Gecode by doxygen 1.6.3

unary.hh

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *     Guido Tack <tack@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2009
00009  *     Guido Tack, 2010
00010  *
00011  *  Last modified:
00012  *     $Date: 2011-07-13 20:01:39 +0200 (Wed, 13 Jul 2011) $ by $Author: schulte $
00013  *     $Revision: 12197 $
00014  *
00015  *  This file is part of Gecode, the generic constraint
00016  *  development environment:
00017  *     http://www.gecode.org
00018  *
00019  *  Permission is hereby granted, free of charge, to any person obtaining
00020  *  a copy of this software and associated documentation files (the
00021  *  "Software"), to deal in the Software without restriction, including
00022  *  without limitation the rights to use, copy, modify, merge, publish,
00023  *  distribute, sublicense, and/or sell copies of the Software, and to
00024  *  permit persons to whom the Software is furnished to do so, subject to
00025  *  the following conditions:
00026  *
00027  *  The above copyright notice and this permission notice shall be
00028  *  included in all copies or substantial portions of the Software.
00029  *
00030  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00031  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00032  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00033  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00034  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00035  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00036  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00037  *
00038  */
00039 
00040 #ifndef __GECODE_INT_UNARY_HH__
00041 #define __GECODE_INT_UNARY_HH__
00042 
00043 #include <gecode/int/task.hh>
00044 
00055 namespace Gecode { namespace Int { namespace Unary {
00056 
00058   class ManFixPTask {
00059   protected:
00061     Int::IntView _s;
00063     int _p;
00064   public:
00066 
00067 
00068     ManFixPTask(void);
00070     ManFixPTask(IntVar s, int p);
00072     void init(IntVar s, int p);
00074     void init(const ManFixPTask& t);
00076 
00078 
00079 
00080     int est(void) const;
00082     int ect(void) const;
00084     int lst(void) const;
00086     int lct(void) const;
00088     int pmin(void) const;
00090     int pmax(void) const;
00092     IntVar st(void) const;
00094     bool mandatory(void) const;
00096     bool excluded(void) const;
00098     bool optional(void) const;
00100 
00102 
00103 
00104     bool assigned(void) const;
00106 
00108 
00109 
00110     ModEvent est(Space& home, int n);
00112     ModEvent ect(Space& home, int n);
00114     ModEvent lst(Space& home, int n);
00116     ModEvent lct(Space& home, int n);
00118     ModEvent norun(Space& home, int e, int l);
00120     ModEvent mandatory(Space& home);
00122     ModEvent excluded(Space& home);
00124 
00126 
00127 
00128     void update(Space& home, bool share, ManFixPTask& t);
00130 
00132 
00133 
00134     void subscribe(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00136     void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00138 
00139   };
00140 
00145   template<class Char, class Traits>
00146   std::basic_ostream<Char,Traits>&
00147   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t);
00148 
00150   class ManFixPSETask : public ManFixPTask {
00151   protected:
00153     TaskType _t;
00154   public:
00156 
00157 
00158     ManFixPSETask(void);
00165     ManFixPSETask(TaskType t, IntVar s, int p);
00172     void init(TaskType t, IntVar s, int p);
00174     void init(const ManFixPSETask& t);
00176 
00178 
00179 
00180     int est(void) const;
00182     int ect(void) const;
00184     int lst(void) const;
00186     int lct(void) const;
00188     int pmin(void) const;
00190     int pmax(void) const;
00192 
00194 
00195 
00196     ModEvent est(Space& home, int n);
00198     ModEvent ect(Space& home, int n);
00200     ModEvent lst(Space& home, int n);
00202     ModEvent lct(Space& home, int n);
00204     ModEvent norun(Space& home, int e, int l);
00206 
00208 
00209 
00210     void update(Space& home, bool share, ManFixPSETask& t);
00212 
00213   };
00214 
00219   template<class Char, class Traits>
00220   std::basic_ostream<Char,Traits>&
00221   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETask& t);
00222 
00224   class OptFixPTask : public ManToOptTask<ManFixPTask> {
00225   protected:
00226     using ManToOptTask<ManFixPTask>::_m;
00227   public:
00229 
00230 
00231     OptFixPTask(void);
00233     OptFixPTask(IntVar s, int p, BoolVar m);
00235     void init(IntVar s, int p, BoolVar m);
00237   };
00238 
00243   template<class Char, class Traits>
00244   std::basic_ostream<Char,Traits>&
00245   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t);
00246 
00248   class OptFixPSETask : public ManToOptTask<ManFixPSETask> {
00249   protected:
00250     using ManToOptTask<ManFixPSETask>::_m;
00251   public:
00253 
00254 
00255     OptFixPSETask(void);
00257     OptFixPSETask(TaskType t, IntVar s, int p, BoolVar m);
00259     void init(TaskType t, IntVar s, int p, BoolVar m);
00261   };
00262 
00267   template<class Char, class Traits>
00268   std::basic_ostream<Char,Traits>&
00269   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t);
00270 
00272   class ManFlexTask {
00273   protected:
00275     Int::IntView _s;
00277     Int::IntView _p;
00279     Int::IntView _e;
00280   public:
00282 
00283 
00284     ManFlexTask(void);
00286     ManFlexTask(IntVar s, IntVar p, IntVar e);
00288     void init(IntVar s, IntVar p, IntVar e);
00290     void init(const ManFlexTask& t);
00292 
00294 
00295 
00296     int est(void) const;
00298     int ect(void) const;
00300     int lst(void) const;
00302     int lct(void) const;
00304     int pmin(void) const;
00306     int pmax(void) const;
00308     IntVar st(void) const;
00310     IntVar p(void) const;
00312     IntVar e(void) const;
00314     bool mandatory(void) const;
00316     bool excluded(void) const;
00318     bool optional(void) const;
00320 
00322 
00323 
00324     bool assigned(void) const;
00326 
00328 
00329 
00330     ModEvent est(Space& home, int n);
00332     ModEvent ect(Space& home, int n);
00334     ModEvent lst(Space& home, int n);
00336     ModEvent lct(Space& home, int n);
00338     ModEvent norun(Space& home, int e, int l);
00340     ModEvent mandatory(Space& home);
00342     ModEvent excluded(Space& home);
00344 
00346 
00347 
00348     void update(Space& home, bool share, ManFlexTask& t);
00350 
00352 
00353 
00354     void subscribe(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00356     void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00358 
00359   };
00360 
00365   template<class Char, class Traits>
00366   std::basic_ostream<Char,Traits>&
00367   operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTask& t);
00368 
00370   class OptFlexTask : public ManToOptTask<ManFlexTask> {
00371   protected:
00372     using ManToOptTask<ManFlexTask>::_m;
00373   public:
00375 
00376 
00377     OptFlexTask(void);
00379     OptFlexTask(IntVar s, IntVar p, IntVar e, BoolVar m);
00381     void init(IntVar s, IntVar p, IntVar e, BoolVar m);
00383   };
00384 
00389   template<class Char, class Traits>
00390   std::basic_ostream<Char,Traits>&
00391   operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTask& t);
00392 
00393 }}}
00394 
00395 #include <gecode/int/unary/task.hpp>
00396 
00397 namespace Gecode { namespace Int { namespace Unary {
00398 
00400   typedef ManFixPTask ManFixPTaskFwd;
00401 
00403   typedef FwdToBwd<ManFixPTaskFwd> ManFixPTaskBwd;
00404 
00406   typedef ManFixPSETask ManFixPSETaskFwd;
00407 
00409   typedef FwdToBwd<ManFixPSETaskFwd> ManFixPSETaskBwd;
00410 
00412   typedef OptFixPTask OptFixPTaskFwd;
00413 
00415   typedef FwdToBwd<OptFixPTaskFwd> OptFixPTaskBwd;
00416 
00418   typedef OptFixPSETask OptFixPSETaskFwd;
00419 
00421   typedef FwdToBwd<OptFixPSETaskFwd> OptFixPSETaskBwd;
00422 
00424   typedef ManFlexTask ManFlexTaskFwd;
00425 
00427   typedef FwdToBwd<ManFlexTaskFwd> ManFlexTaskBwd;
00428 
00430   typedef OptFlexTask OptFlexTaskFwd;
00431 
00433   typedef FwdToBwd<OptFlexTaskFwd> OptFlexTaskBwd;
00434 
00435 
00440   template<class Char, class Traits>
00441   std::basic_ostream<Char,Traits>&
00442   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTaskBwd& t);
00443 
00448   template<class Char, class Traits>
00449   std::basic_ostream<Char,Traits>&
00450   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETaskBwd& t);
00451 
00456   template<class Char, class Traits>
00457   std::basic_ostream<Char,Traits>&
00458   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTaskBwd& t);
00459 
00464   template<class Char, class Traits>
00465   std::basic_ostream<Char,Traits>&
00466   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETaskBwd& t);
00467 
00472   template<class Char, class Traits>
00473   std::basic_ostream<Char,Traits>&
00474   operator <<(std::basic_ostream<Char,Traits>& os, const ManFlexTaskBwd& t);
00475 
00482   template<class Char, class Traits>
00483   std::basic_ostream<Char,Traits>&
00484   operator <<(std::basic_ostream<Char,Traits>& os, const OptFlexTaskBwd& t);
00485 
00486 }}}
00487 
00488 #include <gecode/int/unary/task-view.hpp>
00489 
00490 namespace Gecode { namespace Int {
00491 
00493   template<>
00494   class TaskViewTraits<Unary::ManFixPTaskFwd> {
00495   public:
00497     typedef Unary::ManFixPTask Task;
00498   };
00499 
00501   template<>
00502   class TaskViewTraits<Unary::ManFixPTaskBwd> {
00503   public:
00505     typedef Unary::ManFixPTask Task;
00506   };
00507 
00509   template<>
00510   class TaskViewTraits<Unary::ManFixPSETaskFwd> {
00511   public:
00513     typedef Unary::ManFixPSETask Task;
00514   };
00515 
00517   template<>
00518   class TaskViewTraits<Unary::ManFixPSETaskBwd> {
00519   public:
00521     typedef Unary::ManFixPSETask Task;
00522   };
00523 
00525   template<>
00526   class TaskViewTraits<Unary::OptFixPTaskFwd> {
00527   public:
00529     typedef Unary::OptFixPTask Task;
00530   };
00531 
00533   template<>
00534   class TaskViewTraits<Unary::OptFixPTaskBwd> {
00535   public:
00537     typedef Unary::OptFixPTask Task;
00538   };
00539 
00541   template<>
00542   class TaskViewTraits<Unary::OptFixPSETaskFwd> {
00543   public:
00545     typedef Unary::OptFixPSETask Task;
00546   };
00547 
00549   template<>
00550   class TaskViewTraits<Unary::OptFixPSETaskBwd> {
00551   public:
00553     typedef Unary::OptFixPSETask Task;
00554   };
00555 
00557   template<>
00558   class TaskViewTraits<Unary::ManFlexTaskFwd> {
00559   public:
00561     typedef Unary::ManFlexTask Task;
00562   };
00563 
00565   template<>
00566   class TaskViewTraits<Unary::ManFlexTaskBwd> {
00567   public:
00569     typedef Unary::ManFlexTask Task;
00570   };
00571 
00573   template<>
00574   class TaskViewTraits<Unary::OptFlexTaskFwd> {
00575   public:
00577     typedef Unary::OptFlexTask Task;
00578   };
00579 
00581   template<>
00582   class TaskViewTraits<Unary::OptFlexTaskBwd> {
00583   public:
00585     typedef Unary::OptFlexTask Task;
00586   };
00587 
00588 
00590   template<>
00591   class TaskTraits<Unary::ManFixPTask> {
00592   public:
00594     typedef Unary::ManFixPTaskFwd TaskViewFwd;
00596     typedef Unary::ManFixPTaskBwd TaskViewBwd;
00597   };
00598 
00600   template<>
00601   class TaskTraits<Unary::ManFixPSETask> {
00602   public:
00604     typedef Unary::ManFixPSETaskFwd TaskViewFwd;
00606     typedef Unary::ManFixPSETaskBwd TaskViewBwd;
00607   };
00608 
00610   template<>
00611   class TaskTraits<Unary::OptFixPTask> {
00612   public:
00614     typedef Unary::OptFixPTaskFwd TaskViewFwd;
00616     typedef Unary::OptFixPTaskBwd TaskViewBwd;
00618     typedef Unary::ManFixPTask ManTask;
00619   };
00620 
00622   template<>
00623   class TaskTraits<Unary::OptFixPSETask> {
00624   public:
00626     typedef Unary::OptFixPSETaskFwd TaskViewFwd;
00628     typedef Unary::OptFixPSETaskBwd TaskViewBwd;
00630     typedef Unary::ManFixPTask ManTask;
00631   };
00632 
00634   template<>
00635   class TaskTraits<Unary::ManFlexTask> {
00636   public:
00638     typedef Unary::ManFlexTaskFwd TaskViewFwd;
00640     typedef Unary::ManFlexTaskBwd TaskViewBwd;
00641   };
00642 
00644   template<>
00645   class TaskTraits<Unary::OptFlexTask> {
00646   public:
00648     typedef Unary::OptFlexTaskFwd TaskViewFwd;
00650     typedef Unary::OptFlexTaskBwd TaskViewBwd;
00652     typedef Unary::ManFlexTask ManTask;
00653   };
00654 
00655 }}
00656 
00657 namespace Gecode { namespace Int { namespace Unary {
00658 
00660   class OmegaNode {
00661   public:
00663     int p;
00665     int ect;
00667     void init(const OmegaNode& l, const OmegaNode& r);
00669     void update(const OmegaNode& l, const OmegaNode& r);
00670   };
00671 
00673   template<class TaskView>
00674   class OmegaTree : public TaskTree<TaskView,OmegaNode> {
00675   protected:
00676     using TaskTree<TaskView,OmegaNode>::tasks;
00677     using TaskTree<TaskView,OmegaNode>::leaf;
00678     using TaskTree<TaskView,OmegaNode>::root;
00679     using TaskTree<TaskView,OmegaNode>::init;
00680     using TaskTree<TaskView,OmegaNode>::update;
00681   public:
00683     OmegaTree(Region& r, const TaskViewArray<TaskView>& t);
00685     void insert(int i);
00687     void remove(int i);
00689     int ect(void) const;
00691     int ect(int i) const;
00692   };
00693 
00695   class OmegaLambdaNode : public OmegaNode {
00696   public:
00698     static const int undef = -1;
00700     int lp;
00702     int lect;
00704     int resEct;
00706     int resLp;
00708     void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00710     void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00711   };
00712 
00714   template<class TaskView>
00715   class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
00716   protected:
00717     using TaskTree<TaskView,OmegaLambdaNode>::tasks;
00718     using TaskTree<TaskView,OmegaLambdaNode>::leaf;
00719     using TaskTree<TaskView,OmegaLambdaNode>::root;
00720     using TaskTree<TaskView,OmegaLambdaNode>::init;
00721     using TaskTree<TaskView,OmegaLambdaNode>::update;
00722   public:
00724     OmegaLambdaTree(Region& r, const TaskViewArray<TaskView>& t, 
00725                     bool inc=true);
00727     void shift(int i);
00729     void oinsert(int i);
00731     void linsert(int i);
00733     void lremove(int i);
00735     bool lempty(void) const;
00737     int responsible(void) const;
00739     int ect(void) const;
00741     int lect(void) const;
00742   };
00743 
00744 }}}
00745 
00746 #include <gecode/int/unary/tree.hpp>
00747 
00748 namespace Gecode { namespace Int { namespace Unary {
00749 
00751   template<class ManTask>
00752   ExecStatus overload(Space& home, TaskArray<ManTask>& t);
00754   template<class OptTask>
00755   ExecStatus overload(Space& home, Propagator& p, TaskArray<OptTask>& t);
00756 
00758   template<class Task>
00759   ExecStatus subsumed(Space& home, Propagator& p, TaskArray<Task>& t);
00760 
00762   template<class ManTask>
00763   ExecStatus detectable(Space& home, TaskArray<ManTask>& t);
00765   template<class OptTask>
00766   ExecStatus detectable(Space& home, Propagator& p, TaskArray<OptTask>& t);
00767 
00769   template<class ManTask>
00770   ExecStatus notfirstnotlast(Space& home, TaskArray<ManTask>& t);
00772   template<class OptTask>
00773   ExecStatus notfirstnotlast(Space& home, Propagator& p, TaskArray<OptTask>& t);
00774 
00776   template<class Task>
00777   ExecStatus edgefinding(Space& home, TaskArray<Task>& t);
00778 
00779 
00786   template<class ManTask>
00787   class ManProp : public TaskProp<ManTask,Int::PC_INT_BND> {
00788   protected:
00789     using TaskProp<ManTask,Int::PC_INT_BND>::t;
00791     ManProp(Home home, TaskArray<ManTask>& t);
00793     ManProp(Space& home, bool shared, ManProp& p);
00794   public:
00796     virtual Actor* copy(Space& home, bool share);
00798     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00800     static ExecStatus post(Home home, TaskArray<ManTask>& t);
00801   };
00802 
00809   template<class OptTask>
00810   class OptProp : public TaskProp<OptTask,Int::PC_INT_BND> {
00811   protected:
00812     using TaskProp<OptTask,Int::PC_INT_BND>::t;
00814     OptProp(Home home, TaskArray<OptTask>& t);
00816     OptProp(Space& home, bool shared, OptProp& p);
00817   public:
00819     virtual Actor* copy(Space& home, bool share);
00821     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00823     static ExecStatus post(Home home, TaskArray<OptTask>& t);
00824   };
00825 
00826 }}}
00827 
00828 #include <gecode/int/unary/overload.hpp>
00829 #include <gecode/int/unary/subsumption.hpp>
00830 #include <gecode/int/unary/detectable.hpp>
00831 #include <gecode/int/unary/not-first-not-last.hpp>
00832 #include <gecode/int/unary/edge-finding.hpp>
00833 
00834 #include <gecode/int/unary/man-prop.hpp>
00835 #include <gecode/int/unary/opt-prop.hpp>
00836 
00837 #endif
00838 
00839 // STATISTICS: int-prop