Skip to content

Commit

Permalink
Use correct variants of "loop"
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Apr 14, 2021
1 parent a21efbe commit 0787fb9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
8 changes: 6 additions & 2 deletions chapters/classes.tex
Expand Up @@ -972,7 +972,9 @@ \section{Balanced Models}\label{balanced-models}
\end{definition}

\begin{nonnormative}
Here, \emph{legal values} must respect final bindings and min/max-restrictions. A tool shall verify the \emph{locally balanced} property for the actual values of parameters and constants in the simulation model. It is a quality of implementation for a tool to verify this property in general, due to arrays of (locally) undefined sizes, conditional declarations, for-loops etc.
Here, \emph{legal values} must respect final bindings and min/max-restrictions.
A tool shall verify the \emph{locally balanced} property for the actual values of parameters and constants in the simulation model.
It is a quality of implementation for a tool to verify this property in general, due to arrays of (locally) undefined sizes, conditional declarations, \lstinline!for!-loops etc.
\end{nonnormative}

\begin{definition}[Globally balanced]\index{globally balanced}\index{balanced!globally}
Expand Down Expand Up @@ -1493,7 +1495,9 @@ \subsection{Enumeration Types}\label{enumeration-types}
\end{lstlisting}
\end{example}

An enumeration type is a simple type and the attributes are defined in \cref{attributes-of-enumeration-types}. The \lstinline!Boolean! type name or an enumeration type name can be used to specify the dimension range for a dimension in an array declaration and to specify the range in a for-loop range expression; see \cref{types-as-iteration-ranges}. An element of an enumeration type can be accessed in an expression.
An enumeration type is a simple type and the attributes are defined in \cref{attributes-of-enumeration-types}.
The \lstinline!Boolean! type name or an enumeration type name can be used to specify the dimension range for a dimension in an array declaration and to specify the range in a \lstinline!for!-loop range expression; see \cref{types-as-iteration-ranges}.
An element of an enumeration type can be accessed in an expression.

\begin{nonnormative}
Uses of elements of enumeration type in expressions include indexing into an array.
Expand Down
2 changes: 1 addition & 1 deletion chapters/dae.tex
Expand Up @@ -142,7 +142,7 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation}
end loop
\end{lstlisting}

Clocked variables are handled similarly as $z$ and $m$ (depending on type), but using \lstinline!previous! instead of \lstinline!pre! and only solved in the first iteration of the event-loop.
Clocked variables are handled similarly as $z$ and $m$ (depending on type), but using \lstinline!previous! instead of \lstinline!pre! and only solved in the first event iteration.

Solving \eqref{eq:hydrid-dae} for the unknowns is non-trivial, because this set of equations contains not only \lstinline!Real!, but also discrete-valued unknowns.
Usually, in a first step these equations are sorted and in many cases the discrete-valued unknowns $m$ can be just computed by a forward evaluation sequence.
Expand Down
7 changes: 6 additions & 1 deletion chapters/equations.tex
Expand Up @@ -111,7 +111,12 @@ \subsection{For-Equations -- Repetitive Equation Structures}\label{for-equations

\subsubsection{Explicit Iteration Ranges of For-Equations}\label{explicit-iteration-ranges-of-for-equations}

The \lstinline!expression! of a for-equation shall be a vector expression, where more general array expressions are treated as vector of vectors or vector of matrices. It is evaluated once for each for-equation, and is evaluated in the scope immediately enclosing the for-equation. The expression of a for-equation shall be a parameter expression. The iteration range of a for-equation can also be specified as \lstinline!Boolean! or as an enumeration type, see \cref{types-as-iteration-ranges} for more information. The loop-variable (\lstinline!IDENT!) is in scope inside the loop-construct and shall not be assigned to. For each element of the evaluated vector expression, in the normal order, the loop-variable gets the value of that element and that is used to evaluate the body of the for-loop.
The \lstinline!expression! of a for-equation shall be a vector expression, where more general array expressions are treated as vector of vectors or vector of matrices.
It is evaluated once for each for-equation, and is evaluated in the scope immediately enclosing the for-equation.
The expression of a for-equation shall be a parameter expression.
The iteration range of a for-equation can also be specified as \lstinline!Boolean! or as an enumeration type, see \cref{types-as-iteration-ranges} for more information.
The loop-variable (\lstinline!IDENT!) is in scope inside the loop-construct and shall not be assigned to.
For each element of the evaluated vector expression, in the normal order, the loop-variable gets the value of that element and that is used to evaluate the body of the \lstinline!for!-loop.

\begin{example}
\begin{lstlisting}[language=modelica]
Expand Down
2 changes: 1 addition & 1 deletion chapters/revisions.tex
Expand Up @@ -2752,7 +2752,7 @@ \subsection{Main Changes in Modelica 1.3}\label{main-changes-in-modelica-1-3}
\item
Improved semantic definition of array expressions.
\item
Defined scope of for-loop variables.
Defined scope of \lstinline!for!-loop variables.
\end{itemize}

\subsection{Main Changes in Modelica 1.2}\label{main-changes-in-modelica-1-2}
Expand Down
4 changes: 1 addition & 3 deletions chapters/scoping.tex
Expand Up @@ -69,9 +69,7 @@ \subsection{Simple Name Lookup}\label{simple-name-lookup}
In the latter case the lookup stops except for the predefined types, functions and operators defined in this specification.
For these cases the lookup continues in the global scope, where they are defined.

The iteration variables are the implicitly declared iteration variable(s) if inside
the body of a for-loop, \cref{for-equations-repetitive-equation-structures} and \cref{for-statement},
or the body of a reduction expression, \cref{reduction-functions-and-operators}.
The iteration variables are the implicitly declared iteration variable(s) if inside the body of a \lstinline!for!-loop, \cref{for-equations-repetitive-equation-structures} and \cref{for-statement}, or the body of a reduction expression, \cref{reduction-functions-and-operators}.

Reference to variables successfully looked up in an enclosing class is only allowed for variables declared as \lstinline!constant!. The values of modifiers are thus resolved in the \emph{instance} scope of which the modifier appears; if the use is in a modifier on a short class definition, see \cref{short-class-definitions}.

Expand Down
6 changes: 4 additions & 2 deletions chapters/statements.tex
Expand Up @@ -249,11 +249,13 @@ \subsubsection{Implicit Iteration Ranges}\label{implicit-iteration-ranges}
\end{lstlisting}
\end{example}

The size of an array -- the iteration range -- is evaluated on entry to the for-loop and the array size shall not change during the execution of the for-loop.
The size of an array -- the iteration range -- is evaluated on entry to the \lstinline!for!-loop and the array size shall not change during the execution of the \lstinline!for!-loop.

\subsubsection{Types as Iteration Ranges}\label{types-as-iteration-ranges}

The iteration range can be specified as \lstinline!Boolean! or as an enumeration type. This means iteration over the type from min to max, i.e.\ for \lstinline!Boolean! it is the same as \lstinline!false:true! and for an enumeration \lstinline!E! it is the same as \lstinline!E.min:E.max!. This can be used for \lstinline!for! loops and reduction expressions.
The iteration range can be specified as \lstinline!Boolean! or as an enumeration type.
This means iteration over the type from min to max, i.e.\ for \lstinline!Boolean! it is the same as \lstinline!false:true! and for an enumeration \lstinline!E! it is the same as \lstinline!E.min:E.max!.
This can be used for \lstinline!for!-loops and reduction expressions.

\begin{example}
\begin{lstlisting}[language=modelica]
Expand Down

0 comments on commit 0787fb9

Please sign in to comment.