Generated on Fri Oct 19 11:24:57 2018 for Gecode by doxygen 1.6.3

nq.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  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2004
00009  *     Vincent Barichard, 2012
00010  *
00011  *  This file is part of Gecode, the generic constraint
00012  *  development environment:
00013  *     http://www.gecode.org
00014  *
00015  *  Permission is hereby granted, free of charge, to any person obtaining
00016  *  a copy of this software and associated documentation files (the
00017  *  "Software"), to deal in the Software without restriction, including
00018  *  without limitation the rights to use, copy, modify, merge, publish,
00019  *  distribute, sublicense, and/or sell copies of the Software, and to
00020  *  permit persons to whom the Software is furnished to do so, subject to
00021  *  the following conditions:
00022  *
00023  *  The above copyright notice and this permission notice shall be
00024  *  included in all copies or substantial portions of the Software.
00025  *
00026  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00027  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00028  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00029  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00030  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00031  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00032  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00033  *
00034  */
00035 
00036 namespace Gecode { namespace Float { namespace Rel {
00037 
00038   /*
00039    * Disequality
00040    *
00041    */
00042   template<class View0, class View1>
00043   forceinline
00044   Nq<View0,View1>::Nq(Home home, View0 x0, View1 x1)
00045     : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,x0,x1) {}
00046 
00047   template<class View0, class View1>
00048   ExecStatus
00049   Nq<View0,View1>::post(Home home, View0 x0, View1 x1){
00050     if (x0.assigned() && x1.assigned()) {
00051       if (overlap(x0.val(),x1.val()))
00052         return ES_FAILED;
00053     } else if (x0 == x1) {
00054       return ES_FAILED;
00055     } else {
00056       (void) new (home) Nq<View0,View1>(home,x0,x1);
00057     }
00058     return ES_OK;
00059   }
00060 
00061   template<class View0, class View1>
00062   forceinline
00063   Nq<View0,View1>::Nq(Space& home, Nq<View0,View1>& p)
00064     : MixBinaryPropagator<View0,PC_FLOAT_VAL,View1,PC_FLOAT_VAL>(home,p) {}
00065 
00066   template<class View0, class View1>
00067   Actor*
00068   Nq<View0,View1>::copy(Space& home) {
00069     return new (home) Nq<View0,View1>(home,*this);
00070   }
00071 
00072   template<class View0, class View1>
00073   ExecStatus
00074   Nq<View0,View1>::propagate(Space& home, const ModEventDelta&) {
00075     if (x0.assigned() && x1.assigned()) {
00076       return overlap(x0.val(),x1.val()) ? ES_FAILED : home.ES_SUBSUMED(*this);
00077     }
00078     return ES_FIX;
00079   }
00080 
00081   /*
00082    * Disequality with float value
00083    *
00084    */
00085   template<class View>
00086   forceinline
00087   NqFloat<View>::NqFloat(Home home, View x, FloatVal _c)
00088     : UnaryPropagator<View,PC_FLOAT_VAL>(home,x), c(_c) {}
00089 
00090   template<class View>
00091   ExecStatus
00092   NqFloat<View>::post(Home home, View x, FloatVal c){
00093     if (x.assigned()) {
00094       if (overlap(x.val(),c))
00095         return ES_FAILED;
00096     } else {
00097       (void) new (home) NqFloat<View>(home,x,c);
00098     }
00099     return ES_OK;
00100   }
00101 
00102   template<class View>
00103   forceinline
00104   NqFloat<View>::NqFloat(Space& home, NqFloat<View>& p)
00105     : UnaryPropagator<View,PC_FLOAT_VAL>(home,p), c(p.c) {}
00106 
00107   template<class View>
00108   Actor*
00109   NqFloat<View>::copy(Space& home) {
00110     return new (home) NqFloat<View>(home,*this);
00111   }
00112 
00113   template<class View>
00114   ExecStatus
00115   NqFloat<View>::propagate(Space& home, const ModEventDelta&) {
00116     if (x0.assigned()) {
00117       return (overlap(x0.val(),c)) ? ES_FAILED : home.ES_SUBSUMED(*this);
00118     }
00119     return ES_FIX;
00120   }
00121 
00122 
00123 
00124 }}}
00125 
00126 // STATISTICS: float-prop