ArtificialIntelligence
Ga

Description

The code above defines a simple flowchart using the TikZ package in LaTeX. The flowchart consists of several blocks representing different stages of a genetic algorithm. The blocks are defined using the \texttt{tikzstyle} command with different styles, such as \texttt{decision} and \texttt{block}. The edges between the blocks are drawn using the \texttt{line} and \texttt{path} styles. The nodes are positioned using the \texttt{positioning} TikZ library.

The flowchart starts with a block for population initialization, followed by fitness assignment, selection, crossover, mutation, and inversion. The flow then cycles back to the selection block until a termination criterion is met, at which point the algorithm finishes and reaches the final "Done" block.

Keywords

Keywords: tikz, nodes, edges, styles, diamond, rectangle, draw, fill, text width, text badly centered, node distance, inner sep, rounded corners, minimum height, color, latex'.

Source Code

ArtificialIntelligence

\documentclass{standalone}
 
\usepackage[margin=1.0in]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,positioning}
 
\begin{document}
\tikzstyle{decision}=[diamond, draw, fill=yellow!20,
  text width=4em, text badly centered, node distance=3cm,
  inner sep=0pt]
\tikzstyle{block}=[rectangle, draw, fill=blue!20, 
  text width=8em, text badly centered, rounded corners,
  minimum height=4em]
\tikzstyle{line}=[draw, very thick, color=black!75, -latex']
 
\tikzstyle{path}=[draw, very thick, color=black!75, -]
 
\begin{tikzpicture}[node distance=2cm, auto]
  % Place nodes
  \node [block] (pop_init) {Population Initialization};
  \node [block, below of=pop_init] (fit_ass)
        {Fitness Assignment};
  \node [block, below of=fit_ass] (selection)
        {Selection};
    \node [draw=none, right of=selection] (pointer)
            {};
  \node [block, below of=selection] (crossover)
        {Crossover};
        
  \node [block, below of=crossover] (mutation)
        {Mutation};
  
    \node [block, below of=mutation] (inversion)
        {Inversion};
        
  \node [block, left = 2cm of selection] (done)
        {Done};
        
    
  % Draw edges
  \path [line] (pop_init) -- (fit_ass);
  \path [line] (fit_ass) -- (selection);
  \path [line] (selection) -- (crossover);
    \path [line] (crossover) -- (mutation);
    \path [line] (mutation) -- (inversion);
  \path [path] (inversion) -| (pointer.center);
  
  \path [line] (pointer.center) -- (selection);
  
    \path [line] (selection) -- (done);
\end{tikzpicture}
\end{document}
Deploy to Overleaf