Generated on Mon Nov 30 23:53:34 2009 for Gecode by doxygen 1.6.1

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: 2009-10-12 17:36:53 +0200 (Mon, 12 Oct 2009) $ by $Author: schulte $
00011  *     $Revision: 9878 $
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 
00090 
00091 
00092     bool assigned(void) const;
00094 
00096 
00097 
00098     ModEvent est(Space& home, int n);
00100     ModEvent ect(Space& home, int n);
00102     ModEvent lst(Space& home, int n);
00104     ModEvent lct(Space& home, int n);
00106 
00108 
00109 
00110     void update(Space& home, bool share, ManFixTask& t);
00112 
00114 
00115 
00116     void subscribe(Space& home, Propagator& p);
00118     void cancel(Space& home, Propagator& p);
00120 
00121   };
00122 
00127   template<class Char, class Traits>
00128   std::basic_ostream<Char,Traits>&
00129   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTask& t);
00130 
00131 
00133   class OptFixTask : public ManToOptTask<ManFixTask> {
00134   protected:
00135     using ManToOptTask<ManFixTask>::_m;
00136   public:
00138 
00139 
00140     OptFixTask(void);
00142     OptFixTask(IntVar s, int p, BoolVar m);
00144     void init(IntVar s, int p, BoolVar m);
00146   };
00147 
00152   template<class Char, class Traits>
00153   std::basic_ostream<Char,Traits>&
00154   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTask& t);
00155 
00156 }}}
00157 
00158 #include <gecode/scheduling/unary/task.hpp>
00159 
00160 namespace Gecode { namespace Scheduling { namespace Unary {
00161 
00163   typedef ManFixTask ManFixTaskFwd;
00164 
00166   typedef FwdToBwd<ManFixTaskFwd> ManFixTaskBwd;
00167 
00169   typedef OptFixTask OptFixTaskFwd;
00170 
00172   typedef FwdToBwd<OptFixTaskFwd> OptFixTaskBwd;
00173 
00174 
00179   template<class Char, class Traits>
00180   std::basic_ostream<Char,Traits>&
00181   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTaskBwd& t);
00182 
00187   template<class Char, class Traits>
00188   std::basic_ostream<Char,Traits>&
00189   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTaskBwd& t);
00190 
00191 }}}
00192 
00193 #include <gecode/scheduling/unary/task-view.hpp>
00194 
00195 namespace Gecode { namespace Scheduling {
00196 
00198   template<>
00199   class TaskViewTraits<Unary::ManFixTaskFwd> {
00200   public:
00202     typedef Unary::ManFixTask Task;
00203   };
00204 
00206   template<>
00207   class TaskViewTraits<Unary::ManFixTaskBwd> {
00208   public:
00210     typedef Unary::ManFixTask Task;
00211   };
00212 
00214   template<>
00215   class TaskViewTraits<Unary::OptFixTaskFwd> {
00216   public:
00218     typedef Unary::OptFixTask Task;
00219   };
00220 
00222   template<>
00223   class TaskViewTraits<Unary::OptFixTaskBwd> {
00224   public:
00226     typedef Unary::OptFixTask Task;
00227   };
00228 
00229 
00231   template<>
00232   class TaskTraits<Unary::ManFixTask> {
00233   public:
00235     typedef Unary::ManFixTaskFwd TaskViewFwd;
00237     typedef Unary::ManFixTaskBwd TaskViewBwd;
00238   };
00239 
00241   template<>
00242   class TaskTraits<Unary::OptFixTask> {
00243   public:
00245     typedef Unary::OptFixTaskFwd TaskViewFwd;
00247     typedef Unary::OptFixTaskBwd TaskViewBwd;
00249     typedef Unary::ManFixTask ManTask;
00250   };
00251 
00252 }}
00253 
00254 namespace Gecode { namespace Scheduling { namespace Unary {
00255 
00257   class OmegaNode {
00258   public:
00260     int p;
00262     int ect;
00264     void init(const OmegaNode& l, const OmegaNode& r);
00266     void update(const OmegaNode& l, const OmegaNode& r);
00267   };
00268 
00270   template<class TaskView>
00271   class OmegaTree : public TaskTree<TaskView,OmegaNode> {
00272   protected:
00273     using TaskTree<TaskView,OmegaNode>::tasks;
00274     using TaskTree<TaskView,OmegaNode>::leaf;
00275     using TaskTree<TaskView,OmegaNode>::root;
00276     using TaskTree<TaskView,OmegaNode>::init;
00277     using TaskTree<TaskView,OmegaNode>::update;
00278   public:
00280     OmegaTree(Region& r, const TaskViewArray<TaskView>& t);
00282     void insert(int i);
00284     void remove(int i);
00286     int ect(void) const;
00288     int ect(int i) const;
00289   };
00290 
00292   class OmegaLambdaNode : public OmegaNode {
00293   public:
00295     static const int undef = -1;
00297     int lp;
00299     int lect;
00301     int res;
00303     void init(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00305     void update(const OmegaLambdaNode& l, const OmegaLambdaNode& r);
00306   };
00307 
00309   template<class TaskView>
00310   class OmegaLambdaTree : public TaskTree<TaskView,OmegaLambdaNode> {
00311   protected:
00312     using TaskTree<TaskView,OmegaLambdaNode>::tasks;
00313     using TaskTree<TaskView,OmegaLambdaNode>::leaf;
00314     using TaskTree<TaskView,OmegaLambdaNode>::root;
00315     using TaskTree<TaskView,OmegaLambdaNode>::init;
00316     using TaskTree<TaskView,OmegaLambdaNode>::update;
00317   public:
00319     OmegaLambdaTree(Region& r, const TaskViewArray<TaskView>& t, 
00320                     bool inc=true);
00322     void shift(int i);
00324     void oinsert(int i);
00326     void linsert(int i);
00328     void lremove(int i);
00330     bool lempty(void) const;
00332     int responsible(void) const;
00334     int ect(void) const;
00336     int lect(void) const;
00337   };
00338 
00339 }}}
00340 
00341 #include <gecode/scheduling/unary/tree.hpp>
00342 
00343 namespace Gecode { namespace Scheduling { namespace Unary {
00344 
00346   template<class ManTask>
00347   ExecStatus overload(Space& home, TaskArray<ManTask>& t);
00349   template<class OptTask>
00350   ExecStatus overload(Space& home, Propagator& p, TaskArray<OptTask>& t);
00351 
00353   template<class Task>
00354   ExecStatus subsumed(Space& home, Propagator& p, TaskArray<Task>& t);
00355 
00357   template<class ManTask>
00358   ExecStatus detectable(Space& home, TaskArray<ManTask>& t);
00360   template<class OptTask>
00361   ExecStatus detectable(Space& home, Propagator& p, TaskArray<OptTask>& t);
00362 
00364   template<class ManTask>
00365   ExecStatus notfirstnotlast(Space& home, TaskArray<ManTask>& t);
00367   template<class OptTask>
00368   ExecStatus notfirstnotlast(Space& home, Propagator& p, TaskArray<OptTask>& t);
00369 
00371   template<class Task>
00372   ExecStatus edgefinding(Space& home, TaskArray<Task>& t);
00373 
00374 
00381   template<class ManTask>
00382   class ManProp : public TaskProp<ManTask> {
00383   protected:
00384     using TaskProp<ManTask>::t;
00386     ManProp(Home home, TaskArray<ManTask>& t);
00388     ManProp(Space& home, bool shared, ManProp& p);
00389   public:
00391     virtual Actor* copy(Space& home, bool share);
00393     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00395     static ExecStatus post(Home home, TaskArray<ManTask>& t);
00396   };
00397 
00404   template<class OptTask>
00405   class OptProp : public TaskProp<OptTask> {
00406   protected:
00407     using TaskProp<OptTask>::t;
00409     OptProp(Home home, TaskArray<OptTask>& t);
00411     OptProp(Space& home, bool shared, OptProp& p);
00412   public:
00414     virtual Actor* copy(Space& home, bool share);
00416     virtual ExecStatus propagate(Space& home, const ModEventDelta& med);
00418     static ExecStatus post(Home home, TaskArray<OptTask>& t);
00419   };
00420 
00421 }}}
00422 
00423 #include <gecode/scheduling/unary/overload.hpp>
00424 #include <gecode/scheduling/unary/subsumption.hpp>
00425 #include <gecode/scheduling/unary/detectable.hpp>
00426 #include <gecode/scheduling/unary/not-first-not-last.hpp>
00427 #include <gecode/scheduling/unary/edge-finding.hpp>
00428 
00429 #include <gecode/scheduling/unary/man-prop.hpp>
00430 #include <gecode/scheduling/unary/opt-prop.hpp>
00431 
00432 #endif
00433 
00434 // STATISTICS: scheduling-prop