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, 2013 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 EqNGL<View>::EqNGL(Space& home, View x, int n) 39 : ViewValNGL<View,int,PC_INT_VAL>(home,x,n) {} 40 template<class View> 41 forceinline 42 EqNGL<View>::EqNGL(Space& home, EqNGL& ngl) 43 : ViewValNGL<View,int,PC_INT_VAL>(home,ngl) {} 44 template<class View> 45 NGL* 46 EqNGL<View>::copy(Space& home) { 47 return new (home) EqNGL<View>(home,*this); 48 } 49 template<class View> 50 NGL::Status 51 EqNGL<View>::status(const Space&) const { 52 if (x.assigned()) 53 return (x.val() == n) ? NGL::SUBSUMED : NGL::FAILED; 54 else 55 return x.in(n) ? NGL::NONE : NGL::FAILED; 56 } 57 template<class View> 58 ExecStatus 59 EqNGL<View>::prune(Space& home) { 60 return me_failed(x.nq(home,n)) ? ES_FAILED : ES_OK; 61 } 62 63 64 template<class View> 65 forceinline 66 NqNGL<View>::NqNGL(Space& home, View x, int n) 67 : ViewValNGL<View,int,PC_INT_DOM>(home,x,n) {} 68 template<class View> 69 forceinline 70 NqNGL<View>::NqNGL(Space& home, NqNGL& ngl) 71 : ViewValNGL<View,int,PC_INT_DOM>(home,ngl) {} 72 template<class View> 73 NGL* 74 NqNGL<View>::copy(Space& home) { 75 return new (home) NqNGL<View>(home,*this); 76 } 77 template<class View> 78 NGL::Status 79 NqNGL<View>::status(const Space&) const { 80 if (x.assigned()) 81 return (x.val() == n) ? NGL::FAILED : NGL::SUBSUMED; 82 else 83 return x.in(n) ? NGL::NONE : NGL::SUBSUMED; 84 } 85 template<class View> 86 ExecStatus 87 NqNGL<View>::prune(Space& home) { 88 return me_failed(x.eq(home,n)) ? ES_FAILED : ES_OK; 89 } 90 91 92 template<class View> 93 forceinline 94 LqNGL<View>::LqNGL(Space& home, View x, int n) 95 : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {} 96 template<class View> 97 forceinline 98 LqNGL<View>::LqNGL(Space& home, LqNGL& ngl) 99 : ViewValNGL<View,int,PC_INT_BND>(home,ngl) {} 100 template<class View> 101 NGL* 102 LqNGL<View>::copy(Space& home) { 103 return new (home) LqNGL<View>(home,*this); 104 } 105 template<class View> 106 NGL::Status 107 LqNGL<View>::status(const Space&) const { 108 if (x.max() <= n) 109 return NGL::SUBSUMED; 110 else if (x.min() > n) 111 return NGL::FAILED; 112 else 113 return NGL::NONE; 114 } 115 template<class View> 116 ExecStatus 117 LqNGL<View>::prune(Space& home) { 118 return me_failed(x.gr(home,n)) ? ES_FAILED : ES_OK; 119 } 120 121 122 template<class View> 123 forceinline 124 GqNGL<View>::GqNGL(Space& home, View x, int n) 125 : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {} 126 template<class View> 127 forceinline 128 GqNGL<View>::GqNGL(Space& home, GqNGL& ngl) 129 : ViewValNGL<View,int,PC_INT_BND>(home,ngl) {} 130 template<class View> 131 NGL* 132 GqNGL<View>::copy(Space& home) { 133 return new (home) GqNGL<View>(home,*this); 134 } 135 template<class View> 136 NGL::Status 137 GqNGL<View>::status(const Space&) const { 138 if (x.min() >= n) 139 return NGL::SUBSUMED; 140 else if (x.max() < n) 141 return NGL::FAILED; 142 else 143 return NGL::NONE; 144 } 145 template<class View> 146 ExecStatus 147 GqNGL<View>::prune(Space& home) { 148 return me_failed(x.le(home,n)) ? ES_FAILED : ES_OK; 149 } 150 151}}} 152 153// STATISTICS: int-branch