Is it possible to create flow charts with forest or tikz?
-
1Welcome to Tex.SE. Can you show us how far you could progress by yourself... so that people on this forum could help you out where you get stuck ?– Partha D.May 19, 2021 at 1:28
-
Have you checked out TikZ with shapes, arrows and positioning?– DavislorMay 19, 2021 at 2:05
-
What have you tried?– holaMay 19, 2021 at 2:58
1 Answer
Here is my attempt at re-creating your diagram. It is not the most elegant solution maybe, as it contains a lot of manual shifting of nodes, but it should work as a starting point.
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,shapes,arrows,fit,decorations,decorations.text,calc,decorations.pathreplacing}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{palatino}
\begin{document}
\begin{tikzpicture}[
block/.style={draw,thick,rectangle,minimum height=2cm,minimum width=3cm,font=\bfseries,align=center,text width=2.5cm},
number/.style={draw,circle,minimum size=7mm,inner sep=3pt},
arrow/.style={draw,thick,->,>=stealth},
numarrow/.style={arrow,shorten >=.2cm,shorten <=.2cm},
node distance = 2cm]
\clip (-3.5cm,-6cm) rectangle ++(14.7cm,12.5cm);
\begin{scope}[node distance = .75cm]
\node[number] (three) {3};
\node[number,above=of three] (two) {2};
\node[number,above=of two] (one) {1};
\node[below=of three] (dots) {\vdots};
\node[number,below=of dots] (n) {n};
\node[draw,red,thick,dash dot,ellipse,fit={(one) (n)}] (ellipse) {};
\node[above = of ellipse, font=\bfseries,yshift=-.75cm] {agent};
\end{scope}
\node[block,xshift=4cm] at (three.east) (coord) {Coordinator};
\node[block,right=of coord] (global) {Global Parameters};
\draw[arrow] (coord) -- (global) node[anchor=south,midway,font=\small]{$\frac1n\sum\Delta\theta$} node[anchor=north,midway,font=\small] {$\frac1n\sum\Delta w$};
\draw[decoration={text along path,text={Update {$\theta$}, w},text align={center},raise=1mm,reverse path},decorate] (global) to[out=290,in=350] (ellipse.south);
\draw[arrow,red,dashed,shorten >=.3cm] (global) to[out=290,in=350] (ellipse.south);
\foreach \i in {one, two, three, n} {
\draw[numarrow] (\i) -- (coord) node[anchor=south,font=\footnotesize,midway,sloped] {$\Delta\theta$, $\Delta$ w};
\draw[arrow,<-] ($(\i.west)+(-3mm,2mm)$) -- ++(-1.5cm,0) node[anchor=south,midway,font=\small] {$r, s_{t+1}$};
\draw[arrow] ($(\i.west)+(-3mm,-2mm)$) -- ++(-1.5cm,0) node[anchor=north,midway,font=\small] {$a$};
}
\draw [decoration={brace,amplitude=10pt},decorate] ($(one.north east)+(2mm,0)$) -- ++(2.5cm,0cm) node[midway,anchor=south,font=\footnotesize,text width=2cm,align=center,minimum height=1.5cm] {synchronous update};
\node[draw, thick, minimum width=8cm, minimum height=1.0cm, rectangle, rotate=90, left = of three, anchor=south,font=\bfseries] {Environment};
\end{tikzpicture}
\end{document}