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