public class Geost extends Constraint implements UsesQueueVariable, Stateful, RemoveLevelLate
1) DONE. FlushAndQueue function should be changed and some functionality moved to firstConsistencyCheck.
2) DONE. No propagation inside queueVariable function.
3) DONE. How to incorporate GUI code within Geost constraint.
4) DONE. Move part of the functionality of onObjectUpdate to consistency function.
5) Refactor use of TimeBoundConstraint 5b) DONE. remove runTimeConstraint boolean variable.
6) DONE. asserts for Shape register 6b) asserts about possible values of MaxInt and MinInt.
7) DONE. Use simpleHashSet instead of LinkedHashSet for objectQueue.
8) DONE. Discuss pruning events, do we really need ANY for all variables? For example, maybe time variables always BOUND pruning event.
9) DONE. Simplify queueObject by removing if statements and make sure that this function is being called properly (avoid non-asserts checks inside it).
10) DONE. Discuss the possible implementation of satisfied function.
11) Introduce time switch so geost can work without time dimension.
12) Lessen the feature of geost that it does not work with variables used multiple times within different objects 12b) DONE. (at least for singleton variables).
13) DONE. Verify fix to address bug in case of multiple level removals, or level removals for which no consistency function has been called. Functionality around variable currentLevel. It is still needed.
14. DONE. Fixing a bug connected with timestamps and multiple remove levels calls. 14b Check lastLevelVar (possibly needs to be done similarly as setStart).
Future Work :
1. InArea should support subset of objects and dimensions.
2. Reuse previously generated outboxes. Create a function to create a hashkey from points coordinates for which an outbox is required. Later, for each new point we check if we have proper outbox for a given hash-key generated from this outbox.
3. Not always finishing at consistency fixpoint, speculative fixpoint.
4. consider polymorphism due to rotations only, and see if better performance can be reached under this assumption.
5. If objects have the same shape, and they are indistingushable then symmetry breaking can be employed.
Modifier and Type | Class and Description |
---|---|
static class |
Geost.SweepDirection |
Modifier and Type | Field and Description |
---|---|
boolean |
alwaysUseFrames
It defines whether outbox generation should always rely on overlapping frames.
|
boolean |
backtracking
It is a flag set to true during remove level late function execution so objects which
are being updated upon backtracking can be handled properly.
|
boolean |
enforceNoSkip
if set to true, a variable will never be skipped, even if grounded and not in queue
|
ExternalConstraint[] |
externalConstraints
It stores the reference to the collection of external constraints
which must be satisfied within this constraint.
|
boolean |
filterUseless
It specifies that filtering of useless internal constraint takes place
before an object is being pruned.
|
Collection<InternalConstraint> |
internalConstraints
It stores all generated internal constraints for all objects/constraints.
|
GeostObject[] |
objects
It stores the reference to the collection of objects provided to
the constructor.
|
LexicographicalOrder |
order
It specifies the order between dimensions which is used by the
pruning algorithm.
|
boolean |
partialShapeSweep
set to false to disable relaxed shape pruning
|
Shape[] |
shapeRegister
It stores information about shapes used by objects within this geost constraint.
|
protected Store |
store
It keeps a reference to the store.
|
atomicExecution, consistencyPruningEvents, constraintScope, earlyTerminationOK, increaseWeight, numberId, scope, trace
queueIndex
Constructor and Description |
---|
Geost(Collection<GeostObject> objects,
Collection<ExternalConstraint> constraints,
Collection<Shape> shapes) |
Geost(GeostObject[] objects,
ExternalConstraint[] constraints,
Shape[] shapes)
It creates a geost constraint from provided objects, external constraints,
as well as shapes.
|
Modifier and Type | Method and Description |
---|---|
String |
checkInvariants()
It checks that this constraint has consistent data structures.
|
void |
consistency(Store store)
It is a (most probably incomplete) consistency function which removes the
values from variables domains.
|
protected DBox |
findForbiddenDomain(GeostObject o,
int currentShape,
int[] point,
Geost.SweepDirection dir,
LexicographicalOrder order) |
protected void |
flushQueue(Collection<Var> variables)
It does the processing needed given the set of variables that was updated
between two consecutive calls to the consistency function.
|
protected void |
genInternalConstraints() |
int |
getConsistencyPruningEvent(Var var)
It retrieves the pruning event which causes reevaluation of the
constraint.
|
int |
getDefaultConsistencyPruningEvent() |
Shape |
getShape(int id)
It returns the shape with a given id if such exists.
|
List<Long> |
getStatistics()
It returns all the statistics gathered by geost constraint during the search.
|
void |
impose(Store store)
It imposes the constraint in a given store.
|
void |
increaseWeight()
It increases the weight of the variables in the constraint scope.
|
protected void |
onObjectUpdate(GeostObject o)
It performs the necessary operations for a given changed object.
|
protected int |
pruneMax(Store store,
GeostObject o,
int currentShape,
int d,
int limit)
the sweeping routine for minimal bounds.
|
protected int |
pruneMin(Store store,
GeostObject o,
int currentShape,
int d,
int limit)
the sweeping routine for minimal bounds.
|
void |
queueObject(GeostObject o)
It puts the object into the queue if it can be still pruned or cause failure.
|
void |
queueVariable(int level,
Var v)
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)
This function is called in case of the backtrack.
|
String |
toString()
It produces a string representation of a constraint state.
|
protected void |
updateInternalConstraintsGeneratingOutboxes(GeostObject o)
It is called whenever the object currently being pruned changes.
|
afc, arguments, cleanAfterFailure, decompose, getGuideConstraint, getGuideValue, getGuideVariable, grounded, grounded, id, impose, imposeDecomposition, intArrayToString, long2int, numberArgs, removeConstraint, requiresMonotonicity, setConsistencyPruningEvent, setConstraintScope, setScope, setScope, setScope, setScope, setScope, setWatchedVariableGrounded, supplyGuideFeedback, updateAFC, watchedVariableGrounded
auxiliaryVariables, checkInput, checkInput, checkInputForDuplication, checkInputForDuplicationSkipSingletons, checkInputForNullness, checkInputForNullness, checkInputForNullness, derivative, getDubletonsSkipSingletons, imposeDecomposition
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isStateful
public boolean enforceNoSkip
public boolean partialShapeSweep
public Collection<InternalConstraint> internalConstraints
public final LexicographicalOrder order
protected Store store
public final boolean filterUseless
public boolean alwaysUseFrames
public boolean backtracking
public final GeostObject[] objects
public final ExternalConstraint[] externalConstraints
public final Shape[] shapeRegister
public Geost(Collection<GeostObject> objects, Collection<ExternalConstraint> constraints, Collection<Shape> shapes)
public Geost(GeostObject[] objects, ExternalConstraint[] constraints, Shape[] shapes)
objects
- objects in the scope of the geost constraint.constraints
- the collection of external constraints enforced by geost.shapes
- the list of different shapes used by the objects in scope of the geost.public String checkInvariants()
public final Shape getShape(int id)
id
- the unique id of the shape we are looking for.protected void genInternalConstraints()
protected int pruneMin(Store store, GeostObject o, int currentShape, int d, int limit)
store
- the storeo
- the object to prunecurrentShape
- the shape of the objectd
- the current most significant dimensionlimit
- stop pruning if going beyond this valueprotected int pruneMax(Store store, GeostObject o, int currentShape, int d, int limit)
store
- the storeo
- the object to pruned
- the current most significant dimensioncurrentShape
- the shape of the objectlimit
- stop pruning if going beyond this valueprotected DBox findForbiddenDomain(GeostObject o, int currentShape, int[] point, Geost.SweepDirection dir, LexicographicalOrder order)
public void consistency(Store store)
Constraint
consistency
in class Constraint
store
- constraint store within which the constraint consistency is being checked.protected void updateInternalConstraintsGeneratingOutboxes(GeostObject o)
o
- the object currently being pruned for which internal constraints are being filtered.protected void flushQueue(Collection<Var> variables)
variables
- variables in the queuepublic final void queueObject(GeostObject o)
o
- the object which is possibly put into the queue.protected void onObjectUpdate(GeostObject o)
If the change occurred due to backtracking then only external constraints are being informed about the change, so they can restore proper state in connection to the object. If this function is not called during backtracking then also the following is executed.
If the change occurs due to search progress downwards then it stores the information about object change as well as schedules pruning check for all connected objects.
o
- the object which had a domain changepublic int getConsistencyPruningEvent(Var var)
Constraint
getConsistencyPruningEvent
in class Constraint
var
- variable for which pruning event is retrievedpublic int getDefaultConsistencyPruningEvent()
getDefaultConsistencyPruningEvent
in class Constraint
public void impose(Store store)
Constraint
impose
in class Constraint
store
- the constraint store to which the constraint is imposed to.public void increaseWeight()
Constraint
increaseWeight
in class Constraint
public void queueVariable(int level, Var v)
Constraint
queueVariable
in class Constraint
level
- the level of the store at which the change has occurred.v
- variable which has changed.public void removeLevel(int level)
Stateful
removeLevel
in interface Stateful
level
- the level which is being removed.public void removeLevelLate(int level)
RemoveLevelLate
removeLevelLate
in interface RemoveLevelLate
level
- the level which is being removed.public String toString()
Constraint
toString
in class Constraint
Copyright © 2022. All rights reserved.