Reasoner
Class ConstraintPropagator.Partition

java.lang.Object
  |
  +--Reasoner.ConstraintPropagator.Partition
Enclosing class:
ConstraintPropagator

private class ConstraintPropagator.Partition
extends java.lang.Object

Maintains the contents of a partition of object inferences that reference each other and no object inferences in other partitions.


Field Summary
 java.util.ArrayList adjacencies
           
 int partition_num
           
 
Constructor Summary
private ConstraintPropagator.Partition()
           
 
Method Summary
 void addAdjacency(ConstraintPropagator.Adjacency adjacency)
          Adds an adjacency to this partition.
private  void applyDOFAdjustments(ObjectInference object_inference, DOFAdjustmentNode dof_adjustment)
          Applies a degree-of-freedom adjustment (if present) to the position and/or attitude of an object inference.
private  void assignCardinalDirections()
          Assigns a random attitude to each object inference in this partition based on whether it has a constraint to face a cardinal direction.
private  void buildTransitiveClosure(ObjectInference source_object_inference, java.util.HashMap transitive_closures)
          Builds the transitive closure of the 'in' relation to indicate which object inferences may interpenetrate an object inference.
private  void buildTransitiveClosures()
          Builds the transitive closure of the 'in' relation to indicate which object inferences may interpenetrate each other.
private  boolean containsRelationship(ObjectInference object_inference1, ObjectInference object_inference2, java.lang.String relation_name)
          Returns whether two object inferences participate in a relationship (in either direction).
private  ConstraintPropagator.Adjacency getObjectInference(ObjectInference object_inference)
          Returns the first adjacency containing an object inference.
private  boolean isTransitivelyEnclosed(ObjectInference object_inference1, ObjectInference object_inference2)
          Returns whether two object inferences are linked through a transitive closure of the 'in' relation.
private  int propagate(int max_attempts)
          Propagates the constraints in this partition.
private  void resetPropagationStates()
          Resets the position and attitude states of all object inferences in this partition.
private  void sort(int sort_mode)
          Orders the object inferences in this partition.
 java.lang.String toString()
          Returns a string representation of this class.
private  boolean verifyNonInterpenetration(ObjectInference base_object_inference)
          Returns whether an object inference penetrates an other object inference when it is not allowed to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

adjacencies

public java.util.ArrayList adjacencies

partition_num

public int partition_num
Constructor Detail

ConstraintPropagator.Partition

private ConstraintPropagator.Partition()
Method Detail

addAdjacency

public void addAdjacency(ConstraintPropagator.Adjacency adjacency)
Adds an adjacency to this partition.

Parameters:
adjacency - - the adjacency

applyDOFAdjustments

private void applyDOFAdjustments(ObjectInference object_inference,
                                 DOFAdjustmentNode dof_adjustment)
Applies a degree-of-freedom adjustment (if present) to the position and/or attitude of an object inference.

Parameters:
object_inference - - the object inference
dof_adjustment - - the degree-of-freedom adjustment, which can be null

assignCardinalDirections

private void assignCardinalDirections()
                               throws java.lang.Exception
Assigns a random attitude to each object inference in this partition based on whether it has a constraint to face a cardinal direction.

Throws:
java.lang.Exception - - if the constrain is malformed

buildTransitiveClosure

private void buildTransitiveClosure(ObjectInference source_object_inference,
                                    java.util.HashMap transitive_closures)
Builds the transitive closure of the 'in' relation to indicate which object inferences may interpenetrate an object inference.

Parameters:
source_object_inference - - the object inference serving as the source of the closure
transitive_closures - - the list of closures to build. This is an in/out parameter

buildTransitiveClosures

private void buildTransitiveClosures()
Builds the transitive closure of the 'in' relation to indicate which object inferences may interpenetrate each other.


containsRelationship

private boolean containsRelationship(ObjectInference object_inference1,
                                     ObjectInference object_inference2,
                                     java.lang.String relation_name)
Returns whether two object inferences participate in a relationship (in either direction).

Parameters:
object_inference1 - - an object inference
object_inference2 - - an object inference
relation_name - - the relation
Returns:
the outcome

isTransitivelyEnclosed

private boolean isTransitivelyEnclosed(ObjectInference object_inference1,
                                       ObjectInference object_inference2)
Returns whether two object inferences are linked through a transitive closure of the 'in' relation.

Parameters:
object_inference1 - - the source object inference
object_inference2 - - the target object inference
Returns:
the outcome

getObjectInference

private ConstraintPropagator.Adjacency getObjectInference(ObjectInference object_inference)
Returns the first adjacency containing an object inference. This is normally used to determine whether the object inference is present in an adjacency by comparing the result against null.

Parameters:
object_inference - - the object inference to check for
Returns:
the adjacency, or null if the object inference is not present

propagate

private int propagate(int max_attempts)
               throws java.lang.Exception
Propagates the constraints in this partition. A solution is verified against all previously propagaged object inferences to prevent violations of the system-level selective non-interpenetration constraint.

Returns:
the number of propagations taken to reach a solution, or 0 if propagation failed
Throws:
java.lang.Exception - - if propagation fails

resetPropagationStates

private void resetPropagationStates()
Resets the position and attitude states of all object inferences in this partition.


sort

private void sort(int sort_mode)
Orders the object inferences in this partition.

Parameters:
sort_mode - - the ordering: 1 for descending by cardinality, 2 for ascending by cardinality, and 3 or higher for randomized. Literal values are used instead of constants to allow this to be driven by a counter

toString

public java.lang.String toString()
Returns a string representation of this class.

Overrides:
toString in class java.lang.Object
Returns:
the String representation

verifyNonInterpenetration

private boolean verifyNonInterpenetration(ObjectInference base_object_inference)
                                   throws java.lang.Exception
Returns whether an object inference penetrates an other object inference when it is not allowed to.

Parameters:
base_object_inference - - the object inference
Returns:
true if no interpenetration
Throws:
java.lang.Exception - - if verification fails (due to a developer error)