From a8c01a0b34b4c637a5f74971494330d3b82b2566 Mon Sep 17 00:00:00 2001 From: HOS Date: Thu, 5 Jun 2025 15:25:04 +0200 Subject: [PATCH 1/2] Adding draft variant of Connections.uniqueRoot --- chapters/connectors.tex | 32 ++++++++++++++++++++++++++++ chapters/equations.tex | 4 ++-- chapters/operatorsandexpressions.tex | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/chapters/connectors.tex b/chapters/connectors.tex index 99389c676..ad1afad18 100644 --- a/chapters/connectors.tex +++ b/chapters/connectors.tex @@ -800,6 +800,7 @@ \subsection{Connection Graphs and Their Operators}\label{overconstrained-equatio The edges of the virtual connection graph are implicitly defined by \lstinline!connect! and explicitly by \lstinline!Connections.branch!, see table below. \lstinline!Connections! is a built-in package in global scope containing built-in operators. Additionally, corresponding nodes of the virtual connection graph have to be defined as roots or as potential roots with functions \lstinline!Connections.root! and \lstinline!Connections.potentialRoot!, respectively. +Furthermore there is \lstinline!Connections.uniqueRoot! which is a simpler variant that can only have one root without any loops. The overconstrained equation operators for connection graphs are listed below. Here, \lstinline!a! and \lstinline!b! are connector instances that may be hierarchically structured, e.g., \lstinline!a! may be an abbreviation for \lstinline!enginePort.frame_a!. @@ -815,6 +816,8 @@ \subsection{Connection Graphs and Their Operators}\label{overconstrained-equatio {\lstinline!Connections.potentialRoot(a.R, $\ldots$)!} & Potential root node & \Cref{modelica:Connections.potentialRoot}\\ {\lstinline!Connections.isRoot(a.R)!} & Predicate for being selected as root & \Cref{modelica:Connections.isRoot}\\ {\lstinline!Connections.rooted(a.R)!} & Predicate for being closer to root & \Cref{modelica:Connections.rooted}\\ +{\lstinline!Connections.uniqueRoot(a.R, "msg")!} & Define a unique root node & \Cref{modelica:Connections.uniqueRoot}\\ +{\lstinline!Connections.uniqueRootIndices(a.R, b.R)!} & Checking structure of root indices & \Cref{modelica:Connections.uniqueRootIndices}\\ \hline \end{tabular} \end{center} @@ -903,6 +906,35 @@ \subsection{Connection Graphs and Their Operators}\label{overconstrained-equatio \end{semantics} \end{operatordefinition} +\begin{operatordefinition}[Connections.uniqueRoot] +\begin{synopsis}\begin{lstlisting} +Connections.uniqueRoot(a.R, msg) +\end{lstlisting}\end{synopsis} +\begin{semantics} +The overdetermined type or record instance \lstinline!R! in connector instance \lstinline!a! is a \firstuse[definite root node]{(definite) root node}\index{root node!definite} in a virtual connection graph. +If there are any other roots (normal, unique, or potential) that is an error and the message argument will be used in the diagnostics. +If two unique roots are connected and the message arguments are different either or both arguments may be used. + +\begin{nonnormative} +This definition shall be used if in a model with connector \lstinline!a! the overdetermined record \lstinline!a.R! is (consistently) assigned, e.g., from a parameter expressions, and the overdetermined connectors do not allow multiple roots. +It is used for the \lstinline!Modelica_StateGraph2!. +\end{nonnormative} +\end{semantics} +\end{operatordefinition} + +\begin{operatordefinition}[Connections.uniqueRootIndices] +\begin{synopsis}\begin{lstlisting} +Connections.uniqueRoot(a.R, b.R, msg) +\end{lstlisting}\end{synopsis} +\begin{semantics} +Returns an index for the connections between a and b, where msg is used in case of error. + +\begin{nonnormative} +This is used for checking parallel connections in \lstinline!Modelica_StateGraph2!. +\end{nonnormative} +\end{semantics} +\end{operatordefinition} + \begin{nonnormative} Note, that \lstinline!Connections.branch!, \lstinline!Connections.root!, \lstinline!Connections.potentialRoot! do not generate equations. They only generate nodes and edges in the virtual graph for analysis purposes. diff --git a/chapters/equations.tex b/chapters/equations.tex index d85574de4..a33ea46c9 100644 --- a/chapters/equations.tex +++ b/chapters/equations.tex @@ -153,11 +153,11 @@ \subsection{Connect-Equations}\label{connect-equations} connect "(" component-reference "," component-reference ")" ";" \end{lstlisting} -These can be placed inside \lstinline!for!-equations and \lstinline!if!-equations; provided the indices of the \lstinline!for!-loop and conditions of the \lstinline!if!-equation are evaluable expressions that do not depend on \lstinline!cardinality!, \lstinline!rooted!, \lstinline!Connections.rooted!, or \lstinline!Connections.isRoot!. +These can be placed inside \lstinline!for!-equations and \lstinline!if!-equations; provided the indices of the \lstinline!for!-loop and conditions of the \lstinline!if!-equation are evaluable expressions that do not depend on \lstinline!cardinality!, \lstinline!rooted!, \lstinline!Connections.rooted!, \lstinline!Connections.isRoot!, or \lstinline!Connections.uniqueRootIndices!. The \lstinline!for!-equations/\lstinline!if!-equations are expanded. \lstinline!connect!-equations are described in detail in \cref{connect-equations-and-connectors}. -The same restrictions apply to \lstinline!Connections.branch!, \lstinline!Connections.root!, and \lstinline!Connections.potentialRoot!; which after expansion are handled according to \cref{equation-operators-for-overconstrained-connection-based-equation-systems1}. +The same restrictions apply to \lstinline!Connections.branch!, \lstinline!Connections.root!, \lstinline!Connections.potentialRoot!, and \lstinline!Connections.uniqueRoot!; which after expansion are handled according to \cref{equation-operators-for-overconstrained-connection-based-equation-systems1}. \subsection{If-Equations}\label{if-equations} diff --git a/chapters/operatorsandexpressions.tex b/chapters/operatorsandexpressions.tex index c2191a7bc..ff01fdee3 100644 --- a/chapters/operatorsandexpressions.tex +++ b/chapters/operatorsandexpressions.tex @@ -1607,6 +1607,8 @@ \subsection{Evaluable Expressions}\label{evaluable-expressions} \lstinline!Connections.isRoot(A.R)! \item \lstinline!Connections.rooted(A.R)! + \item + \lstinline!Connections.uniqueRootIndices! \end{itemize} \end{itemize} From e36f891e1a97187a958c58eb9382eea8bc12c5f5 Mon Sep 17 00:00:00 2001 From: HOS Date: Thu, 5 Jun 2025 17:42:12 +0200 Subject: [PATCH 2/2] Copied more from Modelica_StateGraph2 --- chapters/connectors.tex | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/chapters/connectors.tex b/chapters/connectors.tex index ad1afad18..c703085d4 100644 --- a/chapters/connectors.tex +++ b/chapters/connectors.tex @@ -816,7 +816,7 @@ \subsection{Connection Graphs and Their Operators}\label{overconstrained-equatio {\lstinline!Connections.potentialRoot(a.R, $\ldots$)!} & Potential root node & \Cref{modelica:Connections.potentialRoot}\\ {\lstinline!Connections.isRoot(a.R)!} & Predicate for being selected as root & \Cref{modelica:Connections.isRoot}\\ {\lstinline!Connections.rooted(a.R)!} & Predicate for being closer to root & \Cref{modelica:Connections.rooted}\\ -{\lstinline!Connections.uniqueRoot(a.R, "msg")!} & Define a unique root node & \Cref{modelica:Connections.uniqueRoot}\\ +{\lstinline!Connections.uniqueRoot(a.R, msg)!} & Define a unique root node & \Cref{modelica:Connections.uniqueRoot}\\ {\lstinline!Connections.uniqueRootIndices(a.R, b.R)!} & Checking structure of root indices & \Cref{modelica:Connections.uniqueRootIndices}\\ \hline \end{tabular} @@ -912,12 +912,13 @@ \subsection{Connection Graphs and Their Operators}\label{overconstrained-equatio \end{lstlisting}\end{synopsis} \begin{semantics} The overdetermined type or record instance \lstinline!R! in connector instance \lstinline!a! is a \firstuse[definite root node]{(definite) root node}\index{root node!definite} in a virtual connection graph. -If there are any other roots (normal, unique, or potential) that is an error and the message argument will be used in the diagnostics. -If two unique roots are connected and the message arguments are different either or both arguments may be used. +The input \lstinline!a! may be an array, in which case the operator is applied to each element of the array. +Every virtual state diagram graph must have exactly one \lstinline!uniqueRoot! definition (and no normal or potential roots), before breakable branches are removed. +The second argument is a message that shall be reported if the root is not unique together with the component paths of the roots; if two unique roots are connected and the message arguments are different either or both arguments may be used. \begin{nonnormative} This definition shall be used if in a model with connector \lstinline!a! the overdetermined record \lstinline!a.R! is (consistently) assigned, e.g., from a parameter expressions, and the overdetermined connectors do not allow multiple roots. -It is used for the \lstinline!Modelica_StateGraph2!. +It is used for the \lstinline!Modelica_StateGraph2! library. \end{nonnormative} \end{semantics} \end{operatordefinition} @@ -927,10 +928,15 @@ \subsection{Connection Graphs and Their Operators}\label{overconstrained-equatio Connections.uniqueRoot(a.R, b.R, msg) \end{lstlisting}\end{synopsis} \begin{semantics} -Returns an index for the connections between a and b, where msg is used in case of error. +The arguments \lstinline!a.R! and \lstinline!b.R! shall be vectors of overdetermined types or record instances, and \lstinline!size(b.R, 1)<=size(a.R, 1)!. +The arguments \lstinline!a.R! must be unique roots. +The result is an integer vector, \lstinline!rootIndices!, of length \lstinline!size(a.R, 1)! containing a permutation of \lstinline!1:size(a.R, 1)! such that: +There is a (unique) path from \lstinline!a[rootIndices[i]].R! to \lstinline!b[i].R! if \lstinline!i<=size(b.R,1)!. +There is no path from \lstinline!a[rootIndices[i]].R! to any \lstinline!b.R! if \lstinline!i>size(b.R,1)!. +In case no such vector exist an error message should be given and include the third argument \lstinline!msg!. \begin{nonnormative} -This is used for checking parallel connections in \lstinline!Modelica_StateGraph2!. +This is used for checking parallel connections in the \lstinline!Modelica_StateGraph2! library. \end{nonnormative} \end{semantics} \end{operatordefinition}