Generated on Thu Apr 11 13:59:12 2019 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  *  This file is part of Gecode, the generic constraint
00012  *  development environment:
00013  *     http://www.gecode.org
00014  *
00015  *  Permission is hereby granted, free of charge, to any person obtaining
00016  *  a copy of this software and associated documentation files (the
00017  *  "Software"), to deal in the Software without restriction, including
00018  *  without limitation the rights to use, copy, modify, merge, publish,
00019  *  distribute, sublicense, and/or sell copies of the Software, and to
00020  *  permit persons to whom the Software is furnished to do so, subject to
00021  *  the following conditions:
00022  *
00023  *  The above copyright notice and this permission notice shall be
00024  *  included in all copies or substantial portions of the Software.
00025  *
00026  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00027  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00028  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00029  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00030  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00031  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00032  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00033  *
00034  */
00035 
00036 #ifndef __GECODE_INT_UNARY_HH__
00037 #define __GECODE_INT_UNARY_HH__
00038 
00039 #include <gecode/int/task.hh>
00040 
00051 namespace Gecode { namespace Int { namespace Unary {
00052 
00054   class ManFixPTask {
00055   protected:
00057     Int::IntView _s;
00059     int _p;
00060   public:
00062 
00063 
00064     ManFixPTask(void);
00066     ManFixPTask(IntVar s, int p);
00068     void init(IntVar s, int p);
00070     void init(const ManFixPTask& t);
00072 
00074 
00075 
00076     int est(void) const;
00078     int ect(void) const;
00080     int lst(void) const;
00082     int lct(void) const;
00084     int pmin(void) const;
00086     int pmax(void) const;
00088     IntVar st(void) const;
00090     bool mandatory(void) const;
00092     bool excluded(void) const;
00094     bool optional(void) const;
00096 
00098 
00099 
00100     bool assigned(void) const;
00102 
00104 
00105 
00106     ModEvent est(Space& home, int n);
00108     ModEvent ect(Space& home, int n);
00110     ModEvent lst(Space& home, int n);
00112     ModEvent lct(Space& home, int n);
00114     ModEvent norun(Space& home, int e, int l);
00116     ModEvent mandatory(Space& home);
00118     ModEvent excluded(Space& home);
00120 
00122 
00123 
00124     void update(Space& home, ManFixPTask& t);
00126 
00128 
00129 
00130     void subscribe(Space& home, Propagator& p, PropCond pc);
00132     void cancel(Space& home, Propagator& p, PropCond pc);
00134     void reschedule(Space& home, Propagator& p, PropCond pc);
00136 
00137   };
00138 
00143   template<class Char, class Traits>
00144   std::basic_ostream<Char,Traits>&
00145   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPTask& t);
00146 
00148   class ManFixPSETask : public ManFixPTask {
00149   protected:
00151     TaskType _t;
00152   public:
00154 
00155 
00156     ManFixPSETask(void);
00163     ManFixPSETask(TaskType t, IntVar s, int p);
00170     void init(TaskType t, IntVar s, int p);
00172     void init(const ManFixPSETask& t);
00174 
00176 
00177 
00178     int est(void) const;
00180     int ect(void) const;
00182     int lst(void) const;
00184     int lct(void) const;
00186     int pmin(void) const;
00188     int pmax(void) const;
00190 
00192 
00193 
00194     ModEvent est(Space& home, int n);
00196     ModEvent ect(Space& home, int n);
00198     ModEvent lst(Space& home, int n);
00200     ModEvent lct(Space& home, int n);
00202     ModEvent norun(Space& home, int e, int l);
00204 
00206 
00207 
00208     void update(Space& home, ManFixPSETask& t);
00210 
00211   };
00212 
00217   template<class Char, class Traits>
00218   std::basic_ostream<Char,Traits>&
00219   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixPSETask& t);
00220 
00222   class OptFixPTask : public ManToOptTask<ManFixPTask> {
00223   protected:
00224     using ManToOptTask<ManFixPTask>::_m;
00225   public:
00227 
00228 
00229     OptFixPTask(void);
00231     OptFixPTask(IntVar s, int p, BoolVar m);
00233     void init(IntVar s, int p, BoolVar m);
00235   };
00236 
00241   template<class Char, class Traits>
00242   std::basic_ostream<Char,Traits>&
00243   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPTask& t);
00244 
00246   class OptFixPSETask : public ManToOptTask<ManFixPSETask> {
00247   protected:
00248     using ManToOptTask<ManFixPSETask>::_m;
00249   public:
00251 
00252 
00253     OptFixPSETask(void);
00255     OptFixPSETask(TaskType t, IntVar s, int p, BoolVar m);
00257     void init(TaskType t, IntVar s, int p, BoolVar m);
00259   };
00260 
00265   template<class Char, class Traits>
00266   std::basic_ostream<Char,Traits>&
00267   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixPSETask& t);
00268 
00270   class ManFlexTask {
00271   protected:
00273     Int::IntView _s;
00275     Int::IntView _p;
00277     Int::IntView _e;
00278   public:
00280 
00281 
00282     ManFlexTask(void);
00284     ManFlexTask(IntVar s, IntVar p, IntVar e);
00286     void init(IntVar s, IntVar p, IntVar e);
00288     void init(const ManFlexTask& t);
00290 
00292 
00293 
00294     int est(void) const;
00296     int ect(void) const;
00298     int lst(void) const;
00300     int lct(void) const;
00302     int pmin(void) const;
00304     int pmax(void) const;
00306     IntVar st(void) const;
00308     IntVar p(void) const;
00310     IntVar e(void) const;
00312     bool mandatory(void) const;
00314     bool excluded(void) const;
00316     bool optional(void) const;
00318 
00320 
00321 
00322     bool assigned(void) const;
00324 
00326 
00327 
00328     ModEvent est(Space& home, int n);
00330     ModEvent ect(Space& home, int n);
00332     ModEvent lst(Space& home, int n);
00334     ModEvent lct(Space& home, int n);
00336     ModEvent norun(Space& home, int e, int l);
00338     ModEvent mandatory(Space& home);
00340     ModEvent excluded(Space& home);
00342 
00344 
00345 
00346     void update(Space& home, ManFlexTask& t);
00348 
00350 
00351 
00352     void subscribe(Space& home, Propagator& p, PropCond pc);
00354     void cancel(Space& home, Propagator& p, PropCond pc);
00356     void reschedule(Space& home, Propagator& p, PropCond pc);
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(TaskArray<ManTask>& t);
00754   template<class OptTask, class PL>
00755   ExecStatus overload(Space& home, Propagator& p, TaskArray<OptTask>& t);
00756 
00758   template<class Task>
00759   ExecStatus timetabling(Space& home, Propagator& p, TaskArray<Task>& t);
00760 
00762   template<class Task>
00763   ExecStatus subsumed(Space& home, Propagator& p, TaskArray<Task>& t);
00764 
00766   template<class ManTask>
00767   ExecStatus detectable(Space& home, TaskArray<ManTask>& t);
00769   template<class OptTask, class PL>
00770   ExecStatus detectable(Space& home, Propagator& p, TaskArray<OptTask>& t);
00771 
00773   template<class ManTask>
00774   ExecStatus notfirstnotlast(Space& home, TaskArray<ManTask>& t);
00776   template<class OptTask, class PL>
00777   ExecStatus notfirstnotlast(Space& home, Propagator& p, TaskArray<OptTask>& t);
00778 
00780   template<class Task>
00781   ExecStatus edgefinding(Space& home, TaskArray<Task>& t);
00782 
00783 
00790   template<class ManTask, class PL>
00791   class ManProp : public TaskProp<ManTask,PL> {
00792   protected:
00793     using TaskProp<ManTask,PL>::t;
00795     ManProp(Home home, TaskArray<ManTask>& t);
00797     ManProp(Space& home, ManProp& p);
00798   public:
00800     virtual Actor* copy(Space& home);
00802     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00804     static ExecStatus post(Home home, TaskArray<ManTask>& t);
00805   };
00806 
00813   template<class OptTask, class PL>
00814   class OptProp : public TaskProp<OptTask,PL> {
00815   protected:
00816     using TaskProp<OptTask,PL>::t;
00818     OptProp(Home home, TaskArray<OptTask>& t);
00820     OptProp(Space& home, OptProp& p);
00821   public:
00823     virtual Actor* copy(Space& home);
00825     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00827     static ExecStatus post(Home home, TaskArray<OptTask>& t);
00828   };
00829 
00831   template<class ManTask>
00832   ExecStatus
00833   manpost(Home home, TaskArray<ManTask>& t, IntPropLevel ipl);
00834 
00836   template<class OptTask>
00837   ExecStatus
00838   optpost(Home home, TaskArray<OptTask>& t, IntPropLevel ipl);
00839 
00840 }}}
00841 
00842 #include <gecode/int/unary/overload.hpp>
00843 #include <gecode/int/unary/time-tabling.hpp>
00844 #include <gecode/int/unary/subsumption.hpp>
00845 #include <gecode/int/unary/detectable.hpp>
00846 #include <gecode/int/unary/not-first-not-last.hpp>
00847 #include <gecode/int/unary/edge-finding.hpp>
00848 
00849 #include <gecode/int/unary/man-prop.hpp>
00850 #include <gecode/int/unary/opt-prop.hpp>
00851 #include <gecode/int/unary/post.hpp>
00852 
00853 #endif
00854 
00855 // STATISTICS: int-prop