-1

enter image description here

Is it possible to create flow charts with forest or tikz?

3
  • 1
    Welcome 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?
    – Davislor
    May 19, 2021 at 2:05
  • What have you tried?
    – hola
    May 19, 2021 at 2:58

1 Answer 1

4

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}

Image of output

1
  • +1. I'd use math mode for numbers in circled nodes.
    – Sigur
    May 19, 2021 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.