Generated on Fri Oct 19 11:24:53 2018 for Gecode by doxygen 1.6.3

val-commit.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, 2012
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 namespace Gecode { namespace Int { namespace Branch {
00035 
00036   template<class View>
00037   forceinline
00038   ValCommitEq<View>::ValCommitEq(Space& home, const ValBranch<Var>& vb)
00039     : ValCommit<View,int>(home,vb) {}
00040   template<class View>
00041   forceinline
00042   ValCommitEq<View>::ValCommitEq(Space& home, ValCommitEq& vc)
00043     : ValCommit<View,int>(home,vc) {}
00044   template<class View>
00045   forceinline ModEvent
00046   ValCommitEq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
00047     return (a == 0) ? x.eq(home,n) : x.nq(home,n);
00048   }
00049   template<class View>
00050   forceinline NGL*
00051   ValCommitEq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
00052     if (a == 0)
00053       return new (home) EqNGL<View>(home,x,n);
00054     else
00055       return NULL;
00056   }
00057   template<class View>
00058   forceinline void
00059   ValCommitEq<View>::print(const Space&, unsigned int a, View, int i,
00060                            int n, std::ostream& o) const {
00061     o << "var[" << i << "] "
00062       << ((a == 0) ? "=" : "!=") << " " << n;
00063   }
00064 
00065   template<class View>
00066   forceinline
00067   ValCommitLq<View>::ValCommitLq(Space& home, const ValBranch<Var>& vb)
00068     : ValCommit<View,int>(home,vb) {}
00069   template<class View>
00070   forceinline
00071   ValCommitLq<View>::ValCommitLq(Space& home, ValCommitLq& vc)
00072     : ValCommit<View,int>(home,vc) {}
00073   template<class View>
00074   forceinline ModEvent
00075   ValCommitLq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
00076     return (a == 0) ? x.lq(home,n) : x.gr(home,n);
00077   }
00078   template<class View>
00079   forceinline NGL*
00080   ValCommitLq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
00081     if (a == 0)
00082       return new (home) LqNGL<View>(home,x,n);
00083     else
00084       return NULL;
00085   }
00086   template<class View>
00087   forceinline void
00088   ValCommitLq<View>::print(const Space&, unsigned int a, View, int i,
00089                            int n, std::ostream& o) const {
00090     o << "var[" << i << "] "
00091       << ((a == 0) ? "<=" : ">") << " " << n;
00092   }
00093 
00094   template<class View>
00095   forceinline
00096   ValCommitGq<View>::ValCommitGq(Space& home, const ValBranch<Var>& vb)
00097     : ValCommit<View,int>(home,vb) {}
00098   template<class View>
00099   forceinline
00100   ValCommitGq<View>::ValCommitGq(Space& home, ValCommitGq& vc)
00101     : ValCommit<View,int>(home,vc) {}
00102   template<class View>
00103   forceinline ModEvent
00104   ValCommitGq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
00105     return (a == 0) ? x.gq(home,n) : x.le(home,n);
00106   }
00107   template<class View>
00108   forceinline NGL*
00109   ValCommitGq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
00110     if (a == 0)
00111       return new (home) GqNGL<View>(home,x,n);
00112     else
00113       return NULL;
00114   }
00115   template<class View>
00116   forceinline void
00117   ValCommitGq<View>::print(const Space&, unsigned int a, View, int i,
00118                            int n, std::ostream& o) const {
00119     o << "var[" << i << "] "
00120       << ((a == 0) ? ">=" : "<") << " " << n;
00121   }
00122 
00123   template<class View>
00124   forceinline
00125   ValCommitGr<View>::ValCommitGr(Space& home, const ValBranch<Var>& vb)
00126     : ValCommit<View,int>(home,vb) {}
00127   template<class View>
00128   forceinline
00129   ValCommitGr<View>::ValCommitGr(Space& home, ValCommitGr& vc)
00130     : ValCommit<View,int>(home,vc) {}
00131   template<class View>
00132   forceinline ModEvent
00133   ValCommitGr<View>::commit(Space& home, unsigned int a, View x, int, int n) {
00134     return (a == 0) ? x.gr(home,n) : x.lq(home,n);
00135   }
00136   template<class View>
00137   forceinline NGL*
00138   ValCommitGr<View>::ngl(Space& home, unsigned int a, View x, int n) const {
00139     if (a == 0)
00140       return new (home) GqNGL<View>(home,x,n+1);
00141     else
00142       return NULL;
00143   }
00144   template<class View>
00145   forceinline void
00146   ValCommitGr<View>::print(const Space&, unsigned int a, View, int i,
00147                            int n, std::ostream& o) const {
00148     o << "var[" << i << "] "
00149       << ((a == 0) ? ">" : "<=") << " " << n;
00150   }
00151 
00152 }}}
00153 
00154 // STATISTICS: int-branch
00155