Package org.jacop.core
Class SimpleBacktrackableManager
java.lang.Object
org.jacop.core.SimpleBacktrackableManager
- All Implemented Interfaces:
BacktrackableManager
- Direct Known Subclasses:
IntervalBasedBacktrackableManager
It is responsible of remembering what variables have changed at given
store level.
- Version:
- 4.10
-
Field Summary
FieldsModifier and TypeFieldDescriptionintIt specifies the current level which is active in the manager.booleanIt specifies if for the current level we have reached the cutoff value.(package private) SparseSetIt contains indexes of objects changed at active level.(package private) intIt specifies the cutoff value after which a trail is no longer stored and recovery of the old state is done by informing all the variables about the backtracking.(package private) final booleanIt specifies if the debugging information should be displayed.(package private) final int[]It is a fake variable to distinguish between empty levels and full levels.(package private) final int[]It is a fake variable to disinguish between full levels and empty ones.It specifies the levels of the store for which trails are stored.(package private) intIt specifies the actual number of objects in the objects array.It stores objects which change has to be restored upon backtracking.(package private) List<int[]> It specifies a trail.booleanIt specifies if for the current level the all changes are already stored in the trail. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleBacktrackableManager(Backtrackable[] vars, int noOfObjects) It constructs a trail manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChanged(int index) It allows to inform the manager that a given item with id (index) has changed at given level.intgetLevel()It returns the current level at which the changes are being registered.booleanisRecognizedAsChanged(int index) It allows for easy testing if a given object is considered by the manager as the object which has changed and needs being informed about backtracking.voidremoveLevel(int removedLevel) It allows to inform all objects which have changed at removedLevel that the backtracking from that level has occurred.voidsetLevel(int level) It specifies the level which should become the active one in the manager.voidsetSize(int size) It specifies how many objects within objects array are being actually managed.toString()voidupdate(Backtrackable[] objects, int noOfObjects) It updates the manager with new array of objects to manage and new number of them.
-
Field Details
-
currentLevel
public int currentLevelIt specifies the current level which is active in the manager. -
noOfObjects
int noOfObjectsIt specifies the actual number of objects in the objects array. -
currentlyChanged
SparseSet currentlyChangedIt contains indexes of objects changed at active level. It may be empty if trailContainsAllChanges is set to true. -
trail
List<int[]> trailIt specifies a trail. A recorded changes which will be used upon backtracking to inform the objects about backtracking. -
levelInfo
It specifies the levels of the store for which trails are stored. -
cutOffValue
int cutOffValueIt specifies the cutoff value after which a trail is no longer stored and recovery of the old state is done by informing all the variables about the backtracking. -
objects
It stores objects which change has to be restored upon backtracking. The positions of objects will be stored by the manager and all changed objects will have their function removeLevel() be called. -
trailContainsAllChanges
public boolean trailContainsAllChangesIt specifies if for the current level the all changes are already stored in the trail. This situation occurs after each backtrack. If new changes are added then this flag indicates that trail has to be used. -
currentLevelMax
public boolean currentLevelMaxIt specifies if for the current level we have reached the cutoff value. -
emptyLevel
final int[] emptyLevelIt is a fake variable to distinguish between empty levels and full levels. -
fullLevel
final int[] fullLevelIt is a fake variable to disinguish between full levels and empty ones. -
debug
final boolean debugIt specifies if the debugging information should be displayed.- See Also:
-
-
Constructor Details
-
SimpleBacktrackableManager
It constructs a trail manager.- Parameters:
vars- it specifies the list of objects being managed.noOfObjects- it specifies number of objects being managed.
-
-
Method Details
-
addChanged
public void addChanged(int index) It allows to inform the manager that a given item with id (index) has changed at given level.- Specified by:
addChangedin interfaceBacktrackableManager- Parameters:
index- it specifies the index of the object which has changed.
-
setLevel
public void setLevel(int level) It specifies the level which should become the active one in the manager.- Specified by:
setLevelin interfaceBacktrackableManager- Parameters:
level- the active level at which the changes will be recorded.
-
removeLevel
public void removeLevel(int removedLevel) It allows to inform all objects which have changed at removedLevel that the backtracking from that level has occurred.- Specified by:
removeLevelin interfaceBacktrackableManager- Parameters:
removedLevel- it specifies the level which is being removed.
-
setSize
public void setSize(int size) It specifies how many objects within objects array are being actually managed. It allows to specify partially empty array.- Specified by:
setSizein interfaceBacktrackableManager- Parameters:
size- the number of objects in the array.
-
toString
-
isRecognizedAsChanged
public boolean isRecognizedAsChanged(int index) It allows for easy testing if a given object is considered by the manager as the object which has changed and needs being informed about backtracking.- Specified by:
isRecognizedAsChangedin interfaceBacktrackableManager- Parameters:
index- the position of the object which status is in question.- Returns:
- it returns true if the manager recognizes object at position index as changed one.
-
getLevel
public int getLevel()Description copied from interface:BacktrackableManagerIt returns the current level at which the changes are being registered.- Specified by:
getLevelin interfaceBacktrackableManager- Returns:
- the active level for which the changes are being registered.
-
update
Description copied from interface:BacktrackableManagerIt updates the manager with new array of objects to manage and new number of them. This function works properly only during model creation phase, so manager can learn about freshly created objects. If used during search then the old array must be part of the new array to allow manager work properly.- Specified by:
updatein interfaceBacktrackableManager- Parameters:
objects- a new array of objectsnoOfObjects- number of objects in the new array to be taken care of.
-