2

I am writting my thesis and really like to be able to make some equations like the one shown in the picture but don't know how. Your help is really appreciated.

https://towardsdatascience.com/particle-swarm-optimization-visually-explained-46289eeb2e14e

Image taken from : https://towardsdatascience.com/particle-swarm-optimization-visually-explained-46289eeb2e14

1 Answers1

5

Here is my attempt with tikz:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{amsmath}
\tikzset{mystyle/.style={minimum height=2cm,rounded corners=3mm,anchor=base,
label={[anchor=south]south:{\scriptsize\bfseries\textsf{#1}}}}}
\begin{document}
\[
\begin{aligned}
P_i^{t+1} &= P_i^t+V_i^{t+1}\\
V_i^{t+1} &=
\tikz[baseline]{
    \node[fill=gray!20,mystyle=Inertia\strut] (t1)
    {$w V_i^t$}} + 
\tikz[baseline]{
    \node[fill=magenta!20,mystyle=Cognitive(Personal)] (t2)
    {$c_1 r_1\left(P_{best(i)}^t - P_i^t\right)$}} + 
\tikz[baseline]{
    \node[fill=teal!20,mystyle=Social(Global)] (t3)
    {$c_2 r_2\left(P_{bestglobal}^t-P_i^t\right)$}}
\end{aligned}
\]
\end{document}

enter image description here

Andrey L.
  • 1,794