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