Go to the documentation of this file.
44 #ifndef __GECODE_SET_HH__
45 #define __GECODE_SET_HH__
57 #if !defined(GECODE_STATIC_LIBS) && \
58 (defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
60 #ifdef GECODE_BUILD_SET
61 #define GECODE_SET_EXPORT __declspec( dllexport )
63 #define GECODE_SET_EXPORT __declspec( dllimport )
68 #ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
69 #define GECODE_SET_EXPORT __attribute__ ((visibility("default")))
71 #define GECODE_SET_EXPORT
77 #ifndef GECODE_BUILD_SET
78 #define GECODE_LIBRARY_NAME "Set"
96 namespace Gecode {
namespace Set {
107 void check(
int n,
const char*
l);
109 void check(
unsigned int n,
const char*
l);
238 unsigned int glbSize(
void)
const;
241 unsigned int lubSize(
void)
const;
245 unsigned int cardMin(
void)
const;
247 unsigned int cardMax(
void)
const;
301 unsigned int width(
void)
const;
333 unsigned int width(
void)
const;
365 unsigned int width(
void)
const;
459 template<
class Char,
class Traits>
460 std::basic_ostream<Char,Traits>&
507 template<
class InputIterator>
508 SetVarArgs(InputIterator first, InputIterator last);
517 int lubMin,
int lubMax,
518 unsigned int minCard = 0,
528 int lubMin,
int lubMax,
529 unsigned int minCard = 0,
540 unsigned int minCard = 0,
551 unsigned int minCard = 0,
592 unsigned int minCard = 0,
602 unsigned int minCard = 0,
612 unsigned int minCard = 0,
623 unsigned int minCard = 0,
697 cardinality(Home home, SetVar
x,
unsigned int i,
unsigned int j);
700 cardinality(Home home,
const SetVarArgs&
x,
unsigned int i,
unsigned int j);
712 dom(Home home, SetVar
x, SetVar
d);
715 dom(Home home,
const SetVarArgs&
x,
const SetVarArgs&
d);
1108 std::function<
void(
Space& home)>
c);
1128 typedef std::function<bool(
const Space& home, SetVar
x,
int i)>
1140 typedef std::function<double(
const Space& home,
SetVar x,
int i)>
1153 typedef std::function<int(
const Space& home,
SetVar x,
int i)>
1167 typedef std::function<void(
Space& home,
unsigned int a,
1318 typedef std::function<void(
const Space &home,
const Brancher&
b,
1320 SetVar
x,
int i,
const int&
n,
1624 branch(Home home,
const SetVarArgs&
x,
1625 SetVarBranch vars, SetValBranch vals,
1634 branch(Home home,
const SetVarArgs&
x,
1635 TieBreak<SetVarBranch> vars, SetValBranch vals,
1644 branch(Home home, SetVar
x, SetValBranch vals,
1652 assign(Home home,
const SetVarArgs&
x, SetAssign vals,
1661 assign(Home home, SetVar
x, SetAssign vals,
1684 branch(Home home,
const SetVarArgs&
x,
1685 SetVarBranch vars, SetValBranch vals,
1686 const Symmetries& syms,
1696 branch(Home home,
const SetVarArgs&
x,
1697 TieBreak<SetVarBranch> vars, SetValBranch vals,
1698 const Symmetries& syms,
1727 relax(Home home,
const SetVarArgs&
x,
const SetVarArgs& sx,
1752 Iter::Ranges::RangeList> {
1769 Set::LubRanges<Set::SetView> > {
void operator++(void)
Move iterator to next range (if possible)
@ SEL_MED_INC
Include median element (rounding downwards)
Class for action management.
@ TE_PRUNE
Trace prune events.
@ SEL_CHB_SIZE_MIN
With smallest CHB Q-score divided by domain size.
Post propagator for SetVar x
SetVarBranch SET_VAR_ACTION_MIN(double d, BranchTbl tbl)
IntRelType
Relation types for integers.
Return selection strategy Select select(void) const
Post propagator for SetVar SetOpType SetVar y
Iterator for the values in the greatest lower bound of a set variable.
SetVarLubValues(void)
Default constructor.
Lub & lub(void)
Give access iterator for delta in leat bound (values that have been removed)
void assign(Home home, const FloatVarArgs &x, FloatAssign fa, FloatBranchFilter bf, FloatVarValPrint vvp)
Assign all x with value selection vals.
SymmetryHandle VariableSymmetry(const IntVarArgs &vars)
Variables in x are interchangeable.
SetVarBranch SET_VAR_MERIT_MIN(SetBranchMerit bm, BranchTbl tbl)
void max(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
@ SEL_AFC_MIN
With smallest accumulated failure count.
int lubMax(void) const
Return maximum element of least upper bound.
Which values to select for branching first.
SetVarBranch SET_VAR_CHB_SIZE_MAX(BranchTbl tbl)
Iter::Ranges::RangeList o
Iterator over old lub.
Trace delta information for set variables.
@ SEL_MIN_MAX
With largest minimum unknown element.
SetAssign SET_ASSIGN_MIN_INC(void)
@ SEL_DEGREE_SIZE_MAX
With largest degree divided by domain size.
Passing integer variables.
Which value to select Select s
ViewTraceRecorder< Set::SetView > SetTraceRecorder
Trace recorder for set variables.
void element(Home home, IntSharedArray c, IntVar x0, IntVar x1, IntPropLevel)
Post domain consistent propagator for .
SetAFC(void)
Construct as not yet initialized.
@ SEL_SIZE_MAX
With largest unknown set.
@ SEL_ACTION_SIZE_MAX
With largest action divided by domain size.
const int min
Smallest allowed integer in integer set.
bool operator()(void) const
Test whether iterator is still at a range or done.
Class for CHB management.
SetVarBranch SET_VAR_CHB_MAX(BranchTbl tbl)
@ SEL_MED_EXC
Exclude median element (rounding downwards)
void channelSorted(Home home, const IntVarArgs &x, SetVar y)
SetVarBranch SET_VAR_DEGREE_SIZE_MAX(BranchTbl tbl)
Post propagator for SetVar SetOpType SetVar SetRelType SetVar z
@ SEL_MED_INC
Include median element (rounding downwards)
Gecode::IntArgs i(4, 1, 2, 3, 4)
SetVarArgs(void)
Allocate empty array.
@ SEL_CHB_SIZE_MAX
With largest CHB Q-score divided by domain size.
unsigned int cardMin(void) const
Return cardinality minimum.
SetValBranch SET_VAL_MIN_EXC(void)
int max(void) const
Return largest value of range.
@ SEL_MAX_MAX
With largest maximum unknown element.
int lubMin(void) const
Return minimum element of least upper bound.
int min(void) const
Return smallest value of range.
void relax(Home home, const FloatVarArgs &x, const FloatVarArgs &sx, Rnd r, double p)
void notMin(Home home, SetVar s, IntVar x)
SetVarArray(void)
Default constructor (array of size 0)
Range iterator for the unknown set.
SetVarBranch SET_VAR_MIN_MIN(BranchTbl tbl)
SetAssign SET_ASSIGN_MED_INC(void)
@ TE_FIX
Trace fixpoint events.
@ SRT_LQ
Less or equal ( )
SetOpType
Common operations for sets.
void branch(Home home, const FloatVarArgs &x, FloatVarBranch vars, FloatValBranch vals, FloatBranchFilter bf, FloatVarValPrint vvp)
Branch over x with variable selection vars and value selection vals.
int val(void) const
Return current value.
@ SRT_GQ
Greater or equal ( )
Iterator for the values in the least upper bound of a set variable.
@ SEL_NONE
First unassigned.
@ SEL_RND_EXC
Exclude random element.
SetVarBranch SET_VAR_NONE(void)
SetVarBranch SET_VAR_AFC_SIZE_MAX(double d, BranchTbl tbl)
SetVarBranch SET_VAR_CHB_MIN(BranchTbl tbl)
Which value to select for assignment.
SetVarBranch SET_VAR_AFC_SIZE_MIN(double d, BranchTbl tbl)
SetVarBranch SET_VAR_AFC_MIN(double d, BranchTbl tbl)
SetVarBranch SET_VAR_AFC_MAX(double d, BranchTbl tbl)
union Gecode::@579::NNF::@61 u
Union depending on nodetype t.
int val(void) const
Return current value.
std::function< int(const Space &home, SetVar x, int i)> SetBranchVal
Branch value function type for set variables.
SetVarBranch SET_VAR_DEGREE_MIN(BranchTbl tbl)
Recording CHB for set variables.
@ SEL_MAX_INC
Include largest element.
Return selection strategy Select select(void) const
SetCHB(void)
Construct as not yet initialized.
Standard set variable tracer.
SetTraceDelta(Set::SetTraceView o, Set::SetView n, const Delta &d)
Initialize with old trace view o, new view n, and delta d.
SetAssign SET_ASSIGN_MAX_EXC(void)
@ SEL_MIN_INC
Include smallest element.
SetVar(void)
Default constructor.
Recording AFC information for set variables.
Variable branching information.
Gecode toplevel namespace
SetValBranch SET_VAL_MAX_INC(void)
int val(void) const
Return current value.
@ SEL_MAX_EXC
Exclude largest element.
void atmostOne(Home home, const SetVarArgs &xa, unsigned int c)
Action & operator=(const Action &a)
Assignment operator.
double tbl(const Gecode::Space &, double w, double b)
Test function for tie-break limit function.
SetVarBranch SET_VAR_MIN_MAX(BranchTbl tbl)
std::function< bool(const Space &home, SetVar x, int i)> SetBranchFilter
Branch filter function type for set variables.
const int max
Largest allowed integer in integer set.
void init(Home home, const SetVarArgs &x, double d=1.0)
Initialize for set variables x with decay factor d.
@ TE_DONE
Trace done events.
const unsigned int card
Maximum cardinality of an integer set.
std::function< double(const Space &home, SetVar x, int i)> SetBranchMerit
Branch merit function type for set variables.
SetVarLubRanges(void)
Default constructor.
@ SEL_MIN_MIN
With smallest minimum unknown element.
@ SEL_AFC_SIZE_MAX
With largest accumulated failure count divided by domain size.
unsigned int lubSize(void) const
Return number of elements in the least upper bound.
int n
Number of variables (size)
std::ostream & os
Output stream to use.
@ SEL_MERIT_MIN
With least merit.
Generic domain change information to be supplied to advisors.
@ SEL_MAX_EXC
Exclude largest element.
Reification specification.
Passing Boolean variables.
Which variable to select Select s
Home class for posting propagators
bool operator()(void) const
Test whether iterator is still at a value or done.
struct Gecode::@579::NNF::@61::@63 a
For atomic nodes.
void init(Home home, const SetVarArgs &x, double d=1.0, SetBranchMerit bm=nullptr)
Initialize for set variables x with decay factor d.
Initialize with strategy SEL_NONE SetVarBranch(void)
SetAssign SET_ASSIGN_RND_INC(Rnd r)
bool operator()(void) const
Test whether iterator is still at a value or done.
struct Gecode::@579::NNF::@61::@62 b
For binary nodes (and, or, eqv)
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Value iterator from range iterator.
SetAssign SET_ASSIGN_MED_EXC(void)
ViewTracer< Set::SetView > SetTracer
Tracer for set variables.
@ SEL_DEGREE_MAX
With largest degree.
Function type for printing branching alternatives for set variables typedef std::function< void(const Space &home, const Brancher &b, unsigned int a, SetVar x, int i, const int &n, std::ostream &o)> SetVarValPrint
Set::LubRanges< Set::SetView > n
Iterator over new lub.
#define GECODE_SET_EXPORT
Tracer that process view trace information.
void dom(Home home, FloatVar x, FloatVal n)
Propagates .
Set::GlbRanges< Set::SetView > n
Iterator over new glb.
Iter::Ranges::RangeList o
Iterator over old glb.
Post propagator for SetVar SetOpType SetVar SetRelType r
Range iterator for computing set difference.
Boolean integer variables.
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
@ SEL_MIN_EXC
Exclude smallest element.
@ SEL_ACTION_MAX
With highest action.
SetValBranch SET_VAL_MIN_INC(void)
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
SetAssign SET_ASSIGN_RND_EXC(Rnd r)
void operator++(void)
Move iterator to next value (if possible)
unsigned int cardMax(void) const
Return cardinality maximum.
Value branching information.
@ TE_INIT
Trace init events.
bool operator()(void) const
Test whether iterator is still at a range or done.
@ SEL_MED_EXC
Exclude median element (rounding downwards)
@ SEL_DEGREE_MIN
With smallest degree.
SetAssign SET_ASSIGN_MAX_INC(void)
LinIntExpr cardinality(const SetExpr &e)
Cardinality of set expression.
SetAssign SET_ASSIGN_MIN_EXC(void)
Range iterator for the greatest lower bound.
@ SEL_ACTION_MIN
With lowest action.
const int max
Largest allowed integer value.
unsigned int unknownSize(void) const
Return number of unknown elements (elements in lub but not in glb)
@ SEL_RND_INC
Include random element.
@ SEL_MIN_INC
Include smallest element.
SetRelType
Common relation types for sets.
Propagator for recording view trace information.
SetVarBranch SET_VAR_ACTION_MAX(double d, BranchTbl tbl)
@ SEL_MERIT_MAX
With highest merit.
@ SEL_CHB_MAX
With highest CHB Q-score.
void weights(Home home, IntSharedArray elements, IntSharedArray weights, SetVar x, IntVar y)
Lub(RangeList *o, Set::SetView n)
Initialize with old lub o and new lub n.
void notMax(Home home, SetVar s, IntVar x)
Initialize with selection strategy a afc a a
std::function< void(Space &home, unsigned int a, SetVar x, int i, int n)> SetBranchCommit
Branch commit function type for set variables.
void operator++(void)
Move iterator to next range (if possible)
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
void operator++(void)
Move iterator to next value (if possible)
void wait(Home home, FloatVar x, std::function< void(Space &home)> c)
Execute c when x becomes assigned.
bool contains(int i) const
Test whether i is in greatest lower bound.
SetValBranch SET_VAL_RND_EXC(Rnd r)
SetAssign SET_ASSIGN(SetBranchVal v, SetBranchCommit c)
Select value as defined by the value function v and commit function c.
Initialize with selection strategy a s SetAssign(Select s=SEL_MIN_INC)
int max(void) const
Return largest value of range.
@ SOT_DUNION
Disjoint union.
@ SEL_SIZE_MIN
With smallest unknown set.
int min(void) const
Return smallest value of range.
SetVarBranch SET_VAR_SIZE_MAX(BranchTbl tbl)
SetVarBranch SET_VAR_DEGREE_MAX(BranchTbl tbl)
void rel(Home home, FloatVar x0, FloatRelType frt, FloatVal n)
Propagates .
SetValBranch SET_VAL_MED_INC(void)
Class for AFC (accumulated failure count) management.
bool operator()(void) const
Test whether iterator is still at a range or done.
void operator++(void)
Move iterator to next value (if possible)
Which value to select Select s
SetVarBranch SET_VAR_RND(Rnd r)
Set view for set variables
int min(void) const
Return smallest value of range.
SetVarBranch SET_VAR_ACTION_SIZE_MAX(double d, BranchTbl tbl)
unsigned int width(void) const
Return width of range (distance between minimum and maximum)
Recording actions for set variables.
Variables as interfaces to variable implementations.
static StdSetTracer def
Default tracer (printing to std::cerr)
void channel(Home home, FloatVar x0, IntVar x1)
Post propagator for channeling a float and an integer variable .
@ SEL_MAX_MIN
With smallest maximum unknown element.
void check(int n, const char *l)
Check whether integer n is in range, otherwise throw overflow exception with information l.
void precede(Home home, const IntVarArgs &x, int s, int t, IntPropLevel)
Post propagator that s precedes t in x.
SetVarUnknownValues(void)
Default constructor.
SymmetryHandle VariableSequenceSymmetry(const IntVarArgs &vars, int ss)
Variable sequences in x of size ss are interchangeable.
unsigned int glbSize(void) const
Return number of elements in the greatest lower bound.
Delta for the least upper bound.
Range iterator for the least upper bound.
Initialize with selection strategy a decay factor a d
SetVarBranch SET_VAR_MAX_MIN(BranchTbl tbl)
SetValBranch SET_VAL(SetBranchVal v, SetBranchCommit c)
Select value as defined by the value function v and commit function c.
@ SEL_AFC_SIZE_MIN
With smallest accumulated failure count divided by domain size.
int glbMin(void) const
Return minimum element of greatest lower bound.
AFC & operator=(const AFC &a)
Assignment operator.
Glb(RangeList *o, Set::SetView n)
Initialize with old glb and new glb.
void operator++(void)
Move iterator to next range (if possible)
void trace(Home home, const FloatVarArgs &x, TraceFilter tf, int te, FloatTracer &t)
Create a tracer for float variables.
Post propagator for SetVar SetOpType op
Initialize with selection strategy a CHB a c
SetVarBranch SET_VAR_MAX_MAX(BranchTbl tbl)
SetValBranch SET_VAL_MAX_EXC(void)
CHB & operator=(const CHB &a)
Assignment operator.
SetVarBranch SET_VAR_CHB_SIZE_MIN(BranchTbl tbl)
@ SEL_MAX_INC
Include largest element.
Iterator for the greatest lower bound ranges of a set variable.
void sequence(Home home, const IntVarArgs &x, const IntSet &s, int q, int l, int u, IntPropLevel)
Post propagator for .
void ite(Home home, BoolVar b, FloatVar x, FloatVar y, FloatVar z)
Post propagator for if-then-else constraint.
Iterator for the unknown ranges of a set variable.
void init(Home home, const SetVarArgs &x, SetBranchMerit bm=nullptr)
Initialize for set variables x.
Rnd r
Random number generator.
bool operator()(void) const
Test whether iterator is still at a value or done.
SetVarBranch SET_VAR_DEGREE_SIZE_MIN(BranchTbl tbl)
int max(void) const
Return largest value of range.
Iterator for the values in the unknown set of a set variable.
int glbMax(void) const
Return maximum of greatest lower bound.
Initialize with selection strategy a branch merit function a mf
SetVarBranch SET_VAR_SIZE_MIN(BranchTbl tbl)
std::function< double(const Space &home, double w, double b)> BranchTbl
Tie-break limit function.
Expand and CHB void expand(Home home, const SetVarArgs &x)
void min(Home home, FloatVar x0, FloatVar x1, FloatVar x2)
Post propagator for .
SetVarUnknownRanges(void)
Default constructor.
Gecode::FloatVal c(-8, 8)
@ SEL_VAL_COMMIT
Select value according to user-defined functions.
Return selection strategy Select select(void) const
Range iterator for range lists
void convex(Home home, SetVar x)
SetAction(void)
Construct as not yet initialized.
Iterator for the least upper bound ranges of a set variable.
int n
Number of negative literals for node type.
@ SEL_DEGREE_SIZE_MIN
With smallest degree divided by domain size.
@ SEL_CHB_MIN
With lowest CHB Q-score.
Lists of ranges (intervals)
Argument array for variables.
SetVarGlbRanges(void)
Default constructor.
SetVarGlbValues(void)
Default constructor.
Passing integer arguments.
Delta for the greatest lower bound.
SetVarBranch SET_VAR_ACTION_SIZE_MIN(double d, BranchTbl tbl)
@ SEL_MIN_EXC
Exclude smallest element.
SetVarBranch SET_VAR_MERIT_MAX(SetBranchMerit bm, BranchTbl tbl)
@ SEL_AFC_MAX
With largest accumulated failure count.
SetValBranch SET_VAL_MED_EXC(void)
@ SEL_RND_EXC
Exclude random element.
int p
Number of positive literals for node type.
Initialize with selection strategy a s SetValBranch(Select s=SEL_MIN_INC)
@ SEL_ACTION_SIZE_MIN
With smallest action divided by domain size.
@ TE_FAIL
Trace fail events.
Archive & operator<<(Archive &e, FloatNumBranch nl)
SetValBranch SET_VAL_RND_INC(Rnd r)
@ SEL_RND
Random (uniform, for tie breaking)
bool notContains(int i) const
Test whether i is not in the least upper bound.
Glb & glb(void)
Give access to iterator for delta in greatest lower bound (values that have been included)
Which variable to select for branching.
@ SEL_RND_INC
Include random element.