2

I wish to reproduce the following diagram in tikz (Source: Matlab):
enter image description here
So far, I have managed to come up with the main nodes though I am struggling to add the arrows. Below is my MWE which I managed to come up with after going through the solution at Tikz flow chart coloring.

\documentclass[tikz,multi,border=10pt]{standalone}
\usetikzlibrary{shadows,arrows.meta,positioning,backgrounds,fit,chains,scopes}

% Define block styles \tikzset{% materia/.style={draw, fill=blue!20, text width=6.0em, text centered, minimum height=1.5em,drop shadow}, etape/.style={materia, text width=8em, minimum width=10em, minimum height=3em, rounded corners, drop shadow}, linepart/.style={draw, thick, color=black!50, -LaTeX, thick}, line/.style={draw, thick, color=black!50, -LaTeX}, ur/.style={draw, text centered, minimum height=0.01em}, back group/.style={fill=yellow!20,rounded corners, draw=black!50, thick, inner xsep=15pt, inner ysep=10pt}, }

\newcommand{\transreceptor}[3]{% \path [linepart] (#1.east) -- node [above] {\scriptsize #2} (#3);}

\begin{document} \begin{tikzpicture} [ start chain=p going above, every on chain/.append style={etape}, every join/.append style={line}, node distance=1 and -.25, ] { \node [on chain] {\textbf{ENVIRONMENT}}; \node [on chain, join] {REINFORCEMENT LEARNING ALGORITHM}; \node [on chain, join] {POLICY}; }

    \begin{scope}[on background layer]
        \node (bk1) [back group] [fit=(p-2) (p-3)] {};
    \end{scope}

    \path (bk1.east)+(+6.0,0) node (ur1)[ur] {};
    \transreceptor{bk1}{Action $A_t$}{ur1};
\end{tikzpicture}

\end{document}

The MWE is producing the following output:
enter image description here

CarLaTeX
  • 62,716
itc
  • 657

1 Answers1

5

enter image description here

\documentclass[tikz, margin=10pt]{standalone}
\usetikzlibrary{arrows.meta,
                backgrounds,
                chains,
                ext.paths.ortho,
                fit,
                positioning,
                quotes,
                scopes, shadows}

% Define block styles \tikzset{% arr/.style = {-Latex}, box/.style = {draw=#1, rounded corners, fill=#1!30, minimum width=11em, minimum height=3em, text width=\pgfkeysvalueof{/pgf/minimum width}-2*\pgfkeysvalueof{/pgf/inner xsep}, align=flush center, on chain, drop shadow}, box/.default = orange, dot/.style = {circle, fill, inner sep=2pt, node contents={}}, every join/.style = {arr}, FIT/.style = {draw=blue, thick, rounded corners, fill=blue!30, inner sep=5 mm, yshift=2mm, fit=#1}, lbl/.style = {font=\footnotesize\linespread{0,84}\selectfont, align=center} } \begin{document} \begin{tikzpicture}[ node distance = 1 and 0.5, start chain = p going above, ] \node [box=blue] {\textbf{ENVIRONMENT}}; \node [box, join] {REINFORCEMENT LEARNING ALGORITHM}; \node [box, join] {POLICY};

\node (d1) [dot, left=of p-3.west]; \node (d2) [dot,right=of p-3.east];

\scoped[on background layer] \node (bk1) [FIT=(d1) (d2) (p-2) (p-3), label={[font=\bfseries,anchor=north]north:AGENT}] {};

\coordinate (a1) at (p-3 -| bk1.west); \coordinate (a2) at (p-3 -| bk1.east); \begin{scope}[arr] \draw (a1) -- (p-3); \draw (p-3) -- (a2); \draw (d1) |- (p-2); \draw (d2) |- (p-2); % \draw (p-1) -- (bk1); \draw[arr] (p-1.west) -|- [distance=37mm] (a1) node[lbl, pos=0.88, below] {OBSERVATION\$Q_t$}; \draw[arr] (a2) -|- [distance=-27mm] (p-1.east) node[lbl, pos=0.12, below] {ACTION\$Q_t$}; \end{scope} \path (p-1) -- node[lbl, right] {REVARD\ $R_t$} (bk1); \end{tikzpicture} \end{document}

Zarko
  • 296,517