Class Configuration
- java.lang.Object
-
- net.ssehub.easy.varModel.confModel.Configuration
-
- All Implemented Interfaces:
java.lang.Iterable<IDecisionVariable>,IModelListener<Project>,IConfiguration,IConfigurationElement,IConfigurationVisitable,IProjectListener
- Direct Known Subclasses:
AttributeValuesPage.TemporaryAttributesConfiguration
public class Configuration extends java.lang.Object implements IConfigurationVisitable, IProjectListener, java.lang.Iterable<IDecisionVariable>, IConfigurationElement, IConfiguration
Represents a configuration, i.e. a set of decision variables.- Author:
- Holger Eichelberger, El-Sharkawy, Marcel Lueder
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<IDatatype,java.util.Map<IDecisionVariable,ReferenceValue>>allInstancesprivate booleanapproximativeFreezingprivate booleanassignValuesprivate QueryCachecacheprivate java.util.LinkedHashMap<AbstractVariable,IDecisionVariable>decisions(package private) static ConfigurationInitializerRegistry.IConfigurationInitializerDEFAULT_INITIALIZERDefines the default initializer for configurations.private java.util.List<IConfigurationChangeListener>listenersprivate ProjectprojectThe origin project, where this configuration belongs to.private IAssignmentStateresolutionState
-
Constructor Summary
Constructors Constructor Description Configuration(Configuration configuration)Copies aconfigurationby taking over its defined values and assignment states.Configuration(Project project)Creates a new configuration for the given project.Configuration(Project project, boolean assignValues)Alternative constructor to avoid initial value assignment byAssignmentResolver.Configuration(Project project, boolean assignValues, IAssignmentState resolutionState)Alternative constructor to avoid initial value assignment byAssignmentResolver.Configuration(Project project, IAssignmentState resolutionState)Creates a new configuration for the given project with explicit resolution state.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IConfigurationVisitor visitor)Accepts and calls the given visitor.protected voidaddAttributeDecision(Attribute attribute, Value value, IAssignmentState state)Adds an attribute decision to this configuration.private voidaddDecision(IDecisionVariable variable)Adda a decision.private voidaddVariables(java.util.List<AbstractVariable> topLevelDeclarations, boolean visible)CreatesIDecisionVariables for all givenAbstractVariables and adds them to the configuration.private voidallInstancesVariableChanged(IDecisionVariable var)Changes the all instance cache ifvaror one of its nested elements changed.voidclear()Clears all decisions.private voidcollectAllInstances(IDecisionVariable var, IDatatype type, java.util.Map<IDatatype,Reference> referenceTypes, java.util.Map<IDecisionVariable,ReferenceValue> instances)Collects all instances oftypestarting atvarand stores results intoreferenceTypesandinstances.IDecisionVariablecreateDecision(AbstractVariable decl)Creates a visible decision in this configuration.private IDecisionVariablecreateDecision(AbstractVariable decl, boolean visible)Creates a decision in this configuration.private voidcreateVariables()This method looks for allDecisionVariableDeclarations inside the related projects, createsDecisionVariableDeclarations and adds them to this configuration.static Valuedereference(IConfiguration conf, Value value)Dereferences a value.static IDecisionVariabledereference(IDecisionVariable var)Dereferences a variable.static booleanequalsByInstanceName(IDecisionVariable var1, IDecisionVariable var2)Returns whether two decision variables are equal via their instance name.static IDecisionVariablefindInParents(IDecisionVariable var, java.lang.String name)Finds a variable callednamein the decision variable parents ofvar, starting at the direct parent ofvar, thus, returning the variable withnameof the closest enclosing scope.voidfreeze(java.lang.String nestedElement)Freezes a single variable (must be a top layer element).voidfreeze(IFreezeSelector selector)Freezes on the whole configuration.private voidfreezeValues(AbstractVariable var, IFreezeSelector selector)SetsAssignmentState.FROZENstate to the given variablesvar.voidfreezeValues(Project project, FilterType filter)SetsAssignmentState.FROZENstate to already frozen variables.ValuegetAllInstances(IDatatype type)Returns all instances of the given type and sub-types.ConfigurationgetConfiguration()Returns the topLevel parent.(package private) java.util.Map<AbstractVariable,IDecisionVariable>getConfiguredDecisions()Returns the saved (AbstractVariable,IDecisionVariable) mapping.IDecisionVariablegetDecision(java.lang.String varName, boolean dereference)Returns the decision variable for a potentially nested/qualified name from this configuration.private IDecisionVariablegetDecision(IDecisionVariable var, java.lang.String varName, boolean dereference)Returns the decision variable for a potentially nested/qualified name from this configuration using withvaras current search context.IDecisionVariablegetDecision(AbstractVariable declaration)Returns the specifiedIDecisionVariable.intgetDecisionCount()Returns the number of decisions.AbstractVariablegetDeclaration()Returns the declaration of the variable.static java.lang.StringgetInstanceName(IDecisionVariable var)Returns the instance name of a decision variable.static java.lang.StringgetInstanceName(IDecisionVariable var, boolean qualified)Returns the instance name of a decision variable.private ModelInfo<Project>getModelInfo()Returns the related model information instance.java.lang.StringgetName()Returns the name of the configuration.static IDecisionVariablegetNestedElement(IDecisionVariable base, java.lang.String name)Returns an element forbasespecified by its name.IConfigurationElementgetParent()Returns the element this element is part of.ProjectgetProject()Returns the related project.QueryCachegetQueryCache()Returns theQueryCache, which should usually be used for query on thisConfiguration.IAssignmentStategetResolutionState()Returns the assignment state to be used when assigning values in the configuration.IAssignmentStategetState()Returns the assignment state of this variable.static IDecisionVariablegetTopLevelDecision(IDecisionVariable var)Returns the top-level decision variable ofvar.private voidinit()This method creates the list ofIDecisionVariables with initial value settings based on the given project.booleanisApproximatelyFrozen()Return whether this configuration is exactly or approximative (heuristicall) frozen.booleanisNested()Returns whether this decision variable is nested.java.util.Iterator<IDecisionVariable>iterator()Returns an iterator for iterating over all storedIDecisionVariables.static IDecisionVariablemapVariable(IDecisionVariable var, Configuration cfg)Maps a variable to its configuration following nested elements up and down.voidnotifyReplaced(Project oldProject, Project newProject)Is called to notify thatoldModelis replaced bynewModel.static voidprintConfig(java.io.PrintStream out, Configuration cfg)Prints a configuration toout.private static voidprintVariable(java.io.PrintStream out, IDecisionVariable var, java.lang.String indent)Prints a variable toout.voidprune()Creates a copy of the underlyingProjectand removes elements which are not needed for a runtime reasoning, e.g., constraints containing only frozen variables or comments.
Attention: This method creates a modified, shallow copy of the visited project.voidrefresh()This method calls atm only the init() Method.voidregister(IConfigurationChangeListener listener)Registers a new listener.booleanremoveDecision(IDecisionVariable variable)Remove a specific decision.voidremoveDerivedValues()Removes all by a reasoner propagated values from the configuration to clean it up.private voidremoveFromAllInstances(IDecisionVariable variable)Removesvariablefrom all instances.voidsetValue(Value value, IAssignmentState state, IConfigurationElement nested)Changes the value of a nested variable.voidshareQueryCacheWith(Configuration configToShare)Shares the cache of thisConfigurationwith configToShare.ProjecttoProject(boolean ownProject)Turns this configuration into a project, e.g.ProjecttoProject(boolean ownProject, boolean onlyUserInput)Turns this configuration into a project, e.g.voidunfreeze(IAssignmentState state)Unfreezes the whole configuration (including nested variables).private voidunfreezeVariable(IDecisionVariable variable, IAssignmentState state)Unfreezes a variable and all its nested elements (if such exist).booleanunregister(IConfigurationChangeListener listener)Unregisters an listener.(package private) voidvariableChanged(IDecisionVariable var, Value oldValue)Notifies all registeredIConfigurationChangeListeners that aIDecisionVariablechanged.(package private) voidvariableChangedState(IDecisionVariable var)Notifies all registeredIConfigurationChangeListeners that aIDecisionVariablehas changed its state.booleanwasCreated()Returns whether the variable value was explicitly created.
-
-
-
Field Detail
-
DEFAULT_INITIALIZER
static final ConfigurationInitializerRegistry.IConfigurationInitializer DEFAULT_INITIALIZER
Defines the default initializer for configurations. This is used as a default value byConfigurationInitializerRegistry. Shall be redefined by an appropriate reasoner.
-
project
private Project project
The origin project, where this configuration belongs to.
-
assignValues
private boolean assignValues
-
approximativeFreezing
private boolean approximativeFreezing
-
decisions
private java.util.LinkedHashMap<AbstractVariable,IDecisionVariable> decisions
-
listeners
private java.util.List<IConfigurationChangeListener> listeners
-
allInstances
private java.util.Map<IDatatype,java.util.Map<IDecisionVariable,ReferenceValue>> allInstances
-
resolutionState
private IAssignmentState resolutionState
-
cache
private QueryCache cache
-
-
Constructor Detail
-
Configuration
public Configuration(Project project)
Creates a new configuration for the given project.- Parameters:
project- The project, where this configuration belongs to. This project should already be registered at the VarModel- See Also:
#updateModel(net.ssehub.easy.basics.modelManagement.IModel, java.net.URI)
-
Configuration
public Configuration(Project project, IAssignmentState resolutionState)
Creates a new configuration for the given project with explicit resolution state. This project should already be registered at the VarModel#updateModel(net.ssehub.easy.basics.modelManagement.IModel, java.net.URI).- Parameters:
project- The project, where this configuration belongs to.resolutionState- the resolution state for the assignment resolver
-
Configuration
public Configuration(Configuration configuration)
Copies aconfigurationby taking over its defined values and assignment states.- Parameters:
configuration- the configuration to be copied
-
Configuration
public Configuration(Project project, boolean assignValues)
Alternative constructor to avoid initial value assignment byAssignmentResolver. If activated, theAssignmentResolverwill work withAssignmentState.ASSIGNED.- Parameters:
project- to getConfigurationfrom.assignValues- Decision if values should be assigned byAssignmentResolver.
-
Configuration
public Configuration(Project project, boolean assignValues, IAssignmentState resolutionState)
Alternative constructor to avoid initial value assignment byAssignmentResolver.- Parameters:
project- to getConfigurationfrom.assignValues- Decision if values should be assigned byAssignmentResolver.resolutionState- the resolution state for the assignment resolver
-
-
Method Detail
-
wasCreated
public boolean wasCreated()
Description copied from interface:IConfigurationElementReturns whether the variable value was explicitly created.- Specified by:
wasCreatedin interfaceIConfigurationElement- Returns:
truefor created,falseelse
-
getResolutionState
public IAssignmentState getResolutionState()
Returns the assignment state to be used when assigning values in the configuration.- Returns:
- the resolution state
-
getProject
public Project getProject()
Returns the related project.- Returns:
- the related project
-
isApproximatelyFrozen
public boolean isApproximatelyFrozen()
Return whether this configuration is exactly or approximative (heuristicall) frozen.- Returns:
falsefor exact freezing,truefor approximative freezing
-
getConfiguredDecisions
java.util.Map<AbstractVariable,IDecisionVariable> getConfiguredDecisions()
Returns the saved (AbstractVariable,IDecisionVariable) mapping.- Returns:
- A flat copy of the stored (
AbstractVariable,IDecisionVariable) mappings.
-
register
public void register(IConfigurationChangeListener listener)
Registers a new listener.- Parameters:
listener- A Listener which should be informed in case of changes.
-
unregister
public boolean unregister(IConfigurationChangeListener listener)
Unregisters an listener.- Parameters:
listener- The listener which should be unregistered.- Returns:
- true if this configuration contained the specified listener
-
getModelInfo
private ModelInfo<Project> getModelInfo()
Returns the related model information instance.- Returns:
- the model information instance
-
init
private void init()
This method creates the list ofIDecisionVariables with initial value settings based on the given project.
-
createVariables
private void createVariables()
This method looks for allDecisionVariableDeclarations inside the related projects, createsDecisionVariableDeclarations and adds them to this configuration. While creating theseDecisionVariableDeclarations this method also tries assign the specified default values to the newly createdDecisionVariableDeclarations.
-
addVariables
private void addVariables(java.util.List<AbstractVariable> topLevelDeclarations, boolean visible)
CreatesIDecisionVariables for all givenAbstractVariables and adds them to the configuration. Part of thecreateVariables()method and should only be called from this method.- Parameters:
topLevelDeclarations- The variables to add.visible- indicates whether the variable is visible to the user:- true: The variable is visible by the user and can be displayed in the GUI and so on.
- false: The variable is not visible by the user but must be considered in reasoning, instantiation, and so on.
-
createDecision
public IDecisionVariable createDecision(AbstractVariable decl) throws ConfigurationException
Creates a visible decision in this configuration. The declaration must be on top-level and not created before.- Parameters:
decl- the declaration to create the decision for- Returns:
- the created decision variable, may be null if the conditions are not met
- Throws:
ConfigurationException- in case that creating the variable failed
-
createDecision
private IDecisionVariable createDecision(AbstractVariable decl, boolean visible) throws ConfigurationException
Creates a decision in this configuration.- Parameters:
decl- the declaration to create the decision forvisible- whether the variable shall be visible- Returns:
- the created decision variable
- Throws:
ConfigurationException- in case that creating the variable failed
-
freezeValues
public void freezeValues(Project project, FilterType filter)
SetsAssignmentState.FROZENstate to already frozen variables.- Parameters:
project- the project to be frozenfilter- the filter type
-
freezeValues
private void freezeValues(AbstractVariable var, IFreezeSelector selector)
SetsAssignmentState.FROZENstate to the given variablesvar.- Parameters:
var- the variable to be frozenselector- the freeze selector
-
refresh
public void refresh()
This method calls atm only the init() Method.
-
getQueryCache
public QueryCache getQueryCache()
Returns theQueryCache, which should usually be used for query on thisConfiguration.- Returns:
- The cache for this
Configuration.
-
addDecision
private void addDecision(IDecisionVariable variable)
Adda a decision.- Parameters:
variable- the decision to be added
-
getDecisionCount
public int getDecisionCount()
Returns the number of decisions.- Returns:
- the number of decisions
-
getDecision
public IDecisionVariable getDecision(AbstractVariable declaration)
Description copied from interface:IConfigurationReturns the specifiedIDecisionVariable.- Specified by:
getDecisionin interfaceIConfiguration- Parameters:
declaration- The declaration for which the configuration entity should be returned.- Returns:
- The
IDecisionVariablefor the given declaration
-
iterator
public java.util.Iterator<IDecisionVariable> iterator()
Returns an iterator for iterating over all storedIDecisionVariables.- Specified by:
iteratorin interfacejava.lang.Iterable<IDecisionVariable>- Returns:
- an Iterator over the
IDecisionVariablein this configuration.
-
clear
public void clear()
Clears all decisions.
-
removeDecision
public boolean removeDecision(IDecisionVariable variable)
Remove a specific decision.- Parameters:
variable- the decision to be removed- Returns:
trueif this operation was successful,falseelse
-
removeFromAllInstances
private void removeFromAllInstances(IDecisionVariable variable)
Removesvariablefrom all instances.- Parameters:
variable- the variable to be removed
-
getName
public java.lang.String getName()
Returns the name of the configuration.- Returns:
- the name of the configuration
-
accept
public void accept(IConfigurationVisitor visitor)
Description copied from interface:IConfigurationVisitableAccepts and calls the given visitor.- Specified by:
acceptin interfaceIConfigurationVisitable- Parameters:
visitor- the visitor
-
notifyReplaced
public void notifyReplaced(Project oldProject, Project newProject)
Description copied from interface:IModelListenerIs called to notify thatoldModelis replaced bynewModel. The listener registrations foroldModelwill be adjusted accordingly.
Do not modify the the listeners ofoldModelornewModelduring this method.- Specified by:
notifyReplacedin interfaceIModelListener<Project>- Parameters:
oldProject- the old model being replacednewProject- the new model (the replacement)
-
toProject
public Project toProject(boolean ownProject) throws ConfigurationException
Turns this configuration into a project, e.g. for writing.- Parameters:
ownProject- return an own project (true) or add the configuration toproject(false)- Returns:
- the project or null if not implemented (default)
- Throws:
ConfigurationException- in case of any configuration errors
-
toProject
public Project toProject(boolean ownProject, boolean onlyUserInput) throws ConfigurationException
Turns this configuration into a project, e.g. for writing.- Parameters:
ownProject- return an own project (true) or add the configuration toproject(false)onlyUserInput- Specifies whether only user Input should be stored:- true: Assignments in state
AssignmentState.ASSIGNEDandAssignmentState.FROZENwill be saved. - false: Assignments in state
AssignmentState.ASSIGNED,AssignmentState.FROZEN, andAssignmentState.DERIVEDwill be saved (i.e. also computed values).
- true: Assignments in state
- Returns:
- the project or null if not implemented (default)
- Throws:
ConfigurationException- in case of any configuration errors
-
getConfiguration
public final Configuration getConfiguration()
Description copied from interface:IConfigurationElementReturns the topLevel parent.- Specified by:
getConfigurationin interfaceIConfigurationElement- Returns:
- should be the configuration
-
getParent
public IConfigurationElement getParent()
Description copied from interface:IConfigurationElementReturns the element this element is part of.- Specified by:
getParentin interfaceIConfigurationElement- Returns:
- the parent element (may be null in case of the top-level configuration)
-
variableChanged
void variableChanged(IDecisionVariable var, Value oldValue)
Notifies all registeredIConfigurationChangeListeners that aIDecisionVariablechanged.- Parameters:
var- theIDecisionVariablewhich changed. ThisIDecisionVariableshould be part of this configuration (No validation).oldValue- the old value before the change,varthen contains the new value
-
allInstancesVariableChanged
private void allInstancesVariableChanged(IDecisionVariable var)
Changes the all instance cache ifvaror one of its nested elements changed. Precondition is thatallInstanceswas already built up.- Parameters:
var- the changed variable
-
variableChangedState
void variableChangedState(IDecisionVariable var)
Notifies all registeredIConfigurationChangeListeners that aIDecisionVariablehas changed its state.- Parameters:
var- theIDecisionVariablewhich changed. ThisIDecisionVariableshould be part of this configuration (No validation).
-
addAttributeDecision
protected void addAttributeDecision(Attribute attribute, Value value, IAssignmentState state) throws ConfigurationException
Adds an attribute decision to this configuration. This method is a specific functionality for user interaction. Subclass this class and make it accessible if needed, otherwise it may break the value protection provided by this class.- Parameters:
attribute- the attribute for which the decision shall be createdvalue- the value of the attribute (may be null)state- the assignment state- Throws:
ConfigurationException- in case of type conflicts
-
isNested
public boolean isNested()
Description copied from interface:IConfigurationElementReturns whether this decision variable is nested. Being member of aConfigurationdoes not imply.isNested== true- Specified by:
isNestedin interfaceIConfigurationElement- Returns:
trueif it is nested in another decision variable,falseelse
-
getState
public IAssignmentState getState()
Description copied from interface:IConfigurationElementReturns the assignment state of this variable.- Specified by:
getStatein interfaceIConfigurationElement- Returns:
- the assignment state
-
setValue
public void setValue(Value value, IAssignmentState state, IConfigurationElement nested) throws ConfigurationException
Description copied from interface:IConfigurationElementChanges the value of a nested variable.- Specified by:
setValuein interfaceIConfigurationElement- Parameters:
value- the new valuestate- the new assignment statenested- the nested variable to be considered in the parent- Throws:
ConfigurationException- in case of type incompatibilities
-
getDeclaration
public AbstractVariable getDeclaration()
Returns the declaration of the variable.- Specified by:
getDeclarationin interfaceIConfigurationElement- Returns:
- the declaration of the decision variable
-
freeze
public void freeze(IFreezeSelector selector)
Freezes on the whole configuration.- Specified by:
freezein interfaceIConfigurationElement- Parameters:
selector- the selector deciding what to freeze
-
unfreeze
public void unfreeze(IAssignmentState state)
Unfreezes the whole configuration (including nested variables).- Specified by:
unfreezein interfaceIConfigurationElement- Parameters:
state- the target state after unfreezing (must not beAssignmentState.FROZEN)
-
unfreezeVariable
private void unfreezeVariable(IDecisionVariable variable, IAssignmentState state)
Unfreezes a variable and all its nested elements (if such exist).- Parameters:
variable-IDecisionVariableto unfreeze.state- state the target state after unfreezing (must not beAssignmentState.FROZEN)
-
freeze
public void freeze(java.lang.String nestedElement)
Freezes a single variable (must be a top layer element).- Specified by:
freezein interfaceIConfigurationElement- Parameters:
nestedElement- The name of the top layer variable.
-
dereference
public static IDecisionVariable dereference(IDecisionVariable var)
Dereferences a variable.- Parameters:
var- the variable to be dereferenced (may be null)- Returns:
- the dereferenced variable (null if
varwas null)
-
findInParents
public static IDecisionVariable findInParents(IDecisionVariable var, java.lang.String name)
Finds a variable callednamein the decision variable parents ofvar, starting at the direct parent ofvar, thus, returning the variable withnameof the closest enclosing scope.- Parameters:
var- the variable to start atname- the name of the variable to find- Returns:
- the found variable or null if ther is none
-
getDecision
public IDecisionVariable getDecision(java.lang.String varName, boolean dereference) throws ModelQueryException
Returns the decision variable for a potentially nested/qualified name from this configuration.- Parameters:
varName- the name of the variabledereference- dereference intermediary reference variables- Returns:
- the variable or null if none exists
- Throws:
ModelQueryException- in case that querying the model fails
-
getDecision
private IDecisionVariable getDecision(IDecisionVariable var, java.lang.String varName, boolean dereference) throws ModelQueryException
Returns the decision variable for a potentially nested/qualified name from this configuration using withvaras current search context.- Parameters:
var- the variable to search within (null for a top-level call)varName- the name of the variabledereference- dereference intermediary reference variables- Returns:
- the variable or null if none exists
- Throws:
ModelQueryException- in case that querying the model fails
-
getAllInstances
public Value getAllInstances(IDatatype type)
Returns all instances of the given type and sub-types.- Specified by:
getAllInstancesin interfaceIConfiguration- Parameters:
type- the type to look for- Returns:
- all instances of
var, may be null if the instances cannot be retrieved, e.g., in case of an integer variable
-
collectAllInstances
private void collectAllInstances(IDecisionVariable var, IDatatype type, java.util.Map<IDatatype,Reference> referenceTypes, java.util.Map<IDecisionVariable,ReferenceValue> instances)
Collects all instances oftypestarting atvarand stores results intoreferenceTypesandinstances.- Parameters:
var- the variable to collect the instances fromtype- the type to collectreferenceTypes- the reference types for data types (to be modified as a side effect)instances- the actual instances oftype(to be modified as a side effect)
-
mapVariable
public static IDecisionVariable mapVariable(IDecisionVariable var, Configuration cfg)
Maps a variable to its configuration following nested elements up and down.- Parameters:
var- the variable to be mappedcfg- the configuration containing the top-level variables- Returns:
- the mapped variable, null if there is no mapping
-
getInstanceName
public static java.lang.String getInstanceName(IDecisionVariable var)
Returns the instance name of a decision variable. This name is composed from the names of the given variable and its parent variables. Please note that the instance name is typically different from the qualified name of the declaration, which, in case of compound slots, leads to the variable in the compound definition. The result is unqualified regarding the top-level variable.- Parameters:
var- the variable to return the name for (may be null)- Returns:
- the instance name (may be empty if
var == null
-
getInstanceName
public static java.lang.String getInstanceName(IDecisionVariable var, boolean qualified)
Returns the instance name of a decision variable. This name is composed from the names of the given variable and its parent variables. Please note that the instance name is typically different from the qualified name of the declaration, which, in case of compound slots, leads to the variable in the compound definition.- Parameters:
var- the variable to return the name for (may be null)qualified- whether the name of the top-level variable shall be qualified- Returns:
- the instance name (may be empty if
var == null
-
equalsByInstanceName
public static boolean equalsByInstanceName(IDecisionVariable var1, IDecisionVariable var2)
Returns whether two decision variables are equal via their instance name. Please note that this method is faster and less resource consuming than comparing the respective results ofgetInstanceName(IDecisionVariable)as it compares the individual names rather than composing the full name and performing the comparison then.- Parameters:
var1- the first variable to be compared (may be null)var2- the second variable to be compared (may be null)- Returns:
trueif the variables are equal by their instance name,falseif they are not equal, in particular if one is null
-
printConfig
public static void printConfig(java.io.PrintStream out, Configuration cfg)Prints a configuration toout. [debugging]- Parameters:
out- the output streamcfg- the configuration to print
-
printVariable
private static void printVariable(java.io.PrintStream out, IDecisionVariable var, java.lang.String indent)Prints a variable toout. [debugging]- Parameters:
out- the output streamvar- the variable to printindent- the indentation
-
removeDerivedValues
public void removeDerivedValues()
Removes all by a reasoner propagated values from the configuration to clean it up.
-
prune
public void prune()
Creates a copy of the underlyingProjectand removes elements which are not needed for a runtime reasoning, e.g., constraints containing only frozen variables or comments.
Attention: This method creates a modified, shallow copy of the visited project. Thus, the original project becomes invalid through this visitation. This visitor should only be used if the original is no longer needed, e.g., for performance tweaks in a automated setup which does not save any data.
-
shareQueryCacheWith
public void shareQueryCacheWith(Configuration configToShare)
Shares the cache of thisConfigurationwith configToShare. This is useful if configToShare is a temporaryConfiguration/ projection and can reuse queries based thisConfiguration.- Parameters:
configToShare- A temporary configuration which may reuse the cache from this config.
-
getNestedElement
public static IDecisionVariable getNestedElement(IDecisionVariable base, java.lang.String name)
Returns an element forbasespecified by its name. This method is not recursive!- Parameters:
base- the base variable to search on (may be null)name- the name of the nested element- Returns:
- the nested element (may be null if not found or
baseis null)
-
getTopLevelDecision
public static IDecisionVariable getTopLevelDecision(IDecisionVariable var)
Returns the top-level decision variable ofvar.- Parameters:
var- the variable- Returns:
- the top-level decision variable, eventually
var, null if there is none
-
dereference
public static Value dereference(IConfiguration conf, Value value)
Dereferences a value.- Parameters:
conf- the configuration accessvalue- the value to be dereferenced- Returns:
- the dereferenced value
-
-