public class Store extends Object
Modifier and Type | Field and Description |
---|---|
ArrayList<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.
|
int |
level
It specifies the time point in the search.
|
protected ArrayList<MutableVar> |
mutableVariables
A mutable variable is a special variable which can change value during
the search.
|
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.
|
protected boolean |
removeConstraints
It specifies if evaluated constraint should be checked for satisfiability
and removed if it occurs.
|
ArrayList<Constraint> |
removeLevelLateListeners
More advanced constraints may require to be informed of a backtrack to be
able to recover the older versions of the data structures.
|
ArrayList<Constraint> |
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.
|
protected ArrayList<TimeStamp<?>> |
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.
|
HashMap<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.
|
HashMap<Var,HashSet<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 |
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.
|
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 |
deRegisterRemoveLevelListener(Constraint C)
This function deregisters a constraint from the listeners queue.
|
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.
|
int |
findPositionForInsert(int[] tuple)
searches for the position of the tuple in the tuple list.
|
Var |
findVariable(String id)
This function looks for a variable with given id.
|
boolean |
getCheckSatisfiability()
If a constraint is checked for satisfiability and it is satisfied then
it will not be attached to a variable anymore.
|
Constraint |
getCurrentConstraint()
This function returns the constraint which is currently reevaluated.
|
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.
|
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.
|
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(TimeStamp<?> 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.
|
int[][] |
recordTuples(int[][] ts)
It recordTuples to store so tuples can be reused across multiple
extensional constraints.
|
boolean |
registerRemoveLevelLateListener(Constraint C)
Any constraint in general may need information what variables have changed
since the last time a consistency was called.
|
boolean |
registerRemoveLevelListener(Constraint C)
Any constraint in general may need information what variables have changed
since the last time a consistency was called.
|
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.
|
ArrayList<Constraint> |
select(Class<Constraint> classname)
It selects constraints of a given type from queue changed.
|
void |
setCheckSatisfiability(boolean value)
It decides if constraints are checked for satisfiability.
|
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.
|
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.
|
boolean |
smallerEqualTuple(int[] left,
int[] right)
It compares tuples.
|
int[][] |
sortTuples(int[][] ts) |
void |
sortTuplesWithin(int[][] ts)
It sorts tuples.
|
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.
|
void |
trim()
This function trims the store.
|
public static final FailException failException
public static final boolean debug
public SimpleHashSet<Constraint>[] changed
public BooleanVar[] changeHistory4BooleanVariables
public ArrayList<Constraint> removeLevelListeners
public ArrayList<Constraint> removeLevelLateListeners
public ArrayList<Var> auxilaryVariables
public Constraint currentConstraint
public Constraint recentlyFailedConstraint
public int currentQueue
public String description
public String id
public int level
protected ArrayList<MutableVar> mutableVariables
public boolean propagationHasOccurred
protected int numberOfConstraints
public TimeStamp<Integer> pointer4GroundedBooleanVariables
public int queueNo
public boolean raiseLevelBeforeConsistency
protected boolean removeConstraints
public boolean variableWeightManagement
protected int size
protected ArrayList<TimeStamp<?>> timeStamps
public HashMap<Var,HashSet<Constraint>> watchedConstraints
protected String variableIdPrefix
public Var[] vars
public BacktrackableManager trailManager
public HashMap<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 boolean deRegisterRemoveLevelListener(Constraint C)
C
- constraint which no longer needs to be removed when level is removed.public Var findVariable(String id)
id
- unique identifier of the variable.public boolean getCheckSatisfiability()
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 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(TimeStamp<?> 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 registerRemoveLevelListener(Constraint C)
C
- constraint which is no longer interested in listening to remove level events.public boolean registerRemoveLevelLateListener(Constraint 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 setCheckSatisfiability(boolean value)
value
- boolean value specifying if check for satisfiability should be performed.public void setDescription(String description)
description
- public 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 String toStringChangedEl()
public void trim()
public ArrayList<Constraint> select(Class<Constraint> classname)
classname
- specifies the classname.public int[][] recordTuples(int[][] ts)
ts
- tuples to be recorded.public int findPositionForInsert(int[] tuple)
tuple
- to be compared to.public int[][] sortTuples(int[][] ts)
ts
- tuples to be sorted.public void sortTuplesWithin(int[][] ts)
ts
- tuples to be sorted.public boolean smallerEqualTuple(int[] left, int[] right)
left
- tuple to be compared to.right
- tuple to compar with.public String checkInvariants()
Copyright © 2015. All rights reserved.