Class VariableLookUpTable

java.lang.Object
net.ssehub.easy.varModel.model.rewrite.VariableLookUpTable

class VariableLookUpTable extends Object
Part of the RewriteContext to speed up IDecisionVariable retrieval.
Author:
El-Sharkawy
  • Field Details

    • initialized

      private boolean initialized
    • instancesPerType

      private Map<IDatatype,Set<IDecisionVariable>> instancesPerType
      List of instances for a given IDatatype. Is used to speed up Configuration based IModelElementFilter. Contains toplevel and nested variables as well as annotations.
    • instancesPerDeclaration

      private Map<AbstractVariable,Set<IDecisionVariable>> instancesPerDeclaration
      List of instances for a given declaration. Is used to speed up Configuration based IModelElementFilter. Contains toplevel and nested variables as well as annotations.
    • constraintReusers

      private Map<AbstractVariable,Set<ContainableModelElement>> constraintReusers
      List model elements, reusing a constraint variable (declaration). A tuple in form of (Constraint Variable declaration, Set of reusing elements). For instance: Constraint cVar = ...; def Boolean func(Integer intVar) = cVar && ...;
    • definedDeclarations

      private Set<AbstractVariable> definedDeclarations
      List model elements, calling a constraint variable (declaration). A tuple in form of (Calling element Set of called constraint variables). Inverse to constraintReusers For instance: Constraint cVar = func(aVariable); def Boolean func(Integer intVar) = intVar > 10;
      See Also:
  • Constructor Details

    • VariableLookUpTable

      VariableLookUpTable()
      Single constructor for this class.
  • Method Details

    • init

      void init(Configuration config)
      Creates the internal look up tables and should be called if it is the first time used. Multiple calls will ignored.
      Parameters:
      config - The used configuration.
    • init

      private void init(IDecisionVariable variable)
      Recursive part of init(Configuration). Will add the variable as well as all nested variables and annotations. Adapt this method if further tables are needed.
      Parameters:
      variable - A IDecisionVariable of the configuration.
    • addVariable

      private void addVariable(IDecisionVariable variable, IDatatype type)
      Parameters:
      variable - The variable to add
      type - The type of the variable.
    • getInstancesForType

      Set<IDecisionVariable> getInstancesForType(IDatatype type)
      Returns the set of instances of the given IDatatype.
      Parameters:
      type - The exact IDatatype for which the instances shall be returned, will not consider IDatatype.isAssignableFrom(IDatatype).
      Returns:
      The instances for the given type or null if no instances exist.
    • getInstancesForDeclaration

      Set<IDecisionVariable> getInstancesForDeclaration(AbstractVariable declaration)
      Returns the set of instances of the given AbstractVariable declaration.
      Parameters:
      declaration - The declaration for which the instances shall be returned. If the declaration is nested inside a compound which was multiple times instantiated, this single declaration could return multiple IDecisionVariables.
      Returns:
      The instances for the given declaration or null if no instances exist.
    • declarationKnown

      boolean declarationKnown(AbstractVariable declaration)
      Checks whether the declaration is known or whether the declaration is a local declaration used as an iterator of a constraint. Needs that this VariableLookUpTable was already initialized with a Configuration.
      Parameters:
      declaration - The declaration to check.
      Returns:
      true if the declaration is used for a IDecisionVariable of the configuration or if this table was not initialized with a Configuration, false otherwise.
    • putConstraintOccurrence

      void putConstraintOccurrence(AbstractVariable constraintDecl, ContainableModelElement referringElement)
      Stores that the given constraint declaration was used inside the referring element.
      Parameters:
      constraintDecl - A constraint declaration used inside the second parameter.
      referringElement - An element which may use a constraint declaration as part of its own definition, e.g., another constraint declaration, a Constraint or a OperationDefinition.