Generated on Thu Apr 11 13:59:12 2019 for Gecode by doxygen 1.6.3

task.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  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  *
00032  */
00033 
00034 #ifndef __GECODE_INT_TASK_HH__
00035 #define __GECODE_INT_TASK_HH__
00036 
00037 #include <gecode/int.hh>
00038 
00039 namespace Gecode { namespace Int {
00040 
00042   template<class ManTask>
00043   class ManToOptTask : public ManTask {
00044   protected:
00046     Int::BoolView _m;
00047   public:
00049 
00050 
00051     ManToOptTask(void);
00053 
00055 
00056 
00057     bool mandatory(void) const;
00059     bool excluded(void) const;
00061     bool optional(void) const;
00063 
00065 
00066     bool assigned(void) const;
00068 
00070 
00071 
00072     ModEvent mandatory(Space& home);
00074     ModEvent excluded(Space& home);
00076 
00078 
00079 
00080     void update(Space& home, ManToOptTask& t);
00082 
00084 
00085 
00086     void subscribe(Space& home, Propagator& p, PropCond pc);
00088     void cancel(Space& home, Propagator& p, PropCond pc);
00090     void reschedule(Space& home, Propagator& p, PropCond pc);
00092   };
00093 
00094 }}
00095 
00096 #include <gecode/int/task/man-to-opt.hpp>
00097 
00098 namespace Gecode { namespace Int {
00099 
00101   template<class TaskView>
00102   class FwdToBwd : public TaskView {
00103   public:
00105 
00106 
00107     int est(void) const;
00109     int ect(void) const;
00111     int lst(void) const;
00113     int lct(void) const;
00115     int pmin(void) const;
00117     int pmax(void) const;
00119 
00121 
00122 
00123     ModEvent est(Space& home, int n);
00125     ModEvent ect(Space& home, int n);
00127     ModEvent lst(Space& home, int n);
00129     ModEvent lct(Space& home, int n);
00131     ModEvent norun(Space& home, int e, int l);
00133   };
00134 
00135 }}
00136 
00137 #include <gecode/int/task/fwd-to-bwd.hpp>
00138 
00139 namespace Gecode { namespace Int {
00140 
00147   template<class TaskView>
00148   class TaskViewTraits {};
00149 
00156   template<class Task>
00157   class TaskTraits {};
00158 
00159 }}
00160 
00161 namespace Gecode { namespace Int {
00162 
00164   template<class Task>
00165   class TaskArray {
00166   private:
00168     int n;
00170     Task* t;
00171   public:
00173 
00174 
00175     TaskArray(void);
00177     TaskArray(Space& home, int n);
00179     TaskArray(const TaskArray<Task>& a);
00181     const TaskArray<Task>& operator =(const TaskArray<Task>& a);
00183 
00185 
00186 
00187     int size(void) const;
00189     void size(int n);
00191 
00193 
00194 
00195     Task& operator [](int i);
00197     const Task& operator [](int i) const;
00199 
00201 
00202 
00203     void subscribe(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00205     void cancel(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00207     void reschedule(Space& home, Propagator& p, PropCond pc=Int::PC_INT_BND);
00209 
00211 
00212 
00213     void update(Space&, TaskArray& a);
00215 
00216   private:
00217     static void* operator new(size_t);
00218     static void  operator delete(void*,size_t);
00219   };
00220 
00225   template<class Char, class Traits, class Task>
00226   std::basic_ostream<Char,Traits>&
00227   operator <<(std::basic_ostream<Char,Traits>& os,
00228               const TaskArray<Task>& t);
00229 
00230 
00232   template<class TaskView>
00233   class TaskViewArray {
00234   protected:
00236     typedef typename TaskViewTraits<TaskView>::Task Task;
00238     TaskArray<Task>& t;
00239   public:
00241 
00242 
00243     TaskViewArray(TaskArray<Task>& t);
00245 
00247 
00248 
00249     int size(void) const;
00251     void size(int n);
00253 
00255 
00256 
00257     TaskView& operator [](int i);
00259     const TaskView& operator [](int i) const;
00261   private:
00262     static void* operator new(size_t);
00263     static void  operator delete(void*,size_t);
00264   };
00265 
00270   template<class Char, class Traits, class TaskView>
00271   std::basic_ostream<Char,Traits>&
00272   operator <<(std::basic_ostream<Char,Traits>& os,
00273               const TaskViewArray<TaskView>& t);
00274 
00275 }}
00276 
00277 #include <gecode/int/task/array.hpp>
00278 
00279 namespace Gecode { namespace Int {
00280 
00282   enum SortTaskOrder {
00283     STO_EST, 
00284     STO_ECT, 
00285     STO_LST, 
00286     STO_LCT  
00287   };
00288 
00290   template<class TaskView, SortTaskOrder sto, bool inc>
00291   void sort(TaskViewArray<TaskView>& t);
00292 
00294   template<class TaskView, SortTaskOrder sto, bool inc>
00295   void sort(int* map, const TaskViewArray<TaskView>& t);
00296 
00298   template<class TaskView, SortTaskOrder sto, bool inc>
00299   void sort(int* map, int n, const TaskViewArray<TaskView>& t);
00300 
00301 }}
00302 
00303 #include <gecode/int/task/sort.hpp>
00304 
00305 namespace Gecode { namespace Int {
00306 
00308   template<class TaskView, SortTaskOrder sto, bool inc>
00309   class TaskViewIter {
00310   protected:
00312     int* map;
00314     int i;
00316     TaskViewIter(void);
00317   public:
00319     TaskViewIter(Region& r, const TaskViewArray<TaskView>& t);
00321 
00322 
00323     bool operator ()(void) const;
00325     int left(void) const;
00327     void operator ++(void);
00329 
00331 
00332 
00333     int task(void) const;
00335   };
00336 
00338   template<class OptTaskView, SortTaskOrder sto, bool inc>
00339   class ManTaskViewIter : public TaskViewIter<OptTaskView,sto,inc> {
00340   protected:
00341     using TaskViewIter<OptTaskView,sto,inc>::map;
00342     using TaskViewIter<OptTaskView,sto,inc>::i;
00343   public:
00345     ManTaskViewIter(Region& r, const TaskViewArray<OptTaskView>& t);
00346   };
00347 
00348 }}
00349 
00350 #include <gecode/int/task/iter.hpp>
00351 
00352 namespace Gecode { namespace Int {
00353 
00355   int plus(int x, int y);
00356 
00358   long long int plus(long long int x, long long int y);
00359 
00361   double plus(double x, double y);
00362 
00364   template<class TaskView, class Node>
00365   class TaskTree {
00366     template<class,class> friend class TaskTree;
00367   protected:
00369     const TaskViewArray<TaskView>& tasks;
00371     Node* node;
00373     int* _leaf;
00374 
00376     int n_inner(void) const;
00378     int n_nodes(void) const;
00380     static bool n_root(int i);
00382     bool n_leaf(int i) const;
00384     static int n_left(int i);
00386     static bool left(int i);
00388     static int n_right(int i);
00390     static bool right(int i);
00392     static int n_parent(int i);
00393   protected:
00395     Node& leaf(int i);
00397     const Node& root(void) const;
00399     void update(int i, bool l=true);
00401     void init(void);
00403     void update(void);
00405     TaskTree(Region& r, const TaskViewArray<TaskView>& t);
00407     template<class Node2> TaskTree(Region& r,
00408                                    const TaskTree<TaskView,Node2>& t);
00409   };
00410 
00411 }}
00412 
00413 #include <gecode/int/task/tree.hpp>
00414 
00415 namespace Gecode { namespace Int {
00416 
00423   template<class Task, class PL>
00424   class TaskProp : public Propagator {
00425   protected:
00427     TaskArray<Task> t;
00429     TaskProp(Home home, TaskArray<Task>& t);
00431     TaskProp(Space& home, TaskProp<Task,PL>& p);
00432   public:
00434     virtual PropCost cost(const Space& home, const ModEventDelta& med) const;
00436     virtual void reschedule(Space& home);
00438     virtual size_t dispose(Space& home);
00439   };
00440 
00442   template<class OptTask, class PL>
00443   ExecStatus purge(Space& home, Propagator& p, TaskArray<OptTask>& t);
00444 
00446   template<class OptTask, class PL, class Cap>
00447   ExecStatus purge(Space& home, Propagator& p, TaskArray<OptTask>& t, Cap c);
00448 
00450   class PLB {
00451   public:
00453     static const bool basic = true;
00455     static const bool advanced = false;
00457     static const PropCond pc = PC_INT_DOM;
00458   };
00459 
00461   class PLA {
00462   public:
00464     static const bool basic = false;
00466     static const bool advanced = true;
00468     static const PropCond pc = PC_INT_BND;
00469   };
00470 
00472   class PLBA {
00473   public:
00475     static const bool basic = true;
00477     static const bool advanced = true;
00479     static const PropCond pc = PC_INT_DOM;
00480   };
00481 
00482 }}
00483 
00484 #include <gecode/int/task/prop.hpp>
00485 #include <gecode/int/task/purge.hpp>
00486 
00487 namespace Gecode { namespace Int {
00488 
00490   class Event {
00491   public:
00493     enum Type {
00494       LRT = 0, 
00495       LCT = 1, 
00496       EST = 2, 
00497       ZRO = 3, 
00498       ERT = 4, 
00499       END = 5  
00500     };
00501   protected:
00503     unsigned int ei;
00505     int t;
00506   public:
00508     void init(Type e, int t, int i);
00510     Type type(void) const;
00512     int time(void) const;
00514     int idx(void) const;
00516     bool operator <(const Event& e) const;
00518     template<class Task>
00519     static Event* events(Region& r, const TaskArray<Task>& t, bool& assigned);
00521     template<class Task>
00522     static Event* events(Region& r, const TaskArray<Task>& t);
00523   };
00524 
00526   template<class Char, class Traits>
00527   std::basic_ostream<Char,Traits>&
00528   operator <<(std::basic_ostream<Char,Traits>& os, const Event& e);
00529 
00530 }}
00531 
00532 #include <gecode/int/task/event.hpp>
00533 
00534 #endif
00535 
00536 // STATISTICS: int-prop