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 * Vincent Barichard <Vincent.Barichard@univ-angers.fr> 6 * 7 * Copyright: 8 * Christian Schulte, 2004 9 * Vincent Barichard, 2012 10 * 11 * This file is part of Gecode, the generic constraint 12 * development environment: 13 * http://www.gecode.org 14 * 15 * Permission is hereby granted, free of charge, to any person obtaining 16 * a copy of this software and associated documentation files (the 17 * "Software"), to deal in the Software without restriction, including 18 * without limitation the rights to use, copy, modify, merge, publish, 19 * distribute, sublicense, and/or sell copies of the Software, and to 20 * permit persons to whom the Software is furnished to do so, subject to 21 * the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be 24 * included in all copies or substantial portions of the Software. 25 * 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 * 34 */ 35 36namespace Gecode { namespace Float { namespace Rel { 37 38 /* 39 * Disequality 40 * 41 */ 42 template<class View0, class View1> 43 forceinline 44 Nq<View0,View1>::Nq(Home home, View0 x0, View1 x1) 45 : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,x0,x1) {} 46 47 template<class View0, class View1> 48 ExecStatus 49 Nq<View0,View1>::post(Home home, View0 x0, View1 x1){ 50 if (x0.assigned() && x1.assigned()) { 51 if (overlap(x0.val(),x1.val())) 52 return ES_FAILED; 53 } else if (x0 == x1) { 54 return ES_FAILED; 55 } else { 56 (void) new (home) Nq<View0,View1>(home,x0,x1); 57 } 58 return ES_OK; 59 } 60 61 template<class View0, class View1> 62 forceinline 63 Nq<View0,View1>::Nq(Space& home, Nq<View0,View1>& p) 64 : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,p) {} 65 66 template<class View0, class View1> 67 Actor* 68 Nq<View0,View1>::copy(Space& home) { 69 return new (home) Nq<View0,View1>(home,*this); 70 } 71 72 template<class View0, class View1> 73 ExecStatus 74 Nq<View0,View1>::propagate(Space& home, const ModEventDelta&) { 75 if (x0.assigned() && x1.assigned()) { 76 return overlap(x0.val(),x1.val()) ? ES_FAILED : home.ES_SUBSUMED(*this); 77 } 78 return ES_FIX; 79 } 80 81 /* 82 * Disequality with float value 83 * 84 */ 85 template<class View> 86 forceinline 87 NqFloat<View>::NqFloat(Home home, View x, FloatVal _c) 88 : UnaryPropagator<View,PC_FLOAT_VAL>(home,x), c(_c) {} 89 90 template<class View> 91 ExecStatus 92 NqFloat<View>::post(Home home, View x, FloatVal c){ 93 if (x.assigned()) { 94 if (overlap(x.val(),c)) 95 return ES_FAILED; 96 } else { 97 (void) new (home) NqFloat<View>(home,x,c); 98 } 99 return ES_OK; 100 } 101 102 template<class View> 103 forceinline 104 NqFloat<View>::NqFloat(Space& home, NqFloat<View>& p) 105 : UnaryPropagator<View,PC_FLOAT_VAL>(home,p), c(p.c) {} 106 107 template<class View> 108 Actor* 109 NqFloat<View>::copy(Space& home) { 110 return new (home) NqFloat<View>(home,*this); 111 } 112 113 template<class View> 114 ExecStatus 115 NqFloat<View>::propagate(Space& home, const ModEventDelta&) { 116 if (x0.assigned()) { 117 return (overlap(x0.val(),c)) ? ES_FAILED : home.ES_SUBSUMED(*this); 118 } 119 return ES_FIX; 120 } 121 122 123 124}}} 125 126// STATISTICS: float-prop