Generated on Tue Apr 18 10:21:49 2017 for Gecode by doxygen 1.6.3

ngl.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  *
00006  *  Copyright:
00007  *     Christian Schulte, 2013
00008  *
00009  *  Last modified:
00010  *     $Date: 2016-04-19 17:19:45 +0200 (Tue, 19 Apr 2016) $ by $Author: schulte $
00011  *     $Revision: 14967 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode { namespace Int { namespace Branch {
00039 
00040   template<class View>
00041   forceinline
00042   EqNGL<View>::EqNGL(Space& home, View x, int n)
00043     : ViewValNGL<View,int,PC_INT_VAL>(home,x,n) {}
00044   template<class View>
00045   forceinline
00046   EqNGL<View>::EqNGL(Space& home, bool share, EqNGL& ngl)
00047     : ViewValNGL<View,int,PC_INT_VAL>(home,share,ngl) {}
00048   template<class View>
00049   NGL*
00050   EqNGL<View>::copy(Space& home, bool share) {
00051     return new (home) EqNGL<View>(home,share,*this);
00052   }
00053   template<class View>
00054   NGL::Status
00055   EqNGL<View>::status(const Space&) const {
00056     if (x.assigned())
00057       return (x.val() == n) ? NGL::SUBSUMED : NGL::FAILED;
00058     else
00059       return x.in(n) ? NGL::NONE : NGL::FAILED;
00060   }
00061   template<class View>
00062   ExecStatus
00063   EqNGL<View>::prune(Space& home) {
00064     return me_failed(x.nq(home,n)) ? ES_FAILED : ES_OK;
00065   }
00066 
00067 
00068   template<class View>
00069   forceinline
00070   NqNGL<View>::NqNGL(Space& home, View x, int n)
00071     : ViewValNGL<View,int,PC_INT_DOM>(home,x,n) {}
00072   template<class View>
00073   forceinline
00074   NqNGL<View>::NqNGL(Space& home, bool share, NqNGL& ngl)
00075     : ViewValNGL<View,int,PC_INT_DOM>(home,share,ngl) {}
00076   template<class View>
00077   NGL*
00078   NqNGL<View>::copy(Space& home, bool share) {
00079     return new (home) NqNGL<View>(home,share,*this);
00080   }
00081   template<class View>
00082   NGL::Status
00083   NqNGL<View>::status(const Space&) const {
00084     if (x.assigned())
00085       return (x.val() == n) ? NGL::FAILED : NGL::SUBSUMED;
00086     else
00087       return x.in(n) ? NGL::NONE : NGL::SUBSUMED;
00088   }
00089   template<class View>
00090   ExecStatus
00091   NqNGL<View>::prune(Space& home) {
00092     return me_failed(x.eq(home,n)) ? ES_FAILED : ES_OK;
00093   }
00094 
00095 
00096   template<class View>
00097   forceinline
00098   LqNGL<View>::LqNGL(Space& home, View x, int n)
00099     : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {}
00100   template<class View>
00101   forceinline
00102   LqNGL<View>::LqNGL(Space& home, bool share, LqNGL& ngl)
00103     : ViewValNGL<View,int,PC_INT_BND>(home,share,ngl) {}
00104   template<class View>
00105   NGL*
00106   LqNGL<View>::copy(Space& home, bool share) {
00107     return new (home) LqNGL<View>(home,share,*this);
00108   }
00109   template<class View>
00110   NGL::Status
00111   LqNGL<View>::status(const Space&) const {
00112     if (x.max() <= n)
00113       return NGL::SUBSUMED;
00114     else if (x.min() > n)
00115       return NGL::FAILED;
00116     else
00117       return NGL::NONE;
00118   }
00119   template<class View>
00120   ExecStatus
00121   LqNGL<View>::prune(Space& home) {
00122     return me_failed(x.gr(home,n)) ? ES_FAILED : ES_OK;
00123   }
00124 
00125 
00126   template<class View>
00127   forceinline
00128   GqNGL<View>::GqNGL(Space& home, View x, int n)
00129     : ViewValNGL<View,int,PC_INT_BND>(home,x,n) {}
00130   template<class View>
00131   forceinline
00132   GqNGL<View>::GqNGL(Space& home, bool share, GqNGL& ngl)
00133     : ViewValNGL<View,int,PC_INT_BND>(home,share,ngl) {}
00134   template<class View>
00135   NGL*
00136   GqNGL<View>::copy(Space& home, bool share) {
00137     return new (home) GqNGL<View>(home,share,*this);
00138   }
00139   template<class View>
00140   NGL::Status
00141   GqNGL<View>::status(const Space&) const {
00142     if (x.min() >= n)
00143       return NGL::SUBSUMED;
00144     else if (x.max() < n)
00145       return NGL::FAILED;
00146     else
00147       return NGL::NONE;
00148   }
00149   template<class View>
00150   ExecStatus
00151   GqNGL<View>::prune(Space& home) {
00152     return me_failed(x.le(home,n)) ? ES_FAILED : ES_OK;
00153   }
00154 
00155 }}}
00156 
00157 // STATISTICS: int-branch