this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Christian Schulte <schulte@gecode.org> 5 * 6 * Copyright: 7 * Christian Schulte, 2012 8 * 9 * This file is part of Gecode, the generic constraint 10 * development environment: 11 * http://www.gecode.org 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining 14 * a copy of this software and associated documentation files (the 15 * "Software"), to deal in the Software without restriction, including 16 * without limitation the rights to use, copy, modify, merge, publish, 17 * distribute, sublicense, and/or sell copies of the Software, and to 18 * permit persons to whom the Software is furnished to do so, subject to 19 * the following conditions: 20 * 21 * The above copyright notice and this permission notice shall be 22 * included in all copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 * 32 */ 33 34namespace Gecode { namespace Int { namespace Branch { 35 36 template<class View> 37 forceinline 38 ValCommitEq<View>::ValCommitEq 39 (Space& home, const ValBranch<typename ValCommitEq<View>::Var>& vb) 40 : ValCommit<View,int>(home,vb) {} 41 template<class View> 42 forceinline 43 ValCommitEq<View>::ValCommitEq(Space& home, ValCommitEq& vc) 44 : ValCommit<View,int>(home,vc) {} 45 template<class View> 46 forceinline ModEvent 47 ValCommitEq<View>::commit(Space& home, unsigned int a, View x, int, int n) { 48 return (a == 0) ? x.eq(home,n) : x.nq(home,n); 49 } 50 template<class View> 51 forceinline NGL* 52 ValCommitEq<View>::ngl(Space& home, unsigned int a, View x, int n) const { 53 if (a == 0) 54 return new (home) EqNGL<View>(home,x,n); 55 else 56 return nullptr; 57 } 58 template<class View> 59 forceinline void 60 ValCommitEq<View>::print(const Space&, unsigned int a, View, int i, 61 int n, std::ostream& o) const { 62 o << "var[" << i << "] " 63 << ((a == 0) ? "=" : "!=") << " " << n; 64 } 65 66 template<class View> 67 forceinline 68 ValCommitLq<View>::ValCommitLq 69 (Space& home, const ValBranch<typename ValCommitLq<View>::Var>& vb) 70 : ValCommit<View,int>(home,vb) {} 71 template<class View> 72 forceinline 73 ValCommitLq<View>::ValCommitLq(Space& home, ValCommitLq& vc) 74 : ValCommit<View,int>(home,vc) {} 75 template<class View> 76 forceinline ModEvent 77 ValCommitLq<View>::commit(Space& home, unsigned int a, View x, int, int n) { 78 return (a == 0) ? x.lq(home,n) : x.gr(home,n); 79 } 80 template<class View> 81 forceinline NGL* 82 ValCommitLq<View>::ngl(Space& home, unsigned int a, View x, int n) const { 83 if (a == 0) 84 return new (home) LqNGL<View>(home,x,n); 85 else 86 return nullptr; 87 } 88 template<class View> 89 forceinline void 90 ValCommitLq<View>::print(const Space&, unsigned int a, View, int i, 91 int n, std::ostream& o) const { 92 o << "var[" << i << "] " 93 << ((a == 0) ? "<=" : ">") << " " << n; 94 } 95 96 template<class View> 97 forceinline 98 ValCommitGq<View>::ValCommitGq 99 (Space& home, const ValBranch<typename ValCommitGq<View>::Var>& vb) 100 : ValCommit<View,int>(home,vb) {} 101 template<class View> 102 forceinline 103 ValCommitGq<View>::ValCommitGq(Space& home, ValCommitGq& vc) 104 : ValCommit<View,int>(home,vc) {} 105 template<class View> 106 forceinline ModEvent 107 ValCommitGq<View>::commit(Space& home, unsigned int a, View x, int, int n) { 108 return (a == 0) ? x.gq(home,n) : x.le(home,n); 109 } 110 template<class View> 111 forceinline NGL* 112 ValCommitGq<View>::ngl(Space& home, unsigned int a, View x, int n) const { 113 if (a == 0) 114 return new (home) GqNGL<View>(home,x,n); 115 else 116 return nullptr; 117 } 118 template<class View> 119 forceinline void 120 ValCommitGq<View>::print(const Space&, unsigned int a, View, int i, 121 int n, std::ostream& o) const { 122 o << "var[" << i << "] " 123 << ((a == 0) ? ">=" : "<") << " " << n; 124 } 125 126 template<class View> 127 forceinline 128 ValCommitGr<View>::ValCommitGr 129 (Space& home, const ValBranch<typename ValCommitGr<View>::Var>& vb) 130 : ValCommit<View,int>(home,vb) {} 131 template<class View> 132 forceinline 133 ValCommitGr<View>::ValCommitGr(Space& home, ValCommitGr& vc) 134 : ValCommit<View,int>(home,vc) {} 135 template<class View> 136 forceinline ModEvent 137 ValCommitGr<View>::commit(Space& home, unsigned int a, View x, int, int n) { 138 return (a == 0) ? x.gr(home,n) : x.lq(home,n); 139 } 140 template<class View> 141 forceinline NGL* 142 ValCommitGr<View>::ngl(Space& home, unsigned int a, View x, int n) const { 143 if (a == 0) 144 return new (home) GqNGL<View>(home,x,n+1); 145 else 146 return nullptr; 147 } 148 template<class View> 149 forceinline void 150 ValCommitGr<View>::print(const Space&, unsigned int a, View, int i, 151 int n, std::ostream& o) const { 152 o << "var[" << i << "] " 153 << ((a == 0) ? ">" : "<=") << " " << n; 154 } 155 156}}} 157 158// STATISTICS: int-branch 159