Skip to content

Commit

Permalink
Rename concept 'structural parameter' -> 'evaluable parameter'
Browse files Browse the repository at this point in the history
Also renaming the associated 'structural expression' and 'structural component variability'.
  • Loading branch information
henrikt-ma committed Feb 7, 2022
1 parent 2cf5afa commit 07b525c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
18 changes: 9 additions & 9 deletions chapters/annotations.tex
Expand Up @@ -367,13 +367,13 @@ \section{Annotations for Symbolic Processing}\label{annotations-for-symbolic-pro
In the case of hierarchical components it is applied to all components, overriding any \lstinline!Evaluate!-setting for specific components.
The annotation \lstinline!Evaluate! is only allowed for parameters and constants.

Setting \lstinline!Evaluate = true! for a structural parameter, means that it must be an evaluated parameter (i.e., its value must be determined during translation, similar to a constant).
Setting \lstinline!Evaluate = true! for an evaluable parameter, means that it must be an evaluated parameter (i.e., its value must be determined during translation, similar to a constant).
For a normal parameter, it has no impact and it is recommended to issue a warning in most cases.
The exception for recommending this warning is when the parameter is normal due to dependency on a parameter with \lstinline!Evaluate = false!, as this could be a sign of intentional overriding of \lstinline!Evaluate = true!, see example below.
For both structural parameters and constants, the model developer further proposes to utilize the value for symbolic processing.
For both evaluable parameters and constants, the model developer further proposes to utilize the value for symbolic processing.
A constant can never be changed after translation, and it is normal for its value to be used for symbolic processing even without \lstinline!Evaluate = true!.

For a parameter, \lstinline!Evaluate = false! ensures that the parameter is a normal parameter according to \cref{component-variability-prefixes-discrete-parameter-constant} (meaning it is not allowed to be used where a structural expression (\cref{structural-expressions}) is expected).
For a parameter, \lstinline!Evaluate = false! ensures that the parameter is a normal parameter according to \cref{component-variability-prefixes-discrete-parameter-constant} (meaning it is not allowed to be used where an evaluable expression (\cref{evaluable-expressions}) is expected).
For both parameters and constants -- even when the value can be determined during translation -- the model developer further proposes to not utilize the value for symbolic processing.

\begin{nonnormative}
Expand All @@ -383,25 +383,25 @@ \section{Annotations for Symbolic Processing}\label{annotations-for-symbolic-pro
\end{nonnormative}

\begin{example}
When a parameter has \lstinline!Evaluate = true! for optimization reasons (not because it needs to be structural), it is possible to prevent the value from being determined during translation without modifying the original model:
When a parameter has \lstinline!Evaluate = true! for optimization reasons (not because it needs to be evaluable), it is possible to prevent the value from being determined during translation without modifying the original model:
\begin{lstlisting}[language=modelica]
model M_structural
/* Here, 'b' is structural, and will be evaluated. */
model M_evaluable
/* Here, 'b' is evaluable, and will be evaluated. */
parameter Boolean b = false annotation(Evaluate = true);
Real x(start = 1.0, fixed = true);
equation
if b then /* No need for b to be structural. */
if b then /* No need for b to be evaluable. */
der(x) = x;
else
der(x) = -x;
end if;
end M_structural;
end M_evaluable;

model M_normal
/* Here, 'bn' is normal, which in turn will cause 'b' to be normal,
* thereby preventing it from being determined during translation.
*/
extends M_structural(b = bn);
extends M_evaluable(b = bn);
parameter Boolean bn = false annotation(Evaluate = false);
end M_normal;
\end{lstlisting}
Expand Down
34 changes: 17 additions & 17 deletions chapters/classes.tex
Expand Up @@ -284,11 +284,11 @@ \subsubsection{Prefix Rules}\label{prefix-rules}
\subsection{Acyclic Bindings of Constants and Parameters}\label{acyclic-bindings-of-constants-and-parameters}

For a constant or parameter \lstinline!v! with declaration equation, the expression of the declaration equation in the flattended model must not depend on \lstinline!v! itself, neither directly nor indirectly via other variables' declaration equations.
To satisfy this condition, dependencies shall be removed as needed by applying simplifications based on values of constants (except with \lstinline!Evaluate = false!) and all other \willintroduce{structural parameters} (\cref{component-variability-prefixes-discrete-parameter-constant}) that don't depend on \lstinline!v!.
To satisfy this condition, dependencies shall be removed as needed by applying simplifications based on values of constants (except with \lstinline!Evaluate = false!) and all other \willintroduce{evaluable parameters} (\cref{component-variability-prefixes-discrete-parameter-constant}) that don't depend on \lstinline!v!.
It is not permitted to expand a non-scalar declaration equation into scalar equations to satisfy the condition.

That the value of a structural parameter is used for these simplifications does not mean that it has to be determined during translation, but if \lstinline!v! is found to be a structural parameter, then a Modelica tool will be able to break all cycles involving \lstinline!v! by making some (possibly none or all) of the other structural parameters determined during translation.
Hence, evaluation of a constant or structural parameter can never require solving systems of equations; they can always be sorted so that they can be solved one at a time with the natural causality (i.e., the declaration equation is used to determine the value of the component to which it belongs).
That the value of an evaluable parameter is used for these simplifications does not mean that it has to be determined during translation, but if \lstinline!v! is found to be an evaluable parameter, then a Modelica tool will be able to break all cycles involving \lstinline!v! by making some (possibly none or all) of the other evaluable parameters determined during translation.
Hence, evaluation of a constant or evaluable parameter can never require solving systems of equations; they can always be sorted so that they can be solved one at a time with the natural causality (i.e., the declaration equation is used to determine the value of the component to which it belongs).

\begin{example}
Direct and indirect cyclic dependency:
Expand Down Expand Up @@ -358,7 +358,7 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
A variable \lstinline!vc! declared with \lstinline!constant!\indexinline{constant} prefix remains constant during transient analysis, with a value that is unaffected by the initialization problem (i.e., determined during translation).
This is called a \firstuse[---]{constant}, or \firstuse[constant!variable]{constant variable}\index{component variability!constant}.
\item
A variable \lstinline!sp! is called a \firstuse[parameter!structural]{structural parameter variable}\index{component variability!structural parameter} if all of the following applies:
A variable \lstinline!ep! is called a \firstuse[parameter!evaluable]{evaluable parameter variable}\index{component variability!evaluable parameter} if all of the following applies:
\begin{itemize}
\item
It is declared with the \lstinline!parameter!\indexinline{parameter} prefix.
Expand All @@ -367,12 +367,12 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
\item
It does not have annotation \lstinline!Evaluate = false!.
\item
The declaration equation -- or \lstinline!start! attribute if no declaration equation is given (see \cref{initialization-initial-equation-and-initial-algorithm}) -- is given by a structural expression (\cref{structural-expressions}).
The declaration equation -- or \lstinline!start! attribute if no declaration equation is given (see \cref{initialization-initial-equation-and-initial-algorithm}) -- is given by an evaluable expression (\cref{evaluable-expressions}).
\end{itemize}
A structural parameter remains constant during transient analysis, with a value either determined during translation (similar to having prefix \lstinline!constant!, and is then called an \firstuse[parameter!evaluated]{evaluated parameter}) or by the initialization problem (similar to a \willintroduce{normal parameter}, see item below).
An evaluable parameter remains constant during transient analysis, with a value either determined during translation (similar to having prefix \lstinline!constant!, and is then called an \firstuse[parameter!evaluated]{evaluated parameter}) or by the initialization problem (similar to a \willintroduce{normal parameter}, see item below).
At which of these stages the value is determined is tool dependent.
\item
A variable \lstinline!np! declared with the \lstinline!parameter!\indexinline{parameter} prefix, is called a \firstuse[parameter!normal]{normal parameter variable}\index{component variability!normal parameter} unless it is a structural parameter.
A variable \lstinline!np! declared with the \lstinline!parameter!\indexinline{parameter} prefix, is called a \firstuse[parameter!normal]{normal parameter variable}\index{component variability!normal parameter} unless it is an evaluable parameter.
It is also simply called a \firstuse[parameter!normal]{normal parameter}.
It remains constant during transient analysis, with a value determined by the initialization problem.
\item
Expand All @@ -393,41 +393,41 @@ \subsection{Component Variability Prefixes discrete, parameter, constant}\label{
The value of a constant can be modified after it has been given a value, unless the constant is declared \lstinline!final! or modified with a \lstinline!final! modifier.
A constant without an associated declaration equation can be given one by using a modifier.

The term \firstuse[---]{parameter variable} or just \firstuse[---]{parameter} refers to a variable that is either a normal or structural parameter variable.
The term \firstuse[---]{parameter variable} or just \firstuse[---]{parameter} refers to a variable that is either a normal or evaluable parameter variable.

\begin{nonnormative}
With every normal parameter, there is at least one reason why it isn't a structural parameter.
This information is useful to maintain in tools, as it allows generation of informative error messages when a violation of structural expression variability is detected.
With every normal parameter, there is at least one reason why it isn't an evaluable parameter.
This information is useful to maintain in tools, as it allows generation of informative error messages when a violation of evaluable expression variability is detected.
For example:
\begin{lstlisting}[language=modelica]
parameter Integer n =
if b then 1 else 2; // Normal parameter due to variability of b.
parameter Boolean b(fixed = false); // Normal parameter due to fixed = false.
Real[n] x; // Variability error: n must be structural.
Real[n] x; // Variability error: n must be evaluable.
initial equation
b = n > 3;
\end{lstlisting}
Here, a good error message for the variability error can include the information that the reason for \lstinline!n! being a normal parameter is that it has a dependency on the normal parameter \lstinline!b!.

(Would structural and normal parameters have had different variability prefixes in their component declarations, it would have been possible to detect and report errors directly at the structural component declarations instead.)
(Would evaluable and normal parameters have had different variability prefixes in their component declarations, it would have been possible to detect and report errors directly at the evaluable component declarations instead.)
\end{nonnormative}

\begin{nonnormative}
For a parameter in a valid model, presence of \lstinline!Evaluate! (\cref{modelica:Evaluate}) makes it possible to tell immediately whether it is a structural or normal parameter, at least as long as the warning described in \cref{modelica:Evaluate} isn't triggered.
For a parameter in a valid model, presence of \lstinline!Evaluate! (\cref{modelica:Evaluate}) makes it possible to tell immediately whether it is an evaluable or normal parameter, at least as long as the warning described in \cref{modelica:Evaluate} isn't triggered.
To see this, note that \lstinline!Evaluate = false! makes it a normal parameter by definition, and that \lstinline!Evaluate = true! would trigger the warning if the parameter is normal.
\end{nonnormative}

By the acyclic binding rule in \cref{acyclic-bindings-of-constants-and-parameters}, it follows that the value of a constant or structural parameter to be used in simplifications is possible to obtain by evaluation of a structural expression where values are available for all component subexpressions.
By the acyclic binding rule in \cref{acyclic-bindings-of-constants-and-parameters}, it follows that the value of a constant or evaluable parameter to be used in simplifications is possible to obtain by evaluation of an evaluable expression where values are available for all component subexpressions.

\begin{example}
A particularly demanding aspect of this evaluation is the potential presence of external functions.
Hence, if it is known that a parameter won't be used by a structural expression, a user can make it clear that the external function is not meant to be evaluated during translation by using \lstinline!Evaluate = false!:
Hence, if it is known that a parameter won't be used by an evaluable expression, a user can make it clear that the external function is not meant to be evaluated during translation by using \lstinline!Evaluate = false!:
\begin{lstlisting}[language=modelica]
import length = Modelica.Utilities.Strings.length; /* Pure external function */
parameter Integer n = length("Hello"); /* Structural parameter */
parameter Integer n = length("Hello"); /* Evaluable parameter */
parameter Integer p = length("Hello")
annotation(Evaluate = false); /* Normal parameter */
parameter Boolean b = false; /* Structural parameter */
parameter Boolean b = false; /* Evaluable parameter */

/* Fulfillment of acyclic binding rule might cause evaluation of n;
* to break the cycle, a tool might evaluate either b, n, or both:
Expand Down
16 changes: 8 additions & 8 deletions chapters/operatorsandexpressions.tex
Expand Up @@ -1432,27 +1432,27 @@ \subsection{Constant Expressions}\label{constant-expressions}
\end{itemize}
\end{itemize}

\subsection{Structural Expressions}\label{structural-expressions}
\subsection{Evaluable Expressions}\label{evaluable-expressions}

Structural expressions\index{structural expression}\index{expression variability!structural} are:
Evaluable expressions\index{evaluable expression}\index{expression variability!evaluable} are:
\begin{itemize}
\item
Constant expressions.
\item
Structural parameter variables, see \cref{component-variability-prefixes-discrete-parameter-constant}.
Evaluable parameter variables, see \cref{component-variability-prefixes-discrete-parameter-constant}.
\item
Input variables in functions behave as though they were structural expressions.
Input variables in functions behave as though they were evaluable expressions.
\item
Except for the special built-in operators \lstinline!initial!, \lstinline!terminal!, \lstinline!der!, \lstinline!edge!, \lstinline!change!, \lstinline!sample!, and \lstinline!pre!, a function or operator with structural subexpressions is a structural expression.
Except for the special built-in operators \lstinline!initial!, \lstinline!terminal!, \lstinline!der!, \lstinline!edge!, \lstinline!change!, \lstinline!sample!, and \lstinline!pre!, a function or operator with evaluable subexpressions is an evaluable expression.
\item
Some function calls are structural expressions even if the arguments are not:
Some function calls are evaluable expressions even if the arguments are not:
\begin{itemize}
\item
\lstinline!cardinality(c)!, see restrictions for use in \cref{cardinality-deprecated}.
\item
\lstinline!end! in \lstinline!A[$\ldots$ end $\ldots$]! if \lstinline!A! is variable declared in a non-\lstinline!function! class.
\item
\lstinline!size(A)! (including \lstinline!size(A, j)! where \lstinline!j! is a structural expression) if \lstinline!A! is variable declared in a non-function class.
\lstinline!size(A)! (including \lstinline!size(A, j)! where \lstinline!j! is an evaluable expression) if \lstinline!A! is variable declared in a non-function class.
\item
\lstinline!Connections.isRoot(A.R)!
\item
Expand All @@ -1465,7 +1465,7 @@ \subsection{Parameter Expressions}\label{parameter-expressions}
Parameter expressions\index{parameter!expression}\index{expression variability!parameter}\index{parametric variability|see{parameter, expression}} are:
\begin{itemize}
\item
Structural expressions.
Evaluable expressions.
\item
Normal parameter variables, see \cref{component-variability-prefixes-discrete-parameter-constant}.
\item
Expand Down
2 changes: 1 addition & 1 deletion chapters/revisions.tex
Expand Up @@ -295,7 +295,7 @@ \subsection{Main changes in Modelica 3.5}\label{main-changes-in-modelica-3-5}
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/2676}{\#2676}.
\item Made when-descriptions more similar, \cref{restrictions-on-where-a-when-equation-may-occur} and \cref{restrictions-on-equations-within-when-equations}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/2635}{\#2635}.
\item Make assertion level a structural parameter, \cref{assert}.
\item Make assertion level an evaluable parameter, \cref{assert}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/2642}{\#2642}.
\item Deprecate byte order mark, \cref{mapping-a-package-class-hierarchy-into-a-directory-hierarchy-structured-entity}.
Ticket \href{https://github.com/modelica/ModelicaSpecification/issues/2675}{\#2675}.
Expand Down

0 comments on commit 07b525c

Please sign in to comment.