1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
% ==================================================
% PySwarms API
% Author: Lester James V. Miranda
% ==================================================
\documentclass[preview, convert={outfile=\jobname.png, density=300}]{standalone}
\usepackage[usenames, dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{tikz-uml}
\renewcommand\familydefault{\sfdefault}
\usetikzlibrary{
shapes,
arrows,
positioning,
fit,
calc,
backgrounds,
shadows.blur,
}
% Define some colors
\definecolor{gold}{RGB}{255,215,0}
\definecolor{pyblue}{RGB}{7,78,104}
\begin{document}
\tikzumlset{fill class=gold}
\begin{tikzpicture}[
textbox/.style={fill=none, align=left, minimum height=0.7cm, minimum width=0.7cm,
text width=5.0cm, text=black}
]
% High-level packages
\begin{umlpackage}[fill=pyblue,text=white,x=0.21]{Optimizers}
% Global best PSO
\umlsimpleclass{GlobalBestPSO}
% Local best PSO
\umlsimpleclass[right=5mm of GlobalBestPSO]{LocalBestPSO}
% Binary PSO
\umlsimpleclass[right=5mm of LocalBestPSO]{BinaryPSO}
% Foo PSO
\umlsimpleclass[right=5mm of BinaryPSO,fill=magenta!50]{FooPSO}
\end{umlpackage}
% Base packages
\begin{umlpackage}[fill=pyblue,text=white,y=-5]{Base}
% Swarm Optimizer
\umlclass{SwarmOptimizer}{
n\_particles : int\\dimensions : int
}{optimize(), reset()}
% Discrete Swarm Optimizer
\umlclass[right=5mm of SwarmOptimizer]{DiscreteSwarmOptimizer}{
n\_particles : int\\dimensions : int
}{optimize(), reset()}
% Foo Swarm Optimizer
\umlclass[right=5mm of DiscreteSwarmOptimizer, fill=magenta!50]{FooSwarmOptimizer}{
n\_particles : int\\dimensions : int
}{optimize(), reset()}
\end{umlpackage}
% Backend packages
\begin{umlpackage}[fill=pyblue,text=white,x=0.56,y=-10]{Backend}
% Swarm Backend
\umlclass{Swarm}{
position : numpy.ndarray,\\
velocity : numpy.ndarray,\\
options : dict
}{}
% Topology Backend
\umlclass[right=5mm of Swarm]{Topology}{
}{compute\_gbest(),\\
compute\_position(),\\
compute\_velocity()}
% Foo Topology Backend
\umlclass[right=5mm of Topology, fill=magenta!50]{FooTopology}{
}{compute\_gbest(),\\
compute\_position(),\\
compute\_velocity()}
\end{umlpackage}
\umlimport{Base}{Optimizers}
\umlimport{Backend}{Base}
% Annotations
\node[textbox] (annotOptimizers) [right= of Optimizers]
{\small
High-level, off-the-shelf swarm optimization
algorithms
};
\node[textbox] at (Base -| annotOptimizers)
{\small
Base classes for solving different problem types:
SwarmOptimizer for single-continuous, DiscreteSwarmOptimizer for
discrete, etc.
};
\node[textbox] at (Backend -| annotOptimizers)
{\small
Contains the Swarm dataclass for keeping swarm attributes
and Topology for governing swarm behavior.
};
\end{tikzpicture}
\end{document}
|