public class FixedSetVarImpl extends AbstractVariable implements SetVar
_plugexpl, mIdx, modificationEvents, monitors, MSG_BOUND, MSG_EMPTY, MSG_INST, MSG_LOW, MSG_REMOVE, MSG_UNKNOWN, MSG_UPP, name, solver
Constructor and Description |
---|
FixedSetVarImpl(String name,
int[] values,
Solver solver) |
FixedSetVarImpl(String name,
gnu.trove.set.TIntSet values,
Solver solver) |
Modifier and Type | Method and Description |
---|---|
void |
addMonitor(IVariableMonitor monitor)
Build and add a monitor to the monitor list of
this . |
boolean |
addToKernel(int element,
ICause cause)
Adds element to the kernel, i.e. enforces that the set variable
will contain element in every solution
|
void |
contradiction(ICause cause,
IEventType event,
String message)
Throws a contradiction exception based on
|
void |
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.
|
SetVar |
duplicate()
Duplicate
this . |
void |
duplicate(Solver solver,
gnu.trove.map.hash.THashMap<Object,Object> identitymap)
Duplicate
this (which naturally adds it into solver ). |
boolean |
envelopeContains(int element)
Test whether element is present or not in the envelope
|
NoDelta |
getDelta()
Return the delta domain of this
|
int |
getEnvelopeFirst()
Get the first element currently in the envelope domain of
this . |
int |
getEnvelopeNext()
Get the next element in the envelope domain of
this . |
int |
getEnvelopeSize()
Get the number of elements in the envelope domain of
this . |
int |
getKernelFirst()
Get the first element currently in the kernel domain of
this . |
int |
getKernelNext()
Get the next element in the kernel domain of
this . |
int |
getKernelSize()
Get the number of elements in the kernel domain of
this . |
int |
getTypeAndKind()
Return a MASK composed of 2 main information: TYPE and KIND.
|
int[] |
getValues()
Retrieves the current value of the variable if instantiated, otherwise the lower bound (kernel).
|
boolean |
instantiateTo(int[] value,
ICause cause)
Enforces the set variable to contain exactly the set of integers given in parameter
|
boolean |
isInstantiated()
Indicates whether
this is instantiated (see implemtations to know what instantiation means). |
boolean |
kernelContains(int element)
Test whether element is present or not in the kernel
|
ISetDeltaMonitor |
monitorDelta(ICause propagator)
Allow propagator to monitor element removal/enforcing of this
|
void |
notifyMonitors(IEventType event)
Notify monitors of observed variable modifications
|
void |
notifyPropagators(IEventType event,
ICause cause)
If
this has changed, then notify all of its observers. |
void |
notifyViews(IEventType event,
ICause cause)
Notify views of observed variable modifications
|
void |
recordMask(int mask)
Analysis propagator event reaction on this, and adapt this
|
boolean |
removeFromEnvelope(int element,
ICause cause)
Removes element from the envelop, i.e. the set variable cannot contain element anymore
|
void |
removeMonitor(IVariableMonitor monitor) |
void |
subscribeView(IView view) |
compareTo, getId, getIndexInPropagator, getName, getNbProps, getPIndices, getPropagator, getPropagators, getSolver, getViews, isBool, link, toString, unlink
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getIndexInPropagator, getName, getNbProps, getPIndices, getPropagator, getPropagators, getSolver, getViews, link, unlink
compareTo
public int getKernelFirst()
SetVar
this
.
Returns END
if the set is empty.
Note that elements are not sorted.
To iterate over elements that are present in the kernel, do the following loop:
for(int e=getKernelFirst(); e!=SetVar.END; e=getKernelNext()){
// something
}
getKernelFirst
in interface SetVar
END
if it is empty.public int getKernelNext()
SetVar
this
.
Returns END
once all elements have been visited.
To iterate over elements that are present in the kernel, do the following loop:
for(int e=getKernelFirst(); e!=SetVar.END; e=getKernelNext()){
// something
}
getKernelNext
in interface SetVar
END
otherwise.public int getKernelSize()
SetVar
this
.getKernelSize
in interface SetVar
public boolean kernelContains(int element)
SetVar
kernelContains
in interface SetVar
element
- value to testpublic int getEnvelopeFirst()
SetVar
this
.
Returns END
if the set is empty.
Note that elements are not sorted.
To iterate over elements that are present in the envelope, do the following loop:
for(int e=getEnvelopeFirst(); e!=SetVar.END; e=getEnvelopeNext()){
// something
}
getEnvelopeFirst
in interface SetVar
END
if it is empty.public int getEnvelopeNext()
SetVar
this
.
Returns END
once all elements have been visited.
To iterate over elements that are present in the envelope, do the following loop:
for(int e=getEnvelopeFirst(); e!=SetVar.END; e=getEnvelopeNext()){
// something
}
getEnvelopeNext
in interface SetVar
END
otherwise.public int getEnvelopeSize()
SetVar
this
.getEnvelopeSize
in interface SetVar
public boolean envelopeContains(int element)
SetVar
envelopeContains
in interface SetVar
element
- value to testpublic boolean addToKernel(int element, ICause cause) throws ContradictionException
SetVar
addToKernel
in interface SetVar
element
- value to addcause
- cause of value additionContradictionException
public boolean removeFromEnvelope(int element, ICause cause) throws ContradictionException
SetVar
removeFromEnvelope
in interface SetVar
element
- value to removecause
- cause of value removalContradictionException
public boolean instantiateTo(int[] value, ICause cause) throws ContradictionException
SetVar
instantiateTo
in interface SetVar
value
- a set of integerscause
- cause of instantiationContradictionException
public int[] getValues()
SetVar
public NoDelta getDelta()
Variable
public void createDelta()
Variable
createDelta
in interface Variable
public ISetDeltaMonitor monitorDelta(ICause propagator)
SetVar
monitorDelta
in interface SetVar
propagator
- observerpublic boolean isInstantiated()
Variable
this
is instantiated (see implemtations to know what instantiation means).isInstantiated
in interface Variable
true
if this
is instantiatedpublic void addMonitor(IVariableMonitor monitor)
Variable
this
.
The monitor is inactive at the creation and must be activated (by the engine propagation).addMonitor
in interface Variable
addMonitor
in class AbstractVariable
monitor
- a variable monitorpublic void removeMonitor(IVariableMonitor monitor)
removeMonitor
in interface Variable
removeMonitor
in class AbstractVariable
public void subscribeView(IView view)
subscribeView
in interface Variable
subscribeView
in class AbstractVariable
public void recordMask(int mask)
Variable
recordMask
in interface Variable
recordMask
in class AbstractVariable
mask
- event maskpublic void notifyPropagators(IEventType event, ICause cause) throws ContradictionException
Variable
this
has changed, then notify all of its observers.notifyPropagators
in interface Variable
notifyPropagators
in class AbstractVariable
event
- event on this objectcause
- object which leads to the modification of this objectContradictionException
- if a contradiction occurs during notificationpublic void notifyViews(IEventType event, ICause cause) throws ContradictionException
Variable
notifyViews
in interface Variable
notifyViews
in class AbstractVariable
event
- the event which occurred on the variableContradictionException
public void notifyMonitors(IEventType event) throws ContradictionException
Variable
notifyMonitors
in interface Variable
event
- the event which occurred on the variableContradictionException
public void contradiction(ICause cause, IEventType event, String message) throws ContradictionException
Variable
contradiction
in interface Variable
cause
- ICause causing the exceptionevent
- event causing the contradictionmessage
- the detailed message @throws ContradictionException expected behaviorContradictionException
public int getTypeAndKind()
Variable
int type = var.getTypeAndKind() & Variable.TYPE;To get the KIND of a variable:
int kind = var.getTypeAndKind() & Variable.KIND;To check a specific type or kind of a variable:
boolean isVar = (var.getTypeAndKind() & Variable.VAR) !=0; boolean isInt = (var.getTypeAndKind() & Variable.INT) !=0;
getTypeAndKind
in interface Variable
Copyright © 2015. All rights reserved.