Class VariablesMap


  • public class VariablesMap
    extends java.lang.Object
    Represents all variable and constraint relationships. This class consists of two three mappings:
    1. All variable declarations used in constraints (declConstraintMapping).
    2. Constraint - decision variable relations
      1. Constraint assigned to a constraint decision variable {constraintVariableMap}
      2. decision variables assigned to constraints, multiple in case of collections (variableConstraintsMap}
    Both kinds of relationships are maintained independently, whereby both constraint-decision variable relations are managed together to ensure consistency.
    Author:
    sizonenko, Holger Eichelberger
    • Constructor Detail

      • VariablesMap

        public VariablesMap()
        Sole constructor initializing the map.
    • Method Detail

      • obtainConstraintSet

        private java.util.Set<Constraint> obtainConstraintSet​(AbstractVariable declaration)
        Returns the constraint set for declaration.
        Parameters:
        declaration - the declaration
        Returns:
        the constraint set (may be null for none)
      • getRelevantConstraints

        public java.util.Set<Constraint> getRelevantConstraints​(AbstractVariable declaration)
        Returns all constraints, where the specifies declaration was used inside.
        Parameters:
        declaration - A declaration for which all constaints using this declaration should be returned. Must not be null.
        Returns:
        The list of all constraints where the declaration was used, maybe null if it was never used.
      • getDeclarationSize

        public int getDeclarationSize()
        Number of all variables found in constraints (should be replacesd by other method detecting nuber of variables in the model).
        Returns:
        Number of variables found in constaints.
      • clear

        public void clear()
        Clears this instance for reuse.
        See Also:
        #clearConstraintVariables()
      • addAll

        public void addAll​(IDecisionVariable variable,
                           ConstraintList constraints)
        Relates all constraints to the declaration of variable and the declarations of all parent variables of variable.
        Parameters:
        variable - the variable to relate to
        constraints - the constraints to relate
      • addAll

        public void addAll​(AbstractVariable declaration,
                           ConstraintList constraints)
        Relates all constraints to declaration.
        Parameters:
        declaration - the declaration to relate to
        constraints - the constraints to relate
      • removeAll

        public void removeAll​(IDecisionVariable variable,
                              java.util.Collection<Constraint> constraints)
        Unrelates all constraints from the declaration of variable and all declarations of parent variables of variable.
        Parameters:
        variable - the variable to relate to
        constraints - the constraints to unrelate
      • removeAll

        public void removeAll​(AbstractVariable declaration,
                              java.util.Collection<Constraint> constraints)
        Unrelates all constraints from declaration.
        Parameters:
        declaration - the declaration to relate to
        constraints - the constraints to relate
      • registerConstraint

        public void registerConstraint​(IDecisionVariable variable,
                                       Constraint constraint)
        Registers constraint with constraint variable variable.
        Parameters:
        variable - the variable
        constraint - the constraint
      • unregisterConstraint

        public void unregisterConstraint​(IDecisionVariable variable,
                                         Constraint constraint)
        Unregisters a constraint from a decision variable.
        Parameters:
        variable - the variable
        constraint - the constraint
      • getConstraintsForVariable

        public java.util.List<Constraint> getConstraintsForVariable​(IConfigurationElement variable)
        Returns the constraints registered for variable.
        Parameters:
        variable - the variable
        Returns:
        the constraints (may be null)
      • getDecisionVariableForConstraint

        public IDecisionVariable getDecisionVariableForConstraint​(Constraint constraint)
        Returns the decision variable for constraint.
        Parameters:
        constraint - the constraint to return the assigned decision variable for
        Returns:
        the decision variable or null for none
      • copyFrom

        public void copyFrom​(VariablesMap map)
        Copies all registrations from map.
        Parameters:
        map - the map to copy from