public class ConstVariableModelAnalysis
extends java.lang.Object
This class computes the set of constant variables by computing the
set of variables that are not constant and then performing the
complement. This is somewhat easier to compute. The computation is
performed in two passes, the first of which extracts the set of
variables which must be not-constant either by not being evaluatable,
by inclusion in an initial set, by virtue of being a PortParameter
with an external connection, or by assignment from within a modal
model. The second pass collects all the variables which are not
constant because they depend on other variables which are not
constant. This class also recognizes dependence declarations
represented by the DependencyDeclaration
class.
This class also determines the "least change context" of each dynamic variable. The least change context of a variable is typically an actor that contains that variable. During a firing of the least change context, the variable's value is guaranteed to not change. This analysis is important for supporting parameter changes in the context of domains that perform scheduling based on parameter values, like SDF and PSDF. The least change context of a PortParameter with an external connection must be a container of the PortParameter. The least change context of a variable assigned by a finite state machine in a modal model must be a container of the finite state machine. The change context of asserted not constant variables and variables with no expression are assumed to be the toplevel of the model. Note that in some cases (typically when a variable is modified from multiple sources which are not hierarchically related), no least change context may exist.
Constructor and Description |
---|
ConstVariableModelAnalysis()
Create a dummy analysis for actors that are not contained
in a model.
|
ConstVariableModelAnalysis(Entity model)
Analyze the given model to determine which variables must be
constants and which variables may change dynamically during
execution.
|
ConstVariableModelAnalysis(Entity model,
java.util.Set variableSet)
Analyze the given model to determine which variables must be
constants and which variables may change dynamically during
execution, given that all variables in the given set may
change dynamically.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependencyDeclaration(DependencyDeclaration declaration)
Add the information in the given dependency declaration to the
dependence graph of this analysis.
|
static ConstVariableModelAnalysis |
getAnalysis(NamedObj object)
Return the analysis that is active for the given object.
|
Entity |
getChangeContext(Variable variable)
Return the change context of the given variable.
|
Token |
getConstantValue(Variable variable)
Return the constant value of the given parameter, if the
parameter is actually constant.
|
java.util.Set |
getConstVariables(NamedObj container)
Return the computed constant variables for the given container.
|
DirectedGraph |
getDependencyGraph()
Return the parameter dependency graph constructed through this
analysis.
|
java.util.Set |
getNotConstVariables(NamedObj container)
Return the computed not constant variables for the given container.
|
java.util.Set |
getVariablesWithChangeContext(NamedObj container)
Return the set of variables anywhere in the model that have
the given container as least change context.
|
boolean |
isConstant(Variable variable)
Return true if the given variable is not reconfigured in the
model.
|
boolean |
isIndependent(Variable variable)
Return true if the variable has been analyzed by this analysis
and it depends on no other parameters.
|
public ConstVariableModelAnalysis()
public ConstVariableModelAnalysis(Entity model) throws IllegalActionException
model
- The model to be analyzed.IllegalActionException
- If an exception occurs
during analysis.public ConstVariableModelAnalysis(Entity model, java.util.Set variableSet) throws IllegalActionException
model
- The model to be analyzed.variableSet
- The set to be analyzed.IllegalActionException
- If an exception occurs
during analysis.public void addDependencyDeclaration(DependencyDeclaration declaration)
declaration
- The given dependency declaration.public static ConstVariableModelAnalysis getAnalysis(NamedObj object) throws IllegalActionException
object
- The given object.IllegalActionException
- If an exception occurs during
analysis.public Entity getChangeContext(Variable variable)
variable
- The given variable.public Token getConstantValue(Variable variable) throws IllegalActionException
variable
- The given variable.IllegalActionException
- If the given parameter is
not a constant parameter, as determined by this analysis.public java.util.Set getConstVariables(NamedObj container)
container
- The given container.java.lang.RuntimeException
- If the constant variables for the
container have not already been computed.public DirectedGraph getDependencyGraph()
public java.util.Set getNotConstVariables(NamedObj container)
container
- The given container.java.lang.RuntimeException
- If the constant variables for the
container have not already been computed.public java.util.Set getVariablesWithChangeContext(NamedObj container)
container
- The given container.public boolean isConstant(Variable variable)
variable
- The given variable.public boolean isIndependent(Variable variable)
variable
- The given variable.