フローチャートノード内のアニメーション化された tikz マトリックス

フローチャートノード内のアニメーション化された tikz マトリックス

私はTikzでアニメーションフローダイアグラムを作成しようとしています。そして、以下に示すように、フローダイアグラムのノード内でTikzマトリックスを使用したいと考えています。

ここに画像の説明を入力してください

アイデアとしては、行列AとBが次のように強調表示されるというものです。ここに画像の説明を入力してください

アニメーションが実行されるにつれて、色付きのボックスの位置が時間とともに変化します。Tikz マトリックスを入力しようとすると、数学ノードのサイズが適切に設定されません。フローチャート ノード内のマトリックス アルファのコードを以下に示します。

\node (out1) [data,on chain,join] {$\alpha,\beta$
 $
 \alpha =
 \begin{tikzpicture}[baseline=(m-2-1.base)]
 \matrix [{matrix of math nodes}, column sep=5pt, row sep=1pt,
     left delimiter=(,right delimiter=),ampersand replacement=\&] (m)
 {
  1 \& 1 \& 1 \& 0 \& 0 \\
  0 \& 0 \& 0 \& 1 \& 0 \\
  0 \& 0 \& 0 \& 0 \& 1 \\
 };
 \node[myNo=red, fit=(m-1-1) (m-1-3)] {};
 \node[myNo=green, fit=(m-2-4) (m-2-4)] {};
 \node[myNo=blue, fit=(m-3-5) (m-3-5)] {};
 \end{tikzpicture}
 $
 };

ご助力ありがとうございます。

ロマン

答え1

私は、Tikz および Animate パッケージを使用して、アニメーション化された Tikz フローチャート ソリューションを見つけることができました。理想的には、マトリックス要素の周囲のボックスでアニメーションを実行する方法を探していましたが、このソリューションは私が示そうとしていたものには適していました。

これが皆さんの役に立つことを願っています。

マトリックス要素の色を変更するのではなく、マトリックス内のボックスをアニメーション化する方法について何かアイデアがあれば、ぜひ教えてください。

ロマン

\documentclass[aspectratio=169]{beamer}

\mode<presentation> {
\usetheme{Madrid}
}
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{stmaryrd}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{animate}
\usepackage{ifthen}
\usepackage{color}
\usetikzlibrary{shapes,arrows,chains,fit,matrix}
%---------------------------------------------------------------------------
%   TIKZ COMMANDS
%---------------------------------------------------------------------------
\tikzset{
  myNo/.style={
    draw=#1, thick,
    inner sep=0pt,
    rounded corners
    },
  startstop/.style={
    rectangle,
    rounded corners,
    minimum width=2.5cm,
    minimum height=1cm,
    align=center,
    draw=black,
    fill=red!20
    },
  process/.style={
    rectangle,
    minimum width=2cm,
    minimum height=0.75cm,
    align=center,
    draw=black,
    fill=blue!10
    },
  data/.style={
    trapezium,
    trapezium left angle=70,
    trapezium right angle=-70,
    minimum width=2cm,
    minimum height=0.75cm,
    align=center,
    draw=black,
    fill=blue!10
    },
  decision/.style={
    diamond, 
    minimum width=0.75cm, 
    minimum height=0.75cm,
    align=center,
    draw=black,
    fill=green!20
    },
  arrow/.style={
    thick,->,>=stealth
    }
}

\begin{document}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\tiny
\begin{frame}
\frametitle{Weak interactions based system partitioning using binary LP}
\begin{columns}[c]

\column{.25\textwidth}
Given a \textbf{linear time invariant continuous time} controllable state space model defined by

\begin{equation} \label{eqn1}
\dot{x} = Ax + Bu
\end{equation}

where the matrix $A$ is the \textbf{state matrix} and the matrix $B$ is the 
\textbf{input matrix} respectively with the appropriate sizes for $N$ states 
and $M$ inputs, therefore, $x \in \mathbb{R}^{N}$ and $u \in 
\mathbb{R}^{M}$. Partitioning the system model (\ref{eqn1}) consists of 
decomposing the inputs as well as the states into groups representing 
subsystems. For a given number of partitions $P \in \llbracket 2;\min(N,M) 
\rrbracket$ and for any subsystem $p \in \llbracket 1;P \rrbracket$ the 
model of subsystem $p$ can be expressed as follows

\begin{equation} \label{eqn2}
\begin{aligned}
\dot{x}_{p} &= A_{pp} x_{p} + B_{pp} u_{p} \\
&+ \sum_{\substack{j=1 \\ j \neq p}}^{P} \big\{ A_{pj} x_{j} + B_{pj} u_{j}  \big\}
\end{aligned}
\end{equation}

with for all $p \in \llbracket 1;P \rrbracket$, $x_{p} \in \mathbb{R}^{N_{p}}$ and $u_{p} \in \mathbb{R}^{M_{p}}$.

\column{.75\textwidth}
\begin{center}
\begin{animateinline}[poster=first,controls,loop]{1} % 1 frames per sec
\multiframe{10}{iTime=1+1}{  % 10 frames
\begin{tikzpicture}[
  start chain=going below,
  every join/.style={arrow},
  node distance=0.4cm,
  scale=0.75,
  every node/.style={transform shape}]

% Nodes
\node (start) [startstop,on chain] {
$A =
\left( {\begin{array}{cccc}
    a_{11} & a_{12} & a_{13} & a_{14} \\
    a_{21} & a_{22} & a_{23} & a_{24} \\
    a_{31} & a_{32} & a_{33} & a_{34} \\
    a_{41} & a_{42} & a_{43} & a_{44} \\
\end{array} } \right)
$
$B =
\left( {\begin{array}{cccc}
    b_{11} & b_{12} & b_{13} & b_{14} \\
    b_{21} & b_{22} & b_{23} & b_{24} \\
    b_{31} & b_{32} & b_{33} & b_{34} \\
    b_{41} & b_{42} & b_{43} & b_{44} \\
\end{array} } \right)
$
$
P = 2
$
};
\node (in1) [process,on chain] {Interactions Minimization};
\ifthenelse{\iTime < 3}{ \node (out1) [data,on chain] {
    $
    \alpha =
    \left( {\begin{array}{cccc}
        ? & ? & ? & ? \\
        ? & ? & ? & ? \\
    \end{array} } \right)
    $
    $
    \beta =
    \left( {\begin{array}{cccc}
        ? & ? & ? & ? \\
        ? & ? & ? & ? \\
    \end{array} } \right)
    $};}{\ifthenelse{\iTime > 6}{\node (out1) [data,on chain] {
            $
            \alpha =
            \left( {\begin{array}{cccc}
                1 & 1 & 1 & 0 \\
                0 & 0 & 0 & 1 \\
            \end{array} } \right)
            $
            $
            \beta =
            \left( {\begin{array}{cccc}
                1 & 1 & 0 & 1 \\
                0 & 0 & 1 & 0 \\
            \end{array} } \right)
            $};}{\node (out1) [data,on chain] {
                    $
                    \alpha =
                    \left( {\begin{array}{cccc}
                        1 & 1 & 0 & 0 \\
                        0 & 0 & 1 & 1 \\
                    \end{array} } \right)
                    $
                    $
                    \beta =
                    \left( {\begin{array}{cccc}
                        1 & 1 & 0 & 0 \\
                        0 & 0 & 1 & 1 \\
                    \end{array} } \right)
                    $
};}}
\ifthenelse{\iTime < 4}{ \node (out2) [data,on chain] {
$A =
\left( {\begin{array}{cccc}
    a_{11} & a_{12} & a_{13} & a_{14} \\
    a_{21} & a_{22} & a_{23} & a_{24} \\
    a_{31} & a_{32} & a_{33} & a_{34} \\
    a_{41} & a_{42} & a_{43} & a_{44} \\
\end{array} } \right)
$
$B =
\left( {\begin{array}{cccc}
    b_{11} & b_{12} & b_{13} & b_{14} \\
    b_{21} & b_{22} & b_{23} & b_{24} \\
    b_{31} & b_{32} & b_{33} & b_{34} \\
    b_{41} & b_{42} & b_{43} & b_{44} \\
\end{array} } \right)
$
};}{\ifthenelse{\iTime > 7}{\node (out2) [data,on chain] {
$A =
\left( {\begin{array}{cccc}
    \textcolor{red}{a_{11}} & \textcolor{red}{a_{12}} & \textcolor{red}{a_{13}} & a_{14} \\
    \textcolor{red}{a_{21}} & \textcolor{red}{a_{22}} & \textcolor{red}{a_{23}} & a_{24} \\
    \textcolor{red}{a_{31}} & \textcolor{red}{a_{32}} & \textcolor{red}{a_{33}} & a_{34} \\
    a_{41} & a_{42} & a_{43} & \textcolor{blue}{a_{44}} \\
\end{array} } \right)
$
$B =
\left( {\begin{array}{cccc}
    \textcolor{red}{b_{11}} & \textcolor{red}{b_{12}} & b_{13} & \textcolor{red}{b_{14}} \\
    \textcolor{red}{b_{21}} & \textcolor{red}{b_{22}} & b_{23} & \textcolor{red}{b_{24}} \\
    \textcolor{red}{b_{31}} & \textcolor{red}{b_{32}} & b_{33} & \textcolor{red}{b_{34}} \\
    b_{41} & b_{42} & \textcolor{blue}{b_{43}} & b_{44} \\
\end{array} } \right)
$
};}{\node (out2) [data,on chain] {
$A =
\left( {\begin{array}{cccc}
    \textcolor{red}{a_{11}} & \textcolor{red}{a_{12}} & a_{13} & a_{14} \\
    \textcolor{red}{a_{21}} & \textcolor{red}{a_{22}} & a_{23} & a_{24} \\
    a_{31} & a_{32} & \textcolor{blue}{a_{33}} & \textcolor{blue}{a_{34}} \\
    a_{41} & a_{42} & \textcolor{blue}{a_{43}} & \textcolor{blue}{a_{44}} \\
\end{array} } \right)
$
$B =
\left( {\begin{array}{cccc}
    \textcolor{red}{b_{11}} & \textcolor{red}{b_{12}} & b_{13} & b_{14} \\
    \textcolor{red}{b_{21}} & \textcolor{red}{b_{22}} & b_{23} & b_{24} \\
    b_{31} & b_{32} & \textcolor{blue}{b_{33}} & \textcolor{blue}{b_{34}} \\
    b_{41} & b_{42} & \textcolor{blue}{b_{43}} & \textcolor{blue}{b_{44}} \\
\end{array} } \right)
$
};}}
\node (in2) [decision,on chain] {Controllability
\\
Check
};
\node (out3) [process,right of=out1,node distance=150pt] {Controllability Cuts};
\node (out4) [data,on chain] {Controllable Partitions};
% Draw
\draw[arrow] (start) -- node[right,xshift=5pt] {Inputs} (in1);
\draw[arrow] (in1) -- node[right,xshift=5pt] {Optimal Solution} (out1);
\draw[arrow] (out1) -- (out2);
\draw[arrow] (out2) -- (in2);
\draw[arrow] (in2.east) -| node[below,yshift=-5pt] {Not Controllable}  (out3.south);
\draw[arrow] (out3.north) |- node[above,yshift=5pt] {Cuts applied}  (in1.east);
\draw[arrow] (in2) -- node[right,xshift=5pt] {Controllable}(out4);
% Path
\begin{pgfonlayer}{background}
\ifthenelse{\iTime > 1}{
\path[draw,line width=5pt,-,blue!50] (start) edge node {} (in1);}{}

\ifthenelse{\iTime > 2}{
\path[draw,line width=5pt,-,red!50] (in1) edge node {} (out1);}{}

\ifthenelse{\iTime > 3}{
\path[draw,line width=5pt,-,red!50] (out1) edge node {} (out2);}{}

\ifthenelse{\iTime > 4 \AND \iTime < 6}{
\path[draw,line width=5pt,-,red!50] (out2) edge node {} (in2);
\path[draw,line width=5pt,-,red!50] (in2.east) -| (out3.south);}{}

\ifthenelse{\iTime > 5 \AND \iTime < 7}{
\path[draw,line width=5pt,-,red!50] (out3.north) |- (in1.east);}{}

\ifthenelse{\iTime > 6}{
\path[draw,line width=5pt,-,green!50] (in1) edge node {} (out1);}{}
\ifthenelse{\iTime > 7}{
\path[draw,line width=5pt,-,green!50] (out1) edge node {} (out2);}{}

\ifthenelse{\iTime > 8}{
\path[draw,line width=5pt,-,green!50] (out2) edge node {} (in2);}{}

\ifthenelse{\iTime > 9}{
\path[draw,line width=5pt,-,green!50] (in2) edge node {} (out4);}{}
\end{pgfonlayer}
\end{tikzpicture}
}  
\end{animateinline}
\end{center}
\end{columns}
\end{frame}
\end{document}

関連情報