Skip to content

Commit

Permalink
Closed #2182
Browse files Browse the repository at this point in the history
Rewrite merging algorithm, and simplify example and add illegal example.
  • Loading branch information
HansOlsson committed May 10, 2019
1 parent 6753c72 commit 93631c6
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions chapters/synchronous.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1370,52 +1370,46 @@ \subsection{Inferencing of solverMethod}\doublelabel{inferencing-of-solvermethod

If a solverMethod is not explicitly associated with a partition, it is
inferred with a similar mechanism as for sub-clock inferencing, see
\autoref{sub-clock-inferencing}. The inferencing mechanism is defined using the operator
``solverExplicitlyDefined(c)'' which returns \textbf{true}, if a
solverMethod is explicitly associated with clock c and returns
\textbf{false} otherwise.
\autoref{sub-clock-inferencing}.

For every partitioning operator of \autoref{partitioning-operators}, two clocks c1 and c2
are defined for the input and the output argument of the operator,
respectively. Furthermore, for every equality and assignment of clocks,
c1 = c2 or c1 := c2, two clocks are defined as well. In all these cases,
the following statements are implicitly introduced:
For each sub-clock partition we build a set corresponding from this sub-clock partition.
These sets are then merged as follows: for each set without a specified solverMethod we merge it
with sets connected to it (these may contain a solverMethod); and this is repeated until it is not possible to merge more sets.

\begin{lstlisting}[language=modelica]
if solverExplicitlyDefined(c1) and solverExplicitlyDefined(c2) then
// o.k. (no action)
elseif not solverExplicitlyDefined(c1) and not solverExplicitlyDefined(c2) then
assert(c1.solverMethod == c2.solverMethod);
elseif solverExplicitlyDefined(c1) <>solverExplicitlyDefined(c2) then
c1.solverMethod = c2.solverMethod
end if;
\end{lstlisting}

The introduced set of, potentially underdetermined or overdetermined
constraints has to be solved. If no solution exists or if a solution is
contradictory on some clocks that are associated with clocked
discrete-time partitions, then this is ignored, since no solverMethod is
needed for such partitions.
\begin{itemize}
\item If this set contains multiple different solverMethods it is an error.
\item If the set contains continuous time-equations:
\begin{itemize}
\item If this set contains no solverMethod it is an error.
\item Otherwise we use the specified solverMethod.
\end{itemize}
\item If the set does not contain continuous time-equations there is no need for a solverMethod.
\end{itemize}

{[}\emph{Example:}

\begin{lstlisting}[language=modelica]
model InferenceTest "Specific clocks set on all partitions. Decouple constraint"
...
model InferenceTest
Real x(start=3) "Explicitly using ExplicitEuler";
Real y "Explicitly using ImplicitEuler method";
Real z "Inferred to use ExplicitEuler";
equation
// Physical model
der(x1) = -100*x1 + hold(z2);
// Controller submodels
der(z1) = -100*z1 + sample(x2,
Clock(Clock(1, 100), solverMethod="ImplicitEuler"));
w = 0.9*previous (w) + superSample(z1, 3);
when Clock(Clock(1,20),
solverMethod="ExplicitEuler") then
ww = superSample (w);
end when
der(z2) = -z2 + ww;
der(x)=-x+sample(1,Clock(Clock(1,10), solverMethod="ExplicitEuler"));
der(y)=subSample(x,2)+sample(1,Clock(Clock(2,10), solverMethod="ImplicitEuler"));
der(z)=subSample(x,2)+1;
end InferenceTest;

model IllegalInference
Real x(start=3) "Explicitly using ExplicitEuler";
Real y "Explicitly using ImplicitEuler method";
Real z;
equation
der(x)=-x+sample(1,Clock(Clock(1,10), solverMethod="ExplicitEuler"));
der(y)=subSample(x,2)+sample(1,Clock(Clock(2,10), solverMethod="ImplicitEuler"));
der(z)=subSample(x,4)+1+subSample(y);
end IllegalInference;
\end{lstlisting}
Here z is a continuous-time equation connected directly to both x and y partitions that have different solverMethod.
{]}

\section{Initialization of Clocked Partitions}\doublelabel{initialization-of-clocked-partitions}
Expand Down

0 comments on commit 93631c6

Please sign in to comment.