bool.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2006
*
* 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.
*
*/
#include <gecode/int.hh>
namespace Gecode { namespace Int {
BoolVarImp BoolVarImp::s_one(1);
BoolVarImp BoolVarImp::s_zero(0);
ModEvent
BoolVarImp::one_none(Space& home) {
assert(none());
bits() ^= (NONE ^ ONE);
assert(one());
IntDelta d(0);
return notify(home,ME_BOOL_VAL,d);
}
ModEvent
BoolVarImp::zero_none(Space& home) {
assert(none());
bits() ^= (NONE ^ ZERO);
assert(zero());
IntDelta d(1);
return notify(home,ME_BOOL_VAL,d);
}
void
BoolVarImp::subscribe(Space& home, Propagator& p, PropCond,
bool schedule) {
// Subscription can be used with integer propagation conditions,
// which must be remapped to the single Boolean propagation condition.
BoolVarImpBase::subscribe(home,p,PC_BOOL_VAL,assigned(),schedule);
}
void
BoolVarImp::reschedule(Space& home, Propagator& p, PropCond) {
BoolVarImpBase::reschedule(home,p,PC_BOOL_VAL,assigned());
}
void
BoolVarImp::subscribe(Space& home, Advisor& a, bool fail) {
BoolVarImpBase::subscribe(home,a,assigned(),fail);
}
}}
// STATISTICS: int-var
Gecode::Advisor
Base-class for advisors.
Definition core.hpp:1292
Gecode::Int::BoolVarImpBase::notify
Gecode::ModEvent notify(Gecode::Space &home, Gecode::ModEvent me, Gecode::Delta &d)
Notify that variable implementation has been modified with modification event me and delta informatio...
Definition var-imp.hpp:322
Gecode::Int::BoolVarImpBase::subscribe
void subscribe(Gecode::Space &home, Gecode::Propagator &p, Gecode::PropCond pc, bool assigned, bool schedule)
Subscribe propagator p with propagation condition pc.
Definition var-imp.hpp:304
Gecode::Int::BoolVarImpBase::reschedule
void reschedule(Gecode::Space &home, Gecode::Propagator &p, Gecode::PropCond pc, bool assigned)
Re-schedule propagator p.
Definition var-imp.hpp:317
Gecode::Int::BoolVarImp
Boolean variable implementation.
Definition var-imp.hpp:491
Gecode::Int::BoolVarImp::zero
bool zero(void) const
Test whether variable is assigned to zero.
Definition bool.hpp:131
Gecode::Int::BoolVarImp::none
bool none(void) const
Test whether variable is not yet assigned.
Definition bool.hpp:139
Gecode::Int::BoolVarImp::schedule
static void schedule(Space &home, Propagator &p, ModEvent me)
Schedule propagator p with modification event me.
Definition bool.hpp:405
Gecode::Int::BoolVarImp::one
bool one(void) const
Test whether variable is assigned to one.
Definition bool.hpp:135
Gecode::Int::BoolVarImp::one_none
ModEvent one_none(Space &home)
Assign unassigned variable to one.
Definition bool.cpp:42
Gecode::Int::BoolVarImp::NONE
static const BoolStatus NONE
Status of domain not yet assigned.
Definition var-imp.hpp:525
Gecode::Int::BoolVarImp::subscribe
void subscribe(Space &home, Propagator &p, PropCond pc, bool schedule=true)
Subscribe propagator p to variable with propagation condition pc.
Definition bool.cpp:60
Gecode::Int::BoolVarImp::reschedule
void reschedule(Space &home, Propagator &p, PropCond pc)
Re-schedule propagator p.
Definition bool.cpp:68
Gecode::Int::BoolVarImp::ZERO
static const BoolStatus ZERO
Status of domain assigned to zero.
Definition var-imp.hpp:521
Gecode::Int::BoolVarImp::assigned
bool assigned(void) const
Test whether variable is assigned.
Definition bool.hpp:85
Gecode::Int::BoolVarImp::zero_none
ModEvent zero_none(Space &home)
Assign unassigned variable to zero.
Definition bool.cpp:51
Gecode::Int::BoolVarImp::ONE
static const BoolStatus ONE
Status of domain assigned to one.
Definition var-imp.hpp:523
Gecode::Int::IntDelta
Integer delta information for advisors.
Definition var-imp.hpp:51
Gecode::Propagator
Base-class for propagators.
Definition core.hpp:1064
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::VarImp< Gecode::Int::BoolVarImpConf >::fail
ModEvent fail(Space &home)
Definition core.hpp:4570
Gecode::VarImp< Gecode::Int::BoolVarImpConf >::bits
unsigned int bits(void) const
Definition core.hpp:4196
int.hh
Gecode::Int
Finite domain integers.
Gecode::Int::ME_BOOL_VAL
const Gecode::ModEvent ME_BOOL_VAL
Domain operation has resulted in a value (assigned variable).
Definition var-type.hpp:116
Gecode::Int::PC_BOOL_VAL
const Gecode::PropCond PC_BOOL_VAL
Propagate when a view becomes assigned (single value).
Definition var-type.hpp:126
Gecode
Gecode toplevel namespace
Gecode::PropCond
int PropCond
Type for propagation conditions.
Definition core.hpp:72
Gecode::ModEvent
int ModEvent
Type for modification events.
Definition core.hpp:62