|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.actor.util.ConstVariableModelAnalysis
public class ConstVariableModelAnalysis
An analysis that traverses a model to determine all the constant variables in a hierarchical model. Basically, a constant variable in a particular model is any variable in the model that is defined by a expression of constants, or any variable that is defined by an expression of constants and identifiers that reference other constant variables.
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 guaraunteed 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.
Yellow (neuendor) |
Yellow (neuendor) |
Field Summary | |
---|---|
private DirectedGraph |
_dependencyGraph
|
private java.util.Map |
_variableToChangeContext
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
private void |
_addDependencyDeclaration(DependencyDeclaration declaration)
|
private void |
_analyzeAllVariables()
|
private void |
_collectConstraints(NamedObj container)
|
private void |
_collectVariableConstraints(Variable variable)
|
private Entity |
_computeBound(Entity entity1,
Entity entity2)
|
private Node |
_getNode(Variable variable)
|
private boolean |
_updateChangeContext(Variable variable,
Entity changeContext)
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private DirectedGraph _dependencyGraph
private java.util.Map _variableToChangeContext
Constructor Detail |
---|
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.Method Detail |
---|
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.
private void _addDependencyDeclaration(DependencyDeclaration declaration)
private void _collectVariableConstraints(Variable variable)
private void _collectConstraints(NamedObj container) throws IllegalActionException
IllegalActionException
private void _analyzeAllVariables()
private Node _getNode(Variable variable)
private final boolean _updateChangeContext(Variable variable, Entity changeContext)
private final Entity _computeBound(Entity entity1, Entity entity2)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |