Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
6.4 kB · 252 lines
C++
at develop
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- *//* * Main authors: * Christian Schulte <schulte@gecode.org> * * Contributing authors: * Samuel Gagnon <samuel.gagnon92@gmail.com> * * Copyright: * Christian Schulte, 2008 * Samuel Gagnon, 2018 * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */
namespace Gecode { namespace Int {
/* * Negated Boolean views * */
/* * Constructors and initialization * */ forceinline NegBoolView::NegBoolView(void) {} forceinline NegBoolView::NegBoolView(const BoolView& y) : DerivedView<BoolView>(y) {}
/* * Boolean domain tests * */ forceinline BoolStatus NegBoolView::status(void) const { return x.status(); } forceinline bool NegBoolView::zero(void) const { return x.one(); } forceinline bool NegBoolView::one(void) const { return x.zero(); } forceinline bool NegBoolView::none(void) const { return x.none(); }
/* * Boolean assignment operations * */ forceinline ModEvent NegBoolView::zero_none(Space& home) { return x.one_none(home); } forceinline ModEvent NegBoolView::one_none(Space& home) { return x.zero_none(home); }
forceinline ModEvent NegBoolView::zero(Space& home) { return x.one(home); } forceinline ModEvent NegBoolView::one(Space& home) { return x.zero(home); }
/* Domain update by value * */
forceinline ModEvent NegBoolView::lq(Space& home, int n) { return n==0 ? x.one(home) : (n < 0 ? ME_BOOL_FAILED : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::lq(Space& home, long long int n) { return n==0 ? x.one(home) : (n < 0 ? ME_BOOL_FAILED : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::le(Space& home, int n) { return n==1 ? x.one(home) : (n < 1 ? ME_BOOL_FAILED : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::le(Space& home, long long int n) { return n==1 ? x.one(home) : (n < 1 ? ME_BOOL_FAILED : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::gq(Space& home, int n) { return n==1 ? x.zero(home) : (n <= 0 ? ME_BOOL_NONE : ME_BOOL_FAILED); } forceinline ModEvent NegBoolView::gq(Space& home, long long int n) { return n==1 ? x.zero(home) : (n <= 0 ? ME_BOOL_NONE : ME_BOOL_FAILED); } forceinline ModEvent NegBoolView::gr(Space& home, int n) { return n==0 ? x.zero(home) : (n >= 1 ? ME_BOOL_FAILED : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::gr(Space& home, long long int n) { return n==0 ? x.zero(home) : (n >= 1 ? ME_BOOL_FAILED : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::nq(Space& home, int n) { return n==0 ? x.zero(home) : (n==1 ? x.one(home) : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::nq(Space& home, long long int n) { return n==0 ? x.zero(home) : (n==1 ? x.one(home) : ME_BOOL_NONE); } forceinline ModEvent NegBoolView::eq(Space& home, int n) { return n==0 ? x.one(home) : (n==1 ? x.zero(home) : ME_BOOL_FAILED); } forceinline ModEvent NegBoolView::eq(Space& home, long long int n) { return n==0 ? x.one(home) : (n==1 ? x.zero(home) : ME_BOOL_FAILED); } /* * Value access * */ forceinline int NegBoolView::min(void) const { return 1-x.max(); } forceinline int NegBoolView::max(void) const { return 1-x.min(); } forceinline int NegBoolView::val(void) const { return 1-x.val(); }#ifdef GECODE_HAS_CBS forceinline int NegBoolView::baseval(int val) const { return 1-val; }#endif
/* * Delta information for advisors * */ forceinline int NegBoolView::min(const Delta& d) const { return x.max(d); } forceinline int NegBoolView::max(const Delta& d) const { return x.min(d); } forceinline unsigned int NegBoolView::width(const Delta& d) const { return x.width(d); } forceinline bool NegBoolView::any(const Delta& d) const { return x.any(d); } forceinline bool NegBoolView::zero(const Delta& d) { return BoolView::one(d); } forceinline bool NegBoolView::one(const Delta& d) { return BoolView::zero(d); }
/* * View comparison * */ forceinline bool operator ==(const NegBoolView& x, const NegBoolView& y) { return x.base() == y.base(); } forceinline bool operator !=(const NegBoolView& x, const NegBoolView& y) { return !(x == y); }
/** * \brief %Range iterator for negated Boolean variable views * \ingroup TaskActorIntView */ template<> class ViewRanges<NegBoolView> : public Iter::Ranges::Singleton { public: /// \name Constructors and initialization //@{ /// Default constructor ViewRanges(void); /// Initialize with ranges for view \a x ViewRanges(const NegBoolView& x); /// Initialize with ranges for view \a x void init(const NegBoolView& x); //@} };
forceinline ViewRanges<NegBoolView>::ViewRanges(void) {}
forceinline ViewRanges<NegBoolView>::ViewRanges(const NegBoolView& x) : Iter::Ranges::Singleton(x.min(),x.max()) {}
forceinline void ViewRanges<NegBoolView>::init(const NegBoolView& x) { Iter::Ranges::Singleton::init(x.min(),x.max()); }
}}
// STATISTICS: int-var