Class VariablesMap

java.lang.Object
net.ssehub.easy.reasoning.sseReasoner.model.VariablesMap

public class VariablesMap extends 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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Map<net.ssehub.easy.varModel.model.Constraint,net.ssehub.easy.varModel.confModel.IDecisionVariable>
     
    private Map<net.ssehub.easy.varModel.model.AbstractVariable,Set<net.ssehub.easy.varModel.model.Constraint>>
     
    private Map<net.ssehub.easy.varModel.confModel.IDecisionVariable,List<net.ssehub.easy.varModel.model.Constraint>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Sole constructor initializing the map.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.varModel.model.Constraint constraint)
    Adds a relationship between variable and constraint.
    void
    addAll(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.reasoning.core.reasoner.ConstraintList constraints)
    Relates all constraints to the declaration of variable and the declarations of all parent variables of variable.
    void
    addAll(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.reasoning.core.reasoner.ConstraintList constraints)
    Relates all constraints to declaration.
    void
    Clears this instance for reuse.
    void
    Copies all registrations from map.
    List<net.ssehub.easy.varModel.model.Constraint>
    getConstraintsForVariable(net.ssehub.easy.varModel.confModel.IConfigurationElement variable)
    Returns the constraints registered for variable.
    net.ssehub.easy.varModel.confModel.IDecisionVariable
    getDecisionVariableForConstraint(net.ssehub.easy.varModel.model.Constraint constraint)
    Returns the decision variable for constraint.
    int
    Number of all variables found in constraints (should be replacesd by other method detecting nuber of variables in the model).
    Set<net.ssehub.easy.varModel.model.Constraint>
    getRelevantConstraints(net.ssehub.easy.varModel.model.AbstractVariable declaration)
    Returns all constraints, where the specifies declaration was used inside.
    private Set<net.ssehub.easy.varModel.model.Constraint>
    obtainConstraintSet(net.ssehub.easy.varModel.model.AbstractVariable declaration)
    Returns the constraint set for declaration.
    void
    registerConstraint(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.varModel.model.Constraint constraint)
    Registers constraint with constraint variable variable.
    void
    remove(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.varModel.model.Constraint constraint)
    Removes a relationship between variable and constraint.
    void
    removeAll(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, Collection<net.ssehub.easy.varModel.model.Constraint> constraints)
    Unrelates all constraints from the declaration of variable and all declarations of parent variables of variable.
    void
    removeAll(net.ssehub.easy.varModel.model.AbstractVariable declaration, Collection<net.ssehub.easy.varModel.model.Constraint> constraints)
    Unrelates all constraints from declaration.
    void
    unregisterConstraint(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.varModel.model.Constraint constraint)
    Unregisters a constraint from a decision variable.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • declConstraintMapping

      private Map<net.ssehub.easy.varModel.model.AbstractVariable,Set<net.ssehub.easy.varModel.model.Constraint>> declConstraintMapping
    • constraintVariableMap

      private Map<net.ssehub.easy.varModel.model.Constraint,net.ssehub.easy.varModel.confModel.IDecisionVariable> constraintVariableMap
    • variableConstraintsMap

      private Map<net.ssehub.easy.varModel.confModel.IDecisionVariable,List<net.ssehub.easy.varModel.model.Constraint>> variableConstraintsMap
  • Constructor Details

    • VariablesMap

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

    • add

      public void add(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.varModel.model.Constraint constraint)
      Adds a relationship between variable and constraint.
      Parameters:
      declaration - AbstractVariable to be added.
      constraint - Constraint that holds added declaration.
    • remove

      public void remove(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.varModel.model.Constraint constraint)
      Removes a relationship between variable and constraint.
      Parameters:
      declaration - AbstractVariable to be removed.
      constraint - Constraint that holds added declaration.
    • obtainConstraintSet

      private Set<net.ssehub.easy.varModel.model.Constraint> obtainConstraintSet(net.ssehub.easy.varModel.model.AbstractVariable declaration)
      Returns the constraint set for declaration.
      Parameters:
      declaration - the declaration
      Returns:
      the constraint set (may be null for none)
    • getRelevantConstraints

      public Set<net.ssehub.easy.varModel.model.Constraint> getRelevantConstraints(net.ssehub.easy.varModel.model.AbstractVariable declaration)
      Returns all constraints, where the specifies declaration was used inside.
      Parameters:
      declaration - A declaration for which all constraints 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.
    • addAll

      public void addAll(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.reasoning.core.reasoner.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(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.reasoning.core.reasoner.ConstraintList constraints)
      Relates all constraints to declaration.
      Parameters:
      declaration - the declaration to relate to
      constraints - the constraints to relate
    • removeAll

      public void removeAll(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, Collection<net.ssehub.easy.varModel.model.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(net.ssehub.easy.varModel.model.AbstractVariable declaration, Collection<net.ssehub.easy.varModel.model.Constraint> constraints)
      Unrelates all constraints from declaration.
      Parameters:
      declaration - the declaration to relate to
      constraints - the constraints to relate
    • registerConstraint

      public void registerConstraint(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.varModel.model.Constraint constraint)
      Registers constraint with constraint variable variable.
      Parameters:
      variable - the variable
      constraint - the constraint
    • unregisterConstraint

      public void unregisterConstraint(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.varModel.model.Constraint constraint)
      Unregisters a constraint from a decision variable.
      Parameters:
      variable - the variable
      constraint - the constraint
    • getConstraintsForVariable

      public List<net.ssehub.easy.varModel.model.Constraint> getConstraintsForVariable(net.ssehub.easy.varModel.confModel.IConfigurationElement variable)
      Returns the constraints registered for variable.
      Parameters:
      variable - the variable
      Returns:
      the constraints (may be null)
    • getDecisionVariableForConstraint

      public net.ssehub.easy.varModel.confModel.IDecisionVariable getDecisionVariableForConstraint(net.ssehub.easy.varModel.model.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