38#ifndef GECODE_INT_EXTENSIONAL_HH
39#define GECODE_INT_EXTENSIONAL_HH
70 bool empty(
void)
const;
87 template<
class View,
class Val,
class Degree,
class StateIdx>
168 bool empty(
void)
const;
244namespace Gecode {
namespace Int {
namespace Extensional {
255 template<
class IndexType>
274 BitSet(
Space& home,
unsigned int n,
bool indexed=
false);
276 template<
class OldIndexType>
287 unsigned int limit(
void)
const;
289 bool empty(
void)
const;
293 unsigned int width(
void)
const;
301 template<
bool sparse>
319 unsigned long long int ones(
void)
const;
325 unsigned long long int bits(
void)
const;
327 unsigned int words(
void)
const;
329 unsigned int size(
void)
const;
336namespace Gecode {
namespace Int {
namespace Extensional {
339 template<
unsigned int _size>
349 template<
unsigned int largersize>
352 template<
class IndexType>
357 bool empty(
void)
const;
361 unsigned int width(
void)
const;
369 template<
bool sparse>
389 unsigned long long int ones(
void)
const;
395 unsigned long long int bits(
void)
const;
397 unsigned int words(
void)
const;
399 unsigned int size(
void)
const;
406namespace Gecode {
namespace Int {
namespace Extensional {
412 template<
bool indexed>
422 int index(
void)
const;
434 int index(
void)
const;
438 template<
class View,
bool pos,
bool indexed>
469 template<
class Advisor>
499 template<
class Actor>
502 template<
class Actor>
505 template<
class Actor>
509 template<
class View,
bool pos>
598 template<
class Table>
601 template<
class Table>
602 bool full(
const Table& table)
const;
626 template<
class View,
class Table>
654 template<
class TableProp>
696 template<
class View,
class Table>
715 template<
class TableProp>
744 template<
class View,
class Table,
class CtrlView, ReifyMode rm>
767 template<
class TableProp>
792 template<
class View,
class CtrlView, ReifyMode rm>
796 template<
class View,
class CtrlView, ReifyMode rm>
void init(void)
Initialize links (self-linked).
Advisor(Space &home, Propagator &p, Council< A > &c)
Constructor for creation.
Deterministic finite automaton (DFA).
Generic domain change information to be supplied to advisors.
Home class for posting propagators
BitSetData * _word_bits
Active word data.
unsigned long long int bits(void) const
Return an upper bound on the number of bits.
void add_to_mask(const BitSetData *support, BitSetData *mask) const
Add support to mask.
bool intersects(const BitSetData *mask) const
Check if has a non-empty intersection with the set.
void intersect_with_mask(const BitSetData *mask)
Intersect with mask, sparse mask if sparse is true.
unsigned int width(void) const
Return the highest active index.
IndexType _word_capacity
Number of addressable word slots.
unsigned long long int ones(void) const
Return the number of ones.
IndexType _active_words
Number of active words.
void intersect_with_masks(const BitSetData *a, const BitSetData *b)
Intersect with the "or" of a and b.
IndexType * _word_index
Original word index for each active word position.
unsigned int size(void) const
Return the number of required bit set words.
unsigned int limit(void) const
Get the number of active words.
void replace_and_decrease(IndexType active_pos, BitSetData word)
Replace active word active_pos, dropping it if word is zero.
void clear_mask(BitSetData *mask) const
Clear all active words in mask.
bool empty(void) const
Check whether the set is empty.
unsigned int words(void) const
Return the number of required bit set words.
IndexType * _active_position
Reverse map from word index to active position+1 (optional).
void flush(void)
Make the set empty.
void nand_with_mask(const BitSetData *mask)
Perform "nand" with mask.
CompactAdvisorIndex(int i)
Initialize without storing i.
int index(void) const
Return a dummy index.
int index(void) const
Return the variable index.
int _index
Variable index.
CompactAdvisorIndex(int i)
Initialize with index i.
Optional variable index stored by a compact-table advisor.
Advisor shared by compact-table support representations.
TupleSet::Range Range
Range type for supports.
void dispose(Space &home, Council< CompactAdvisor > &c)
Dispose advisor.
const Range * lst(void) const
Return last range of support data structure.
CompactAdvisor(Space &home, CompactAdvisor &a)
Clone advisor a.
const Range * fst(void) const
Return first range of support data structure.
int index(void) const
Return the variable index.
CompactAdvisor(Space &home, Propagator &p, Council< CompactAdvisor > &c, const TupleSet &ts, View x, int i)
Initialize from parameters.
void adjust(void)
Adjust supports to the current view bounds.
Touched-advisor status shared by positive compact-table propagators.
void propagating(void)
Record that propagation is in progress.
StatusType
Type of status.
CompactStatus(StatusType t)
Initialize with status t.
void touched(Advisor &a)
Record that advisor a was touched.
void none(void)
Record that no advisor has been touched.
CompactStatus(const CompactStatus &status)
Copy constructor.
bool single(Advisor &a) const
Test whether only advisor a was touched.
StatusType type(void) const
Return status type.
Iterator over lost supports.
int last_value
High value.
const Range * support_range
Range information.
const BitSetData * support(void) const
Return support representation.
LostSupports(const Compact< View, pos > &p, CTAdvisor &a, int first_value, int last_value)
Initialize iterator for values between first_value and last_value.
bool operator()(void) const
Whether iterator is done.
void operator++(void)
Move iterator to next value.
const unsigned int n_words
Number of words.
const BitSetData * support_words
The lost value's support.
const Range * last_support_range
Last range.
Iterator over valid supports.
const Range * last_support_range
The last range.
ViewRanges< View > view_ranges
Range iterator.
bool operator()(void) const
Whether there are still supports left.
const BitSetData * support(void) const
Return support representation.
void operator++(void)
Move to next supports.
ValidSupports(const Compact< View, pos > &p, CTAdvisor &a)
Initialize from initialized propagator.
const BitSetData * support_words
The value's support.
int max_value
Maximal value.
void find(void)
Find a new value (only for negative case).
const unsigned int n_words
Number of words.
int val(void) const
Return supported value.
const Range * support_range
Support iterator.
Compact(Space &home, Compact &p)
Constructor for cloning p.
size_t dispose(Space &home)
Delete propagator and return its size.
TupleSet ts
The tuple set.
Compact(Home home, const TupleSet &ts)
Constructor for posting.
const BitSetData * supports(CTAdvisor &a, int n)
Return supports for value n.
CompactAdvisor< View, pos, false > CTAdvisor
Advisor for updating current table.
bool full(const Table &table) const
Check whether the table covers the whole Cartedion product.
void setup(Space &home, Table &table, ViewArray< View > &x)
Setup the actual table.
const unsigned int n_words
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function.
bool all(void) const
Whether all variables are assigned.
const Range * range(CTAdvisor &a, int n)
Find range for n.
bool atmostone(void) const
Whether at most one variable is unassigned.
TupleSet::Range Range
Range type for supports.
Compressed tuple-word support list.
const TupleSet::CSupportWord * end(void) const
Return one past last support word.
const TupleSet::CSupportWord * begin(void) const
Return first support word.
bool empty(void) const
Whether support list is empty.
const TupleSet::CSupportWord * e
One past last support word.
const TupleSet::CSupportWord * b
First support word.
CompressedSupport(void)
Initialize as empty support list.
Edge defined by in-state and out-state
StateIdx o_state
Number of out-state.
StateIdx i_state
Number of in-state.
Range approximation of which positions have changed.
void reset(void)
Reset range to be empty.
void add(const IndexRange &ir)
Add index range ir to range.
void add(int i)
Add index i to range.
int fst(void) const
Return first position.
void lshift(int n)
Shift index range by n elements to the left.
int lst(void) const
Return last position.
bool empty(void) const
Test whether range is empty.
IndexRange(void)
Initialize range as empty.
Index(Space &home, Propagator &p, Council< Index > &c, int i)
Create index advisor.
int i
The position of the view in the view array.
bool operator()(void) const
Test whether more values supported.
void operator++(void)
Move to next supported value.
LayerValues(void)
Default constructor.
int val(void) const
Return supported value.
Layer for a view in the layered graph
Support * support
Supported values.
State * states
States used by outgoing edges.
ValSize size
Number of supported values.
StateIdx n_states
Number of states used by outgoing edges.
States are described by number of incoming and outgoing edges.
Degree o_deg
The out-degree (number of outgoing edges) Initialize with zeroes.
Degree i_deg
The in-degree (number of incoming edges).
Support information for a value
Edge * edges
Supporting edges in layered graph.
Degree n_edges
Number of supporting edges.
ExecStatus initialize(Space &home, const VarArgArray< Var > &x, const DFA &dfa)
Initialize layered graph.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
unsigned int n_edges
Total number of edges.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Gecode::Support::IntTypeTraits< Val >::utype ValSize
Type for support size.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
virtual PropCost cost(const Space &home, const ModEventDelta &med) const
Cost function (defined as high linear).
StateIdx max_states
Maximal number of states per layer.
unsigned int n_states
Total number of states.
State & o_state(int i, const Edge &e)
Return state for layer i and out state of edge e.
bool i_dec(int i, const Edge &e)
Decrement out degree for in state of edge e for layer i.
int n
Number of layers (and views).
IndexRange o_ch
Index range with out-degree modifications.
IndexRange a_ch
Index range for any change (for compression).
virtual size_t dispose(Space &home)
Delete propagator and return its size.
LayeredGraph(Space &home, LayeredGraph< View, Val, Degree, StateIdx > &p)
Constructor for cloning p.
void audit(void)
Perform consistency check on data structures.
IndexRange i_ch
Index range with in-degree modifications.
Council< Index > c
The advisor council.
static ExecStatus post(Home home, const VarArgArray< Var > &x, const DFA &dfa)
Post propagator on views x and DFA dfa.
State & i_state(int i, const Edge &e)
Return in state for layer i and in state of edge e.
State & o_state(int i, StateIdx os)
Return out state for layer i and state index os.
bool o_dec(int i, const Edge &e)
Decrement in degree for out state of edge e for layer i.
State & i_state(int i, StateIdx is)
Return in state for layer i and state index is.
virtual void reschedule(Space &home)
Schedule function.
Layer * layers
The layers of the graph.
Shared implementation of negative compact-table propagation.
Compact< View, false >::ValidSupports ValidSupports
Compact< View, false >::CTAdvisor CTAdvisor
virtual Actor * copy(Space &home)
Copy propagator during cloning.
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Table table
Current table.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
NegCompact(Space &home, TableProp &p)
Constructor for cloning p.
friend class NegCompactAlgorithm
size_t dispose(Space &home)
Delete propagator and return its size.
virtual void reschedule(Space &home)
Schedule function.
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts)
Post propagator for views x and table t.
Compact< View, false >::Range Range
Shared implementation of positive compact-table propagation.
size_t dispose(Space &home)
Delete propagator and return its size.
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Compact< View, true >::ValidSupports ValidSupports
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
Compact< View, true >::Range Range
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
Table table
Current table.
Compact< View, true >::CTAdvisor CTAdvisor
Status status
Propagator status.
friend class PosCompactAlgorithm
CompactStatus< CTAdvisor > Status
Status management.
Compact< View, true >::LostSupports LostSupports
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts)
Post propagator for views x and table t.
virtual void reschedule(Space &home)
Schedule function.
bool empty(void) const
Check whether the table is empty.
PosCompact(Space &home, TableProp &p)
Constructor for cloning p.
Status::StatusType StatusType
Status type.
Shared implementation of reified compact-table propagation.
Compact< View, false >::Range Range
virtual Actor * copy(Space &home)
Copy propagator during cloning.
Table table
Current table.
ViewArray< View > y
The views (for rewriting).
Compact< View, false >::CTAdvisor CTAdvisor
static constexpr ReifyMode mode
virtual ExecStatus advise(Space &home, Advisor &a, const Delta &d)
Give advice to propagator.
virtual ExecStatus propagate(Space &home, const ModEventDelta &med)
Perform propagation.
ReCompact(Space &home, TableProp &p)
Constructor for cloning p.
static ExecStatus post(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post propagator for views x and table t.
static ExecStatus post_neg(Home home, ViewArray< View > &x, const TupleSet &ts)
static ExecStatus post_pos(Home home, ViewArray< View > &x, const TupleSet &ts)
friend class ReCompactAlgorithm
CtrlView b
Boolean control view.
Compact< View, false >::ValidSupports ValidSupports
virtual void reschedule(Space &home)
Schedule function.
size_t dispose(Space &home)
Delete propagator and return its size.
TinyBitSet(Space &home, const TinyBitSet< largersize > &tbs)
Initialize during cloning.
void intersect_with_mask(const BitSetData *mask)
Intersect with mask, sparse mask if sparse is true.
unsigned int words(void) const
Return the number of required bit set words.
unsigned int width(void) const
Return the highest active index.
bool intersects(const BitSetData *b)
Check if has a non-empty intersection with the set.
void add_to_mask(const BitSetData *b, BitSetData *mask) const
Add to mask.
int limit(void) const
Get the limit.
unsigned long long int bits(void) const
Return an upper bound on the number of bits.
void nand_with_masks(const BitSetData *a, const BitSetData *b)
Perform "nand" with and the "or" of a and b.
unsigned long long int ones(void) const
Return the number of ones.
unsigned int size(void) const
Return the total number of words.
bool empty(void) const
Check whether the set is empty.
BitSetData _bits[_size]
Words.
void intersect_with_masks(const BitSetData *a, const BitSetData *b)
Intersect with the "or" of and b.
void flush(void)
Make the set empty.
void nand_with_mask(const BitSetData *b)
Perform "nand" with b.
void clear_mask(BitSetData *mask)
Clear the first limit words in mask.
Range iterator for integer views.
ModEventDelta med
A set of modification events (used during propagation).
Propagator(Home home)
Constructor for posting.
Traits to for information about integer types.
Compressed support data for one tuple-word block.
Class representing a set of tuples.
int * Tuple
Type of a tuple.
Argument array for variables.
ViewAdvisor(Space &home, Propagator &p, Council< A > &c, View x0)
Constructor for creation.
View view(void) const
Access view.
int ModEventDelta
Modification event deltas.
ReifyMode
Mode for reification.
ExecStatus postnegcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for compact table propagator.
TupleSet::Tuple Tuple
Tuple type.
ExecStatus postposcompact(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for positive compact table propagator.
Gecode::Support::BitSetData BitSetData
Import type.
ExecStatus postrecompact(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post function for compact table propagator.
ExecStatus postposcompact_compressed(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for positive compact table with compressed supports.
ExecStatus post_lgp(Home home, const VarArgArray< Var > &x, const DFA &dfa)
Select small types for the layered graph propagator.
ExecStatus postnegcompact_compressed(Home home, ViewArray< View > &x, const TupleSet &ts)
Post function for negative compact table with compressed supports.
ExecStatus postrecompact_compressed(Home home, ViewArray< View > &x, const TupleSet &ts, CtrlView b)
Post function for reified compact table with compressed supports.
Gecode toplevel namespace