Class VariablesMap
java.lang.Object
net.ssehub.easy.reasoning.sseReasoner.model.VariablesMap
Represents all variable and constraint relationships. This class consists of two three mappings:
- All variable declarations used in constraints (
declConstraintMapping). - Constraint - decision variable relations
- Constraint assigned to a constraint decision variable {
constraintVariableMap} - decision variables assigned to constraints, multiple in case of collections
(
variableConstraintsMap}
- Constraint assigned to a constraint decision variable {
- Author:
- sizonenko, Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.varModel.model.Constraint constraint) Adds a relationship between variable and constraint.voidaddAll(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.reasoning.core.reasoner.ConstraintList constraints) Relates allconstraintsto the declaration ofvariableand the declarations of all parent variables ofvariable.voidaddAll(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.reasoning.core.reasoner.ConstraintList constraints) Relates allconstraintstodeclaration.voidclear()Clears this instance for reuse.voidcopyFrom(VariablesMap map) Copies all registrations frommap.List<net.ssehub.easy.varModel.model.Constraint> getConstraintsForVariable(net.ssehub.easy.varModel.confModel.IConfigurationElement variable) Returns the constraints registered forvariable.net.ssehub.easy.varModel.confModel.IDecisionVariablegetDecisionVariableForConstraint(net.ssehub.easy.varModel.model.Constraint constraint) Returns the decision variable forconstraint.intNumber 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 specifiesdeclarationwas used inside.private Set<net.ssehub.easy.varModel.model.Constraint> obtainConstraintSet(net.ssehub.easy.varModel.model.AbstractVariable declaration) Returns the constraint set fordeclaration.voidregisterConstraint(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.varModel.model.Constraint constraint) Registersconstraintwith constraint variablevariable.voidremove(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.varModel.model.Constraint constraint) Removes a relationship between variable and constraint.voidremoveAll(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, Collection<net.ssehub.easy.varModel.model.Constraint> constraints) Unrelates allconstraintsfrom the declaration ofvariableand all declarations of parent variables ofvariable.voidremoveAll(net.ssehub.easy.varModel.model.AbstractVariable declaration, Collection<net.ssehub.easy.varModel.model.Constraint> constraints) Unrelates allconstraintsfromdeclaration.voidunregisterConstraint(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.varModel.model.Constraint constraint) Unregisters a constraint from a decision variable.
-
Field Details
-
declConstraintMapping
-
constraintVariableMap
private Map<net.ssehub.easy.varModel.model.Constraint,net.ssehub.easy.varModel.confModel.IDecisionVariable> constraintVariableMap -
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-AbstractVariableto be added.constraint-Constraintthat holds addeddeclaration.
-
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-AbstractVariableto be removed.constraint-Constraintthat holds addeddeclaration.
-
obtainConstraintSet
private Set<net.ssehub.easy.varModel.model.Constraint> obtainConstraintSet(net.ssehub.easy.varModel.model.AbstractVariable declaration) Returns the constraint set fordeclaration.- 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 specifiesdeclarationwas 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 allconstraintsto the declaration ofvariableand the declarations of all parent variables ofvariable.- Parameters:
variable- the variable to relate toconstraints- the constraints to relate
-
addAll
public void addAll(net.ssehub.easy.varModel.model.AbstractVariable declaration, net.ssehub.easy.reasoning.core.reasoner.ConstraintList constraints) Relates allconstraintstodeclaration.- Parameters:
declaration- the declaration to relate toconstraints- the constraints to relate
-
removeAll
public void removeAll(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, Collection<net.ssehub.easy.varModel.model.Constraint> constraints) Unrelates allconstraintsfrom the declaration ofvariableand all declarations of parent variables ofvariable.- Parameters:
variable- the variable to relate toconstraints- the constraints to unrelate
-
removeAll
public void removeAll(net.ssehub.easy.varModel.model.AbstractVariable declaration, Collection<net.ssehub.easy.varModel.model.Constraint> constraints) Unrelates allconstraintsfromdeclaration.- Parameters:
declaration- the declaration to relate toconstraints- the constraints to relate
-
registerConstraint
public void registerConstraint(net.ssehub.easy.varModel.confModel.IDecisionVariable variable, net.ssehub.easy.varModel.model.Constraint constraint) Registersconstraintwith constraint variablevariable.- Parameters:
variable- the variableconstraint- 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 variableconstraint- the constraint
-
getConstraintsForVariable
public List<net.ssehub.easy.varModel.model.Constraint> getConstraintsForVariable(net.ssehub.easy.varModel.confModel.IConfigurationElement variable) Returns the constraints registered forvariable.- 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 forconstraint.- Parameters:
constraint- the constraint to return the assigned decision variable for- Returns:
- the decision variable or null for none
-
copyFrom
Copies all registrations frommap.- Parameters:
map- the map to copy from
-