Class Regular
- All Implemented Interfaces:
RemoveLevelLate
,Stateful
,UsesQueueVariable
- Version:
- 4.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionTime-stamp for the number of active states in each level.private int[]
private int
This is the counter of save-to-latex calls.(package private) List
<Constraint> private int
static final boolean
It specifies if debugging information should be printed out.dNames contain a "name" for each value from the union of all variabl's domains.(package private) boolean
Consistency function call the prune arc function for every pruned variable and collect information about the levels that had some changes in "levelHadChaged" array Then it collect the values of the edges that are still active on the levels that had chages and update the domains of the variables.(package private) int
It specifies finite state machine used by this regular.(package private) static AtomicInteger
(package private) int[]
Name of the file to store the latex output after consistency call The output will be : file_name + "call number" + ".tex"The ith smallest level of Layered Graph which have changed.private Integer
(package private) boolean[]
IntVar[]
Array of the variables of the graph levels.boolean
It specifies if the edges should have a list of values associated with them.boolean
It specifies if the support functionality should be used.final boolean
It specifies if the translation of FSM into optimized MDD should take place so minimal layered graph can be obtained.The ith largest level of Layered Graph which have changed.private Integer
static final boolean
It specifies if constraint description should be saved to latex for later viewing.private RegState[][]
Stores the states of all graph levels.(package private) int
Number of states in the graph used only during the printing to latex function.It keeps for each variable value pair a current support.The position of the currentTouchedIndex.(package private) RegState[]
(package private) LinkedHashSet
<IntVar> Queue of changed variables.Fields inherited from class org.jacop.constraints.Constraint
atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, trace
Fields inherited from class org.jacop.constraints.DecomposedConstraint
queueIndex
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
void
consistency
(Store store) It is a (most probably incomplete) consistency function which removes the values from variables domains.It returns an array list of constraint which are used to decompose this constraint.void
disableState
(int level, int pos) It marks state as being not active.int
getState
(int level, int id) Find the state with the corresponding id.void
It imposes the constraint in a given store.void
imposeDecomposition
(Store store) It imposes the decomposition of the given constraint in a given store.private void
initializeARRAY
(FSM dfa) Initialization phase of the algorithm.private void
initializeARRAY
(MDD mdd) Initialization phase of the algorithm.void
pruneArc
(int varIndex) Collects the damaged states, after pruning the domain of variable "var", and put these states in two separated sets.void
queueVariable
(int level, Var var) This is a function called to indicate which variable in a scope of constraint has changed.void
removeLevel
(int level) This function is called in case of the backtrack, so a constraint can clear the queue of changed variables which is no longer valid.void
removeLevelLate
(int level) Sweep the graph upon backtracking.void
saveLatexToFile
(String desc) It saves the constraint latex description into file.void
setLatexBaseFileName
(String filename) It sets the filename for the file which is used to save latex descriptions.It creates a latex description of the constraint state.toString()
It produces a string representation of a constraint state.int
unreachBackwardLoop
(int sucPrevLimit, int level) It does backward check to remove inactive edges and states.void
unreachForwardLoop
(int end, int level) Forward part deletes the outgoing edges of the damaged state and watch whether the successors are still active (in-degree > 0 ), otherwise we collect it and continue the loop.void
uppendToLatexFile
(String desc, String fileName) It appends latex description of the constraint current state to the specified filename.Methods inherited from class org.jacop.constraints.Constraint
afc, arguments, cleanAfterFailure, getConsistencyPruningEvent, getGuideConstraint, getGuideValue, getGuideVariable, grounded, grounded, id, impose, increaseWeight, intArrayToString, long2int, numberArgs, removeConstraint, requiresMonotonicity, setConsistencyPruningEvent, setConstraintScope, setScope, setScope, setScope, setScope, setScope, setWatchedVariableGrounded, supplyGuideFeedback, updateAFC, watchedVariableGrounded
Methods inherited from class org.jacop.constraints.DecomposedConstraint
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecomposition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jacop.api.Stateful
isStateful
-
Field Details
-
debugAll
public static final boolean debugAllIt specifies if debugging information should be printed out.- See Also:
-
saveAllToLatex
public static final boolean saveAllToLatexIt specifies if constraint description should be saved to latex for later viewing.- See Also:
-
optimizedMDD
public final boolean optimizedMDDIt specifies if the translation of FSM into optimized MDD should take place so minimal layered graph can be obtained. This option most of the time causes out of memory exception as it requires finding and storing all solutions in mtrie before translation to an optimized MDD can take place. FSM also has to be a deterministic one.- See Also:
-
latexFile
Name of the file to store the latex output after consistency call The output will be : file_name + "call number" + ".tex" -
calls
private int callsThis is the counter of save-to-latex calls. -
dNames
dNames contain a "name" for each value from the union of all variabl's domains. If Hashmap - dNames - is not null then upon saving the latex graph the values on the edges will be replaced with their "names". -
leftChange
The ith smallest level of Layered Graph which have changed. -
rightChange
The ith largest level of Layered Graph which have changed. -
touchedIndex
The position of the currentTouchedIndex. -
stateLevels
Stores the states of all graph levels. -
activeLevels
Time-stamp for the number of active states in each level. -
activeLevelsTemp
private int[] activeLevelsTemp -
stateNumber
int stateNumberNumber of states in the graph used only during the printing to latex function. -
variableQueue
LinkedHashSet<IntVar> variableQueueQueue of changed variables. TODO try to use PriorityQueue based on the number of states for a given variable or a domain size to pickup first variables which may result in failure faster. It does not have to be fully correct ordering. -
mapping
-
idNumber
-
supports
It keeps for each variable value pair a current support. -
listRepresentation
public boolean listRepresentationIt specifies if the edges should have a list of values associated with them. -
oneSupport
public boolean oneSupportIt specifies if the support functionality should be used. -
leftPosition
-
rightPosition
-
firstConsistencyCheck
boolean firstConsistencyCheckConsistency function call the prune arc function for every pruned variable and collect information about the levels that had some changes in "levelHadChaged" array Then it collect the values of the edges that are still active on the levels that had chages and update the domains of the variables. -
levelHadChanged
boolean[] levelHadChanged -
firstConsistencyLevel
int firstConsistencyLevel -
constraints
List<Constraint> constraints -
touchedStates
RegState[] touchedStates -
currentTouchedIndex
private int currentTouchedIndex -
fsm
It specifies finite state machine used by this regular. -
list
Array of the variables of the graph levels. -
lastNumberOfActiveStates
int[] lastNumberOfActiveStates
-
-
Constructor Details
-
Regular
Constructor need Store to initialize the time-stamps.- Parameters:
fsm
- (deterministic) finite automatonlist
- variables which values have to be accepted by the automaton.
-
-
Method Details
-
initializeARRAY
Initialization phase of the algorithm.Considering that it needs to initialize the array of graph States - stateLevels, and, thus, it needs to know the actual number of the states on each level I found nothing better then run the initialization phase with the complete NxN array of states and then copy the useful ones into a final array (which is ugly)
- Parameters:
dfa
- specification of deterministic finite automaton.
-
getState
Find the state with the corresponding id.- Parameters:
level
- specifies the variable for which the state is seeked for.id
- specifies the id of the state.- Returns:
- the state at given level with a given id.
-
pruneArc
public void pruneArc(int varIndex) Collects the damaged states, after pruning the domain of variable "var", and put these states in two separated sets.One with the states with zero incoming degree - these are the candidates for the forward part. The other set consists of states with zero out-coming degree - these are the candidates for backward part.
- Parameters:
varIndex
- the index of the variable which have changed.
-
addTouchedState
-
unreachBackwardLoop
public int unreachBackwardLoop(int sucPrevLimit, int level) It does backward check to remove inactive edges and states.- Parameters:
sucPrevLimit
- previous number of states at a given level.level
- level for which the backward sweep is computed.- Returns:
- level at which the sweep has ended. TODO return value is not used.
-
unreachForwardLoop
public void unreachForwardLoop(int end, int level) Forward part deletes the outgoing edges of the damaged state and watch whether the successors are still active (in-degree > 0 ), otherwise we collect it and continue the loop. TODO return value is not used.- Parameters:
end
- the position of the last active state at a given level.level
- level being examined.
-
disableState
public void disableState(int level, int pos) It marks state as being not active.- Parameters:
level
- level at which the state is residing.pos
- position of the state in the array of states.
-
removeLevel
public void removeLevel(int level) Description copied from interface:Stateful
This function is called in case of the backtrack, so a constraint can clear the queue of changed variables which is no longer valid. This function is called *before* all timestamps, variables, mutablevariables have reverted to their previous value.- Specified by:
removeLevel
in interfaceStateful
- Parameters:
level
- the level which is being removed.
-
removeLevelLate
public void removeLevelLate(int level) Sweep the graph upon backtracking.- Specified by:
removeLevelLate
in interfaceRemoveLevelLate
- Parameters:
level
- the level which is being removed.
-
queueVariable
Description copied from class:Constraint
This is a function called to indicate which variable in a scope of constraint has changed. It also indicates a store level at which the change has occurred.- Overrides:
queueVariable
in classConstraint
- Parameters:
level
- the level of the store at which the change has occurred.var
- variable which has changed.
-
consistency
Description copied from class:Constraint
It is a (most probably incomplete) consistency function which removes the values from variables domains. Only values which do not have any support in a solution space are removed.- Specified by:
consistency
in classConstraint
- Parameters:
store
- constraint store within which the constraint consistency is being checked.
-
impose
Description copied from class:Constraint
It imposes the constraint in a given store.- Overrides:
impose
in classConstraint
- Parameters:
store
- the constraint store to which the constraint is imposed to.
-
getDefaultConsistencyPruningEvent
public int getDefaultConsistencyPruningEvent()- Specified by:
getDefaultConsistencyPruningEvent
in classConstraint
-
toString
Description copied from class:Constraint
It produces a string representation of a constraint state.- Overrides:
toString
in classConstraint
-
imposeDecomposition
Description copied from class:Constraint
It imposes the decomposition of the given constraint in a given store.- Overrides:
imposeDecomposition
in classConstraint
- Parameters:
store
- the constraint store to which the constraint is imposed to.
-
decompose
Description copied from class:Constraint
It returns an array list of constraint which are used to decompose this constraint. It actually creates a decomposition (possibly also creating variables), but it does not impose the constraint.- Overrides:
decompose
in classConstraint
- Parameters:
store
- the constraint store in which context the decomposition takes place.- Returns:
- an array list of constraints used to decompose this constraint.
-
toLatex
It creates a latex description of the constraint state.- Parameters:
addDescription
- added description.- Returns:
- description of the constraint state.
-
saveLatexToFile
It saves the constraint latex description into file.- Parameters:
desc
- description of the constraint
-
setLatexBaseFileName
It sets the filename for the file which is used to save latex descriptions.- Parameters:
filename
- the name of the file
-
uppendToLatexFile
It appends latex description of the constraint current state to the specified filename.- Parameters:
desc
- appended description.fileName
- filename where the description is appended.
-
initializeARRAY
Initialization phase of the algorithm.Considering that it needs to initialize the array of graph States - stateLevels, and, thus, it needs to know the actual number of the states on each level I found nothing better then run the initialization phase with the complete NxN array of states and then copy the useful ones into a final array (which is ugly)
-