/Users/jamian/Desktop/gecode-2.0.1/contribs/qecode/warner.cc

Go to the documentation of this file.
00001 /*****************************************************************[warner.cc]
00002 Copyright (c) 2007, Universite d'Orleans - Jeremie Vautard, Marco Benedetti,
00003 Arnaud Lallouet.
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy
00006 of this software and associated documentation files (the "Software"), to deal
00007 in the Software without restriction, including without limitation the rights
00008 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00009 copies of the Software, and to permit persons to whom the Software is
00010 furnished to do so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in
00013 all copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00021 THE SOFTWARE.
00022 *****************************************************************************/
00023 #include "warner.hh"
00024 
00025 void Warner::warn(int w) {
00026   if (bh != NULL) 
00027     bh->vartouched(w,sp);
00028 }
00029 
00030 
00031 void Warner::setBH(BranchingHeuristic* b) {
00032   bh=b;
00033 }
00034 
00035 
00036 IntWarningProp::IntWarningProp(Space* home, int v, IntView vv, Warner* f, bool fd) : UnaryPropagator<IntView,PC_INT_DOM>(home,vv) {
00037   var=v;
00038   toWarn=f;
00039 }
00040 
00041 IntWarningProp::IntWarningProp(Space* home, bool share, IntWarningProp& p) : UnaryPropagator<IntView,PC_INT_DOM>(home,share,p) {
00042   var=p.var;
00043   toWarn=p.toWarn;
00044 }
00045 
00046 IntWarningProp::~IntWarningProp(void) {}
00047 
00048 PropCost IntWarningProp::cost(void) const {return PC_CRAZY_HI;}
00049 
00050 ExecStatus IntWarningProp::propagate(Space * home) {
00051   toWarn->warn(var);
00052   return ES_NOFIX;
00053 }
00054 
00055 Actor* IntWarningProp::copy(Space* home,bool share) {return new (home) IntWarningProp(home,share,*this);}
00056 
00057 ExecStatus IntWarningProp::warning(Space* home, int v, IntView vv, Warner* f) {
00058   (void) new (home) IntWarningProp(home,v,vv,f);
00059   return ES_OK;
00060 }
00061 
00062 void IntWarningProp::IntWarning(Space* home, int v, IntVar iv, Warner* f) {
00063   IntView vv(iv);  
00064   GECODE_ES_FAIL(home,warning(home,v,vv,f));
00065 }
00066 
00068 
00069 BoolWarningProp::BoolWarningProp(Space* home, int v, BoolView vv, Warner* f, bool fd) : UnaryPropagator<BoolView,PC_INT_DOM>(home,vv) {
00070     var=v;
00071     toWarn=f;
00072 }
00073 
00074 BoolWarningProp::BoolWarningProp(Space* home, bool share, BoolWarningProp& p) : UnaryPropagator<BoolView,PC_INT_DOM>(home,share,p) {
00075     var=p.var;
00076     toWarn=p.toWarn;
00077 }
00078 
00079 BoolWarningProp::~BoolWarningProp(void) {}
00080 
00081 PropCost BoolWarningProp::cost(void) const {return PC_CRAZY_HI;}
00082 
00083 ExecStatus BoolWarningProp::propagate(Space * home) {
00084     toWarn->warn(var);
00085     return ES_NOFIX;
00086 }
00087 
00088 Actor* BoolWarningProp::copy(Space* home,bool share) {return new (home) BoolWarningProp(home,share,*this);}
00089 
00090 ExecStatus BoolWarningProp::warning(Space* home, int v, BoolView vv, Warner* f) {
00091     (void) new (home) BoolWarningProp(home,v,vv,f);
00092     return ES_OK;
00093 }
00094 
00095 void BoolWarningProp::BoolWarning(Space* home, int v, BoolVar iv, Warner* f) {
00096     BoolView vv(iv);  
00097     GECODE_ES_FAIL(home,warning(home,v,vv,f));
00098 }
00099 
00100 
00101 

Generated on Thu Feb 7 14:33:45 2008 for qecode by  doxygen 1.5.2