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

task.hpp

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-08-11 21:20:39 +0200 (Tue, 11 Aug 2009) $ by $Author: schulte $
00011  *     $Revision: 9589 $
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 namespace Gecode { namespace Scheduling { namespace Unary {
00039 
00040   /*
00041    * Mandatory fixed task
00042    */
00043 
00044   forceinline
00045   ManFixTask::ManFixTask(void) {}
00046   forceinline
00047   ManFixTask::ManFixTask(IntVar s, int p) : _s(s), _p(p) {}
00048   forceinline void
00049   ManFixTask::init(IntVar s, int p) {
00050     _s=s; _p=p;
00051   }
00052 
00053   forceinline int 
00054   ManFixTask::est(void) const {
00055     return _s.min();
00056   }
00057   forceinline int
00058   ManFixTask::ect(void) const {
00059     return _s.min()+_p;
00060   }
00061   forceinline int
00062   ManFixTask::lst(void) const {
00063     return _s.max();
00064   }
00065   forceinline int
00066   ManFixTask::lct(void) const {
00067     return _s.max()+_p;
00068   }
00069   forceinline IntVar
00070   ManFixTask::st(void) const {
00071     return _s;
00072   }
00073   forceinline int
00074   ManFixTask::p(void) const {
00075     return _p;
00076   }
00077 
00078   forceinline bool
00079   ManFixTask::assigned(void) const {
00080     return _s.assigned();
00081   }
00082 
00083   forceinline ModEvent 
00084   ManFixTask::est(Space& home, int n) {
00085     return _s.gq(home,n);
00086   }
00087   forceinline ModEvent
00088   ManFixTask::ect(Space& home, int n) {
00089     return _s.gq(home,n-_p);
00090   }
00091   forceinline ModEvent
00092   ManFixTask::lst(Space& home, int n) {
00093     return _s.lq(home,n);
00094   }
00095   forceinline ModEvent
00096   ManFixTask::lct(Space& home, int n) {
00097     return _s.lq(home,n-_p);
00098   }
00099 
00100   forceinline void
00101   ManFixTask::update(Space& home, bool share, ManFixTask& t) {
00102     _s.update(home,share,t._s); _p=t._p;
00103   }
00104 
00105   forceinline void
00106   ManFixTask::subscribe(Space& home, Propagator& p) {
00107     _s.subscribe(home, p, Int::PC_INT_BND);
00108   }
00109   forceinline void
00110   ManFixTask::cancel(Space& home, Propagator& p) {
00111     _s.cancel(home, p, Int::PC_INT_BND);
00112   }
00113 
00114   template<class Char, class Traits>
00115   std::basic_ostream<Char,Traits>&
00116   operator <<(std::basic_ostream<Char,Traits>& os, const ManFixTask& t) {
00117     std::basic_ostringstream<Char,Traits> s;
00118     s.copyfmt(os); s.width(0);
00119     s << t.est() << ':' << t.p() << ':' << t.lct();
00120     return os << s.str();
00121   }
00122     
00123 
00124   /*
00125    * Optional fixed task
00126    */
00127 
00128   forceinline
00129   OptFixTask::OptFixTask(void) {}
00130   forceinline
00131   OptFixTask::OptFixTask(IntVar s, int p, BoolVar m) {
00132     ManFixTask::init(s,p); _m=m;
00133   }
00134   forceinline void
00135   OptFixTask::init(IntVar s, int p, BoolVar m) {
00136     ManFixTask::init(s,p); _m=m;
00137   }
00138 
00139   template<class Char, class Traits>
00140   std::basic_ostream<Char,Traits>&
00141   operator <<(std::basic_ostream<Char,Traits>& os, const OptFixTask& t) {
00142     std::basic_ostringstream<Char,Traits> s;
00143     s.copyfmt(os); s.width(0);
00144     s << t.est() << ':' << t.p() << ':' << t.lct() << ':'
00145       << (t.mandatory() ? '1' : (t.optional() ? '?' : '0'));
00146     return os << s.str();
00147   }
00148     
00149 }}}
00150 
00151 // STATISTICS: scheduling-var