/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte * * Copyright: * Christian Schulte, 2006 * * Last modified: * $Date: 2008-01-31 18:29:16 +0100 (Thu, 31 Jan 2008) $ by $Author: tack $ * $Revision: 6017 $ * * 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 { namespace Bool { /* * Less or equal propagator * */ template forceinline Lq::Lq(Space* home, BV b0, BV b1) : BoolBinary(home,b0,b1) {} template forceinline Lq::Lq(Space* home, bool share, Lq& p) : BoolBinary(home,share,p) {} template Actor* Lq::copy(Space* home, bool share) { return new (home) Lq(home,share,*this); } template inline ExecStatus Lq::post(Space* home, BV b0, BV b1) { if (b0.zero()) { return ES_OK; } else if (b0.one()) { GECODE_ME_CHECK(b1.one(home)); } else if (b1.zero()) { GECODE_ME_CHECK(b0.zero(home)); } else if (b1.one()) { return ES_OK; } else { (void) new (home) Lq(home,b0,b1); } return ES_OK; } template ExecStatus Lq::propagate(Space* home, ModEventDelta) { #define GECODE_INT_STATUS(S0,S1) \ ((BV::S0<<(1*BV::BITS))|(BV::S1<<(0*BV::BITS))) switch ((x0.status()<<(1*BV::BITS)) | (x1.status()<<(0*BV::BITS))) { case GECODE_INT_STATUS(NONE,NONE): GECODE_NEVER; case GECODE_INT_STATUS(NONE,ZERO): GECODE_ME_CHECK(x0.zero_none(home)); break; case GECODE_INT_STATUS(NONE,ONE): x0.cancel(home,this,PC_BOOL_VAL); break; case GECODE_INT_STATUS(ZERO,NONE): x1.cancel(home,this,PC_BOOL_VAL); break; case GECODE_INT_STATUS(ZERO,ZERO): break; case GECODE_INT_STATUS(ZERO,ONE): break; case GECODE_INT_STATUS(ONE,NONE): GECODE_ME_CHECK(x1.one_none(home)); break; case GECODE_INT_STATUS(ONE,ZERO): return ES_FAILED; case GECODE_INT_STATUS(ONE,ONE): break; default: GECODE_NEVER; } return ES_SUBSUMED(this,sizeof(*this)); #undef GECODE_INT_STATUS } template inline Support::Symbol Lq::ati(void) { return Reflection::mangle("Gecode::Int::Bool::Lq"); } template Reflection::ActorSpec Lq::spec(const Space* home, Reflection::VarMap& m) const { return BoolBinary::spec(home, m, ati()); } template void Lq::post(Space* home, Reflection::VarMap& vars, const Reflection::ActorSpec& spec) { spec.checkArity(2); BV b0(home, vars, spec[0]); BV b1(home, vars, spec[1]); (void) new (home) Lq(home,b0,b1); } /* * Less posting * */ template forceinline ExecStatus Le::post(Space* home, BV b0, BV b1) { GECODE_ME_CHECK(b0.zero(home)); GECODE_ME_CHECK(b1.one(home)); return ES_OK; } }}} // STATISTICS: int-prop