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