public enum IntEventType extends Enum<IntEventType> implements IEventType
REMOVE
: value removal event,INCLOW
: lower bound increase event,DECUPP
: upper bound decrease event,BOUND
: lower bound increase and/or upper bound decrease event,INSTANTIATE
: variable instantiation event Propagator.getPropagationConditions(int i)
.
It helps sorting the propagator of the variable i wrt the types of event they can deal with.
Propagators which react to the same type of events are placed in the same "bucket".
Thus, when the variable i is modified, only propagators which are able to deduce something from that event are called.
In that case, combinations of events are allowed, such as {REMOVE
, INCLOW
}
or {REMOVE
, INCLOW
, DECUPP
, INSTANTIATE
},
and are stored, for each variable, with the help of bit mask.
IntVar.instantiateTo(int, ICause)
or IntVar.updateLowerBound(int, ICause)
.
In that case, when the propagation engine is triggered, with only single one event as input: INSTANTIATE
or INCLOW
.
Then, in the propagation engine, the event is stored, possibly merged with not propagates ones, for future execution.
Propagator.propagate(int, int)
.
In this method, it may happen that the events registered are filtered,
calling isRemove(int)
or isBound(int)
, to adapt the filtering to the type of events registered.
Note that the conditional tests should consider that events can be merged.
REMOVE
is the smallest event.
Then, if other type of event occurs, it is greater and maybe a specific and/or more efficient algorithm can be used instead.
So, we prefer testing whether an event is greater than smaller.
More over, using deltas, we can iterate over newly removed values, without paying interest to the type of events registered.
When, in your propagator, you declare Propagator.getPropagationConditions(int i)
like this:
public int getPropagationConditions(int vIdx) {
return IntEventType.boundAndInst();
}
your propagator will be informed anytime one if its variables is modified by any events but REMOVE
(that is INCLOW
and/or DECUPP
and/or INSTANTIATE
).
On the contrary, if you defined something like:
public int getPropagationConditions(int vIdx) {
return IntEventType.all();
}
your propagator will be informed anytime one of its variable is modified by any events.
Later, when your propagator is actually executed, the aggregated events mask is given as input
(2nd parameter of Propagator.propagate(int i,int m)
),
and here you can adapt the algorithm to the events got.
Indeed, you can have a merge event made of DECUPP
and INCLOW
and REMOVE
which indicates that:
Enum Constant and Description |
---|
BOUND
Increasing lower bound and decreasing upper bound event
|
DECUPP
Decreasing upper bound event
|
INCLOW
Increasing lower bound event
|
INSTANTIATE
Instantiation event
|
REMOVE
Value removal event
|
VOID
No event
|
ALL_EVENTS
Modifier and Type | Method and Description |
---|---|
static int |
all() |
static int |
boundAndInst() |
static int |
combine(IntEventType... evts)
Combines into a single mask some evts.
|
int |
getMask()
Return the value of the mask associated with the event.
|
static int |
instantiation() |
static boolean |
isBound(int mask) |
static boolean |
isDecupp(int mask) |
static boolean |
isInclow(int mask) |
static boolean |
isInstantiate(int mask) |
static boolean |
isRemove(int mask) |
static IntEventType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static IntEventType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final IntEventType VOID
public static final IntEventType REMOVE
public static final IntEventType INCLOW
public static final IntEventType DECUPP
public static final IntEventType BOUND
public static final IntEventType INSTANTIATE
public static IntEventType[] values()
for (IntEventType c : IntEventType.values()) System.out.println(c);
public static IntEventType valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic int getMask()
IEventType
getMask
in interface IEventType
public static int combine(IntEventType... evts)
evts
- list of events to combinepublic static int all()
public static int boundAndInst()
public static int instantiation()
public static boolean isInstantiate(int mask)
mask
- the mask to checkmask
contains an INSTANTIATE
event mask.public static boolean isRemove(int mask)
public static boolean isBound(int mask)
mask
- the mask to checkmask
contains an BOUND
event mask.public static boolean isInclow(int mask)
mask
- the mask to checkmask
contains an INCLOW
event mask.public static boolean isDecupp(int mask)
mask
- the mask to checkmask
contains an DECUPP
event mask.Copyright © 2018. All rights reserved.