public class Store extends Object
Modifier and Type | Field and Description |
---|---|
List<Var> |
auxilaryVariables
It contains all auxilary variables created by decomposable constraints.
|
SimpleHashSet<Constraint>[] |
changed
It stores constraints scheduled for reevaluation.
|
BooleanVar[] |
changeHistory4BooleanVariables
It stores boolean variables as soon as they change (become grounded or
number of constraints being attached is changed).
|
Constraint |
currentConstraint
It stores constraint which is currently re-evaluated.
|
int |
currentQueue
It stores current queue, which is being evaluated.
|
static boolean |
debug
It specifies if some debugging information is printed.
|
String |
description
It specifies long description of the store.
|
static FailException |
failException
It stores standard fail exception used when empty domain encountered.
|
String |
id
Id string of the store.
|
boolean |
isLastConsistencyFailure
This flag is set to true when consistency function of the store encounters failure.
|
int |
level
It specifies the time point in the search.
|
protected List<MutableVar> |
mutableVariables
A mutable variable is a special variable which can change value during
the search.
|
long |
numberConsistencyCalls
Number of calls to consistency methods of constraints.
|
protected int |
numberOfConstraints
It stores the number of constraints which were imposed to the store.
|
TimeStamp<Integer> |
pointer4GroundedBooleanVariables
It specifies the current pointer to put next changed boolean variable.
|
boolean |
propagationHasOccurred
This variable specifies if there was a new propagation.
|
int |
queueNo
It stores number of queues used in this store.
|
boolean |
raiseLevelBeforeConsistency
Some constraints maintain complex data structure based on function
recentDomainPruning of a variable, this function for proper functioning
requires to raise store level after imposition and before any changes to
variables of this constraint occur.
|
Constraint |
recentlyFailedConstraint
It stores constraint that has recently failed during store.consistency() execution.
|
Set<RemoveLevelLate> |
removeLevelLateListeners
More advanced constraints may require to be informed of a backtrack to be
able to recover the older versions of the data structures.
|
Set<Stateful> |
removeLevelListeners
More advanced constraints may require to be informed of a backtrack to be
able to recover the older versions of the data structures.
|
protected int |
size
Number of variables stored within a store.
|
SparseSet |
sparseSet
It is used by Extensional MDD constraints.
|
int |
sparseSetSize
It is used by Extensional MDD constraints.
|
boolean |
strict
It indicates that consistency function should immediately return fail if last inconsistency was not followed
yet by removeLevel function.
|
protected List<Stateful> |
timeStamps
TimeStamp variable is a simpler version of a mutable variable.
|
BacktrackableManager |
trailManager
It allows to manage information about changed variables in
efficient/specialized/tailored manner.
|
protected String |
variableIdPrefix
The prefix of any variable which was noname.
|
Map<String,Var> |
variablesHashMap
It may be used for faster retrieval of variables given their id.
|
boolean |
variableWeightManagement
It specifies if the weight of variables which are in the scope of the failure
constraint should be increased.
|
Var[] |
vars
It stores integer variables created within a store.
|
Map<Var,Set<Constraint>> |
watchedConstraints
This keeps information about watched constraints by given variable.
|
Constructor and Description |
---|
Store()
It specifies the default constructor of the store.
|
Store(int size)
It specifies the constructor of the store, which allows to decide what is
the initial size of the Variable list.
|
Modifier and Type | Method and Description |
---|---|
void |
activityManagement(boolean m) |
void |
addChanged(Constraint c)
This function schedules given constraint for re-evaluation.
|
void |
addChanged(Var var,
int pruningEvent,
int info)
This function schedules all attached (not yet satisfied constraints) for
given variable for re-evaluation.
|
void |
afcManagement(boolean m) |
String |
checkInvariants()
It checks invariants to see if the execution went smoothly.
|
void |
clearChanged()
It clears the queue of constraints which need to be reevaluated usefull
if different scheme propagation scheme needs to be implemented.
|
void |
clearWatchedConstraint()
It removes all watches to constraints, therefore
constraints are no longer watched, no longer part of the model.
|
boolean |
consistency()
This function computes the consistency function.
|
void |
countConstraint()
This function is called when a counter of constraints should be
increased.
|
void |
countConstraint(int n)
This function is called when a counter of constraints should be increased
by given value.
|
int |
countWatches()
It returns number of watches which are used to watch constraints.
|
boolean |
deregisterReplacement(Replaceable<? extends Constraint> replacement)
It makes it possible to deregister the replacement.
|
void |
deregisterWatchedLiteralConstraint(Constraint c)
Watched constraint given as parameter is being removed, no variable will
be watching it.
|
void |
deregisterWatchedLiteralConstraint(Var v,
Constraint c)
Variable given as a parameter no longer watches constraint given as
parameter.
|
Var |
findVariable(String id)
This function looks for a variable with given id.
|
Set<Constraint> |
getConstraints() |
Constraint |
getCurrentConstraint()
This function returns the constraint which is currently reevaluated.
|
double |
getDecay() |
String |
getDescription()
This function returns the long description of the store.
|
Constraint |
getFirstChanged()
This function returns the constraint scheduled for re-evaluation.
|
String |
getName()
This function returns the id of the store.
|
static long |
getSeed() |
String |
getVariableIdPrefix()
This function returns the prefix of the automatically generated names for
noname variables.
|
void |
impose(Constraint c)
This function imposes a constraint to a store.
|
void |
impose(Constraint c,
int queueIndex)
This function imposes a constraint to a store.
|
void |
imposeDecomposition(DecomposedConstraint c)
This function imposes a decomposable constraint to a store.
|
void |
imposeDecomposition(DecomposedConstraint c,
int queueIndex)
This function imposes a constraint decomposition to a store.
|
void |
imposeDecompositionWithConsistency(DecomposedConstraint c)
In some special cases it may be beneficial to compute consistency of
constraint store immediately after the decomposed constraint is imposed.
|
void |
imposeWithConsistency(Constraint c)
In some special cases it may be beneficial to compute consistency of
constraint store immediately after the constraint is imposed.
|
void |
imposeWithConsistency(Constraint c,
int queueIndex)
In some special cases it may be beneficial to compute consistency of
constraint store immediately after the constraint is imposed.
|
boolean |
isGround()
This function checks if all variables within a store are grounded.
|
int |
numberConstraints()
This function returns the number of constraints.
|
void |
print()
This function prints the information of the store to standard output
stream.
|
int |
putMutableVar(MutableVar value)
Any constraint may have their own mutable variables which can be register
at store and then store will be responsible for calling appropriate
functions from MutableVar interface to keep the variables consistent with
the search.
|
int |
putMutableVar(Stateful value)
Any entity (for example constraints) may have their own mutable variables
(timestamps) which can be register at store and then store will be
responsible for calling appropriate functions from TimeStamp class to
keep the variables consistent with the search.
|
int |
putVariable(Var var)
This function is used to register a variable within a store.
|
void |
recordBooleanChange(BooleanVar recordedVariable)
Any boolean variable which is changed must be recorded by store, so it
can be restored to the previous state if backtracking is performed.
|
void |
recordChange(Var recordedVariable)
Any change of finite domain variable must also be recorded, so intervals
denoting changed variables can be updated.
|
boolean |
registerRemoveLevelLateListener(RemoveLevelLate c)
Any constraint in general may need information what variables have changed
since the last time a consistency was called.
|
boolean |
registerRemoveLevelListener(Stateful stateful)
Any constraint in general may need information what variables have changed
since the last time a consistency was called.
|
boolean |
registerReplacement(Replaceable<? extends Constraint> replacement)
It makes it possible to register replacement for a particular constraint
type.
|
void |
registerWatchedLiteralConstraint(Var v,
Constraint c)
It register variable to watch given constraint.
|
void |
removeLevel(int rLevel)
This important function removes all changes which has been recorded to
any variable at given level.
|
static void |
resetSeed() |
static boolean |
seedPresent() |
void |
setAllConstraints() |
void |
setDecay(double d) |
void |
setDescription(String description)
This function sets the long description of the store.
|
void |
setID(String id)
This function sets the id of the store.
|
void |
setLevel(int levelSetTo)
This function allows to proceed with the search, create new layer at
which new values for variables will be recorded.
|
static void |
setSeed(long s) |
void |
setVariableIdPrefix(String idPrefix)
This function sets the prefix of the automatically generated names for
noname variables.
|
int |
size()
It returns number of variables in a store.
|
void |
throwFailException(Var x)
It throws an exception after printing trace information if tracing is
switched on.
|
String |
toString()
This function returns a string a representation of the store.
|
String |
toStringChangedEl()
This function returns a string representation of the constraints pending
for re-evaluation.
|
String |
toStringOrderedVars() |
public static final FailException failException
public static final boolean debug
public SimpleHashSet<Constraint>[] changed
public BooleanVar[] changeHistory4BooleanVariables
public Set<Stateful> removeLevelListeners
public Set<RemoveLevelLate> removeLevelLateListeners
public List<Var> auxilaryVariables
public Constraint currentConstraint
public Constraint recentlyFailedConstraint
public int currentQueue
public String description
public String id
public int level
protected List<MutableVar> mutableVariables
public boolean propagationHasOccurred
protected int numberOfConstraints
public TimeStamp<Integer> pointer4GroundedBooleanVariables
public int queueNo
public boolean raiseLevelBeforeConsistency
public boolean variableWeightManagement
protected int size
public long numberConsistencyCalls
public boolean strict
public boolean isLastConsistencyFailure
protected List<Stateful> timeStamps
public Map<Var,Set<Constraint>> watchedConstraints
protected String variableIdPrefix
public Var[] vars
public BacktrackableManager trailManager
public Map<String,Var> variablesHashMap
public SparseSet sparseSet
public int sparseSetSize
public Store()
public Store(int size)
size
- specifies the initial number of variables.public void deregisterWatchedLiteralConstraint(Var v, Constraint c)
v
- variable at which constraint is no longer watching.c
- constraint which is no longer watched by given variable.public void deregisterWatchedLiteralConstraint(Constraint c)
c
- constraint for which all watches are removed.public int countWatches()
public void registerWatchedLiteralConstraint(Var v, Constraint c)
v
- variable which is used to watch the constraint.c
- the constraint being used.public void clearWatchedConstraint()
public void addChanged(Constraint c)
c
- constraint which needs reevaluation.public void addChanged(Var var, int pruningEvent, int info)
var
- variable for which some pruning event has occurred.pruningEvent
- specifies the type of the pruning event.info
- it specifies detailed information about the change of the variable domain.
the inputs of the currentConstraint in the manner that would validate another execution.public void clearChanged()
public boolean consistency()
public void countConstraint()
public void countConstraint(int n)
n
- integer by which the counter of constraints should be increased.public Var findVariable(String id)
id
- unique identifier of the variable.public Constraint getCurrentConstraint()
public String getDescription()
public Constraint getFirstChanged()
public String getName()
public String getVariableIdPrefix()
public void impose(Constraint c)
c
- constraint to be imposed.public void impose(Constraint c, int queueIndex)
c
- constraint to be added to specified queue.queueIndex
- specifies index of the queue for a constraint.public void imposeWithConsistency(Constraint c) throws FailException
c
- constraint to be imposed.FailException
- failure exception.public void imposeWithConsistency(Constraint c, int queueIndex) throws FailException
c
- constraint to be imposed.queueIndex
- constraint priority for evaluation.FailException
- failure exception.public void imposeDecomposition(DecomposedConstraint c)
c
- constraint to be imposed.public void imposeDecomposition(DecomposedConstraint c, int queueIndex)
c
- constraint to be added to specified queue.queueIndex
- specifies index of the queue for a constraint.public void imposeDecompositionWithConsistency(DecomposedConstraint c)
c
- decomposed constraint to be imposed.public boolean isGround()
public int numberConstraints()
public void print()
public int putMutableVar(MutableVar value)
value
- MutableVariable to be added and maintained by a store.public int putMutableVar(Stateful value)
value
- timestamp to be added and maintained by a store.public int putVariable(Var var)
var
- variable to be registered.public void recordBooleanChange(BooleanVar recordedVariable)
recordedVariable
- boolean variable which has changed.public void recordChange(Var recordedVariable)
recordedVariable
- variable which has changed.public boolean registerReplacement(Replaceable<? extends Constraint> replacement)
replacement
- that is being registered.public boolean deregisterReplacement(Replaceable<? extends Constraint> replacement)
replacement
- that is being deregister from within the constraint store.public boolean registerRemoveLevelListener(Stateful stateful)
stateful
- constraint which is interested in listening to remove level events.public boolean registerRemoveLevelLateListener(RemoveLevelLate c)
c
- constraint which is no longer interested in listening to remove level events.public void removeLevel(int rLevel)
rLevel
- Store level to be removed.public void setDescription(String description)
description
- description of the storepublic void setID(String id)
id
- store id.public void setLevel(int levelSetTo)
levelSetTo
- level number to which store is changing to.public void setVariableIdPrefix(String idPrefix)
idPrefix
- prefix of all variables with automatically generated names.public int size()
public void throwFailException(Var x)
x
- variable causing the failure exception.FailException
- is always thrown.public String toString()
public Set<Constraint> getConstraints()
public void setAllConstraints()
public void setDecay(double d)
public double getDecay()
public void afcManagement(boolean m)
public void activityManagement(boolean m)
public String toStringChangedEl()
public String checkInvariants()
public String toStringOrderedVars()
public static void setSeed(long s)
public static long getSeed()
public static boolean seedPresent()
public static void resetSeed()
Copyright © 2022. All rights reserved.