Generated on Tue Apr 18 10:21:37 2017 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  *  Last modified:
00010  *     $Date: 2017-02-16 12:11:51 +0100 (Thu, 16 Feb 2017) $ by $Author: schulte $
00011  *     $Revision: 15434 $
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 Int { namespace Branch {
00039 
00040   template<class View>
00041   forceinline
00042   ValCommitEq<View>::ValCommitEq(Space& home, const ValBranch<Var>& vb)
00043     : ValCommit<View,int>(home,vb) {}
00044   template<class View>
00045   forceinline
00046   ValCommitEq<View>::ValCommitEq(Space& home, bool shared, ValCommitEq& vc)
00047     : ValCommit<View,int>(home,shared,vc) {}
00048   template<class View>
00049   forceinline ModEvent
00050   ValCommitEq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
00051     return (a == 0) ? x.eq(home,n) : x.nq(home,n);
00052   }
00053   template<class View>
00054   forceinline NGL*
00055   ValCommitEq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
00056     if (a == 0)
00057       return new (home) EqNGL<View>(home,x,n);
00058     else
00059       return NULL;
00060   }
00061   template<class View>
00062   forceinline void
00063   ValCommitEq<View>::print(const Space&, unsigned int a, View, int i,
00064                            int n, std::ostream& o) const {
00065     o << "var[" << i << "] "
00066       << ((a == 0) ? "=" : "!=") << " " << n;
00067   }
00068 
00069   template<class View>
00070   forceinline
00071   ValCommitLq<View>::ValCommitLq(Space& home, const ValBranch<Var>& vb)
00072     : ValCommit<View,int>(home,vb) {}
00073   template<class View>
00074   forceinline
00075   ValCommitLq<View>::ValCommitLq(Space& home, bool shared, ValCommitLq& vc)
00076     : ValCommit<View,int>(home,shared,vc) {}
00077   template<class View>
00078   forceinline ModEvent
00079   ValCommitLq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
00080     return (a == 0) ? x.lq(home,n) : x.gr(home,n);
00081   }
00082   template<class View>
00083   forceinline NGL*
00084   ValCommitLq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
00085     if (a == 0)
00086       return new (home) LqNGL<View>(home,x,n);
00087     else
00088       return NULL;
00089   }
00090   template<class View>
00091   forceinline void
00092   ValCommitLq<View>::print(const Space&, unsigned int a, View, int i,
00093                            int n, std::ostream& o) const {
00094     o << "var[" << i << "] "
00095       << ((a == 0) ? "<=" : ">") << " " << n;
00096   }
00097 
00098   template<class View>
00099   forceinline
00100   ValCommitGq<View>::ValCommitGq(Space& home, const ValBranch<Var>& vb)
00101     : ValCommit<View,int>(home,vb) {}
00102   template<class View>
00103   forceinline
00104   ValCommitGq<View>::ValCommitGq(Space& home, bool shared, ValCommitGq& vc)
00105     : ValCommit<View,int>(home,shared,vc) {}
00106   template<class View>
00107   forceinline ModEvent
00108   ValCommitGq<View>::commit(Space& home, unsigned int a, View x, int, int n) {
00109     return (a == 0) ? x.gq(home,n) : x.le(home,n);
00110   }
00111   template<class View>
00112   forceinline NGL*
00113   ValCommitGq<View>::ngl(Space& home, unsigned int a, View x, int n) const {
00114     if (a == 0)
00115       return new (home) GqNGL<View>(home,x,n);
00116     else
00117       return NULL;
00118   }
00119   template<class View>
00120   forceinline void
00121   ValCommitGq<View>::print(const Space&, unsigned int a, View, int i,
00122                            int n, std::ostream& o) const {
00123     o << "var[" << i << "] "
00124       << ((a == 0) ? ">=" : "<") << " " << n;
00125   }
00126 
00127   template<class View>
00128   forceinline
00129   ValCommitGr<View>::ValCommitGr(Space& home, const ValBranch<Var>& vb)
00130     : ValCommit<View,int>(home,vb) {}
00131   template<class View>
00132   forceinline
00133   ValCommitGr<View>::ValCommitGr(Space& home, bool shared, ValCommitGr& vc)
00134     : ValCommit<View,int>(home,shared,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