Generated on Mon May 10 06:46:44 2010 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  *
00006  *  Copyright:
00007  *     Christian Schulte, 2009
00008  *
00009  *  Last modified:
00010  *     $Date: 2010-04-08 12:35:31 +0200 (Thu, 08 Apr 2010) $ by $Author: schulte $
00011  *     $Revision: 10684 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #ifndef __GECODE_SCHEDULING_UNARY_HH__
00039 #define __GECODE_SCHEDULING_UNARY_HH__
00040 
00041 #include <gecode/scheduling/task.hh>
00042 
00053 namespace Gecode { namespace Scheduling { namespace Unary {
00054 
00056   class ManFixTask {
00057   protected:
00059     Int::IntView _s;
00061     int _p;
00062   public:
00064 
00065 
00066     ManFixTask(void);
00068     ManFixTask(IntVar s, int p);
00070     void init(IntVar s, int p);
00072 
00074 
00075 
00076     int est(void) const;
00078     int ect(void) const;
00080     int lst(void) const;
00082     int lct(void) const;
00084     IntVar st(void) const;
00086    int p(void) const;
00088     bool mandatory(void) const;
00090     bool excluded(void) const;
00092     bool optional(void) const;
00094 
00096 
00097 
00098     bool assigned(void) const;
00100 
00102 
00103 
00104     ModEvent est(Space& home, int n);
00106     ModEvent ect(Space& home, int n);
00108     ModEvent lst(Space& home, int n);
00110     ModEvent lct(Space& home, int n);
00112     ModEvent norun(Space& home, int e, int l);
00114     ModEvent mandatory(Space& home);
00116     ModEvent excluded(Space& home);
00118 
00120 
00121 
00122     void update(Space& home, bool share, ManFixTask& t);
00124 
00126 
00127 
00128     void subscribe(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00130     void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00132 
00133   };
00134 
00139   template<class Char, class Traits>
00140   std::basic_ostream<Char,Traits>&
00141   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTask& t);
00142 
00143 
00145   class OptFixTask : public ManToOptTask<ManFixTask> {
00146   protected:
00147     using ManToOptTask<ManFixTask>::_m;
00148   public:
00150 
00151 
00152     OptFixTask(void);
00154     OptFixTask(IntVar s, int p, BoolVar m);
00156     void init(IntVar s, int p, BoolVar m);
00158   };
00159 
00164   template<class Char, class Traits>
00165   std::basic_ostream<Char,Traits>&
00166   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTask& t);
00167 
00168 }}}
00169 
00170 #include <gecode/scheduling/unary/task.hpp>
00171 
00172 namespace Gecode { namespace Scheduling { namespace Unary {
00173 
00175   typedef ManFixTask ManFixTaskFwd;
00176 
00178   typedef FwdToBwd<ManFixTaskFwd> ManFixTaskBwd;
00179 
00181   typedef OptFixTask OptFixTaskFwd;
00182 
00184   typedef FwdToBwd<OptFixTaskFwd> OptFixTaskBwd;
00185 
00186 
00191   template<class Char, class Traits>
00192   std::basic_ostream<Char,Traits>&
00193   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTaskBwd& t);
00194 
00199   template<class Char, class Traits>
00200   std::basic_ostream<Char,Traits>&
00201   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTaskBwd& t);
00202 
00203 }}}
00204 
00205 #include <gecode/scheduling/unary/task-view.hpp>
00206 
00207 namespace Gecode { namespace Scheduling {
00208 
00210   template<>
00211   class TaskViewTraits<Unary::ManFixTaskFwd> {
00212   public:
00214     typedef Unary::ManFixTask Task;
00215   };
00216 
00218   template<>
00219   class TaskViewTraits<Unary::ManFixTaskBwd> {
00220   public:
00222     typedef Unary::ManFixTask Task;
00223   };
00224 
00226   template<>
00227   class TaskViewTraits<Unary::OptFixTaskFwd> {
00228   public:
00230     typedef Unary::OptFixTask Task;
00231   };
00232 
00234   template<>
00235   class TaskViewTraits<Unary::OptFixTaskBwd> {
00236   public:
00238     typedef Unary::OptFixTask Task;
00239   };
00240 
00241 
00243   template<>
00244   class TaskTraits<Unary::ManFixTask> {
00245   public:
00247     typedef Unary::ManFixTaskFwd TaskViewFwd;
00249     typedef Unary::ManFixTaskBwd TaskViewBwd;
00250   };
00251 
00253   template<>
00254   class TaskTraits<Unary::OptFixTask> {
00255   public:
00257     typedef Unary::OptFixTaskFwd TaskViewFwd;
00259     typedef Unary::OptFixTaskBwd TaskViewBwd;
00261     typedef Unary::ManFixTask ManTask;
00262   };
00263 
00264 }}
00265 
00266 namespace Gecode { namespace Scheduling { namespace Unary {
00267 
00269   class OmegaNode {
00270   public:
00272     int p;
00274     int ect;
00276     void init(const OmegaNode& l, const OmegaNode& r);
00278     void update(const OmegaNode& l, const OmegaNode& r);
00279   };
00280 
00282   template<class TaskView>
00283   class OmegaTree : public TaskTree<TaskView,OmegaNode> {
00284   protected:
00285     using TaskTree<TaskView,OmegaNode>::tasks;
00286     using TaskTree<TaskView,OmegaNode>::leaf;
00287     using TaskTree<TaskView,OmegaNode>::root;
00288     using TaskTree<TaskView,OmegaNode>::init;
00289     using TaskTree<TaskView,OmegaNode>::update;
00290   public:
00292     OmegaTree(Region& r, const TaskViewArray<TaskView>& t);
00294     void insert(int i);
00296     void remove(int i);
00298     int ect(void) const;
00300     int ect(int i) const;
00301   };
00302 
00304   class OmegaLambdaNode : public OmegaNode {
00305   public:
00307     static const int undef = -1;
00309     int lp;
00311     int lect;
00313     int res;
00315     void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00317     void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00318   };
00319 
00321   template<class TaskView>
00322   class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
00323   protected:
00324     using TaskTree<TaskView,OmegaLambdaNode>::tasks;
00325     using TaskTree<TaskView,OmegaLambdaNode>::leaf;
00326     using TaskTree<TaskView,OmegaLambdaNode>::root;
00327     using TaskTree<TaskView,OmegaLambdaNode>::init;
00328     using TaskTree<TaskView,OmegaLambdaNode>::update;
00329   public:
00331     OmegaLambdaTree(Region& r, const TaskViewArray<TaskView>& t, 
00332                     bool inc=true);
00334     void shift(int i);
00336     void oinsert(int i);
00338     void linsert(int i);
00340     void lremove(int i);
00342     bool lempty(void) const;
00344     int responsible(void) const;
00346     int ect(void) const;
00348     int lect(void) const;
00349   };
00350 
00351 }}}
00352 
00353 #include <gecode/scheduling/unary/tree.hpp>
00354 
00355 namespace Gecode { namespace Scheduling { namespace Unary {
00356 
00358   template<class ManTask>
00359   ExecStatus overload(Space& home, TaskArray<ManTask>& t);
00361   template<class OptTask>
00362   ExecStatus overload(Space& home, Propagator& p, TaskArray<OptTask>& t);
00363 
00365   template<class Task>
00366   ExecStatus subsumed(Space& home, Propagator& p, TaskArray<Task>& t);
00367 
00369   template<class ManTask>
00370   ExecStatus detectable(Space& home, TaskArray<ManTask>& t);
00372   template<class OptTask>
00373   ExecStatus detectable(Space& home, Propagator& p, TaskArray<OptTask>& t);
00374 
00376   template<class ManTask>
00377   ExecStatus notfirstnotlast(Space& home, TaskArray<ManTask>& t);
00379   template<class OptTask>
00380   ExecStatus notfirstnotlast(Space& home, Propagator& p, TaskArray<OptTask>& t);
00381 
00383   template<class Task>
00384   ExecStatus edgefinding(Space& home, TaskArray<Task>& t);
00385 
00386 
00393   template<class ManTask>
00394   class ManProp : public TaskProp<ManTask> {
00395   protected:
00396     using TaskProp<ManTask>::t;
00398     ManProp(Home home, TaskArray<ManTask>& t);
00400     ManProp(Space& home, bool shared, ManProp& p);
00401   public:
00403     virtual Actor* copy(Space& home, bool share);
00405     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00407     static ExecStatus post(Home home, TaskArray<ManTask>& t);
00408   };
00409 
00416   template<class OptTask>
00417   class OptProp : public TaskProp<OptTask> {
00418   protected:
00419     using TaskProp<OptTask>::t;
00421     OptProp(Home home, TaskArray<OptTask>& t);
00423     OptProp(Space& home, bool shared, OptProp& p);
00424   public:
00426     virtual Actor* copy(Space& home, bool share);
00428     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00430     static ExecStatus post(Home home, TaskArray<OptTask>& t);
00431   };
00432 
00433 }}}
00434 
00435 #include <gecode/scheduling/unary/overload.hpp>
00436 #include <gecode/scheduling/unary/subsumption.hpp>
00437 #include <gecode/scheduling/unary/detectable.hpp>
00438 #include <gecode/scheduling/unary/not-first-not-last.hpp>
00439 #include <gecode/scheduling/unary/edge-finding.hpp>
00440 
00441 #include <gecode/scheduling/unary/man-prop.hpp>
00442 #include <gecode/scheduling/unary/opt-prop.hpp>
00443 
00444 #endif
00445 
00446 // STATISTICS: scheduling-prop