ArtificialIntelligence
Genetic Crossover

Description

The code above produces a simple TikZ diagram that shows a single point of crossover between two parent chromosomes during genetic algorithm crossover. The diagram consists of two parallel nodes on the left and right sides, each of which displays a string of digits representing a chromosome. A dashed line indicates the point of crossover, and an arrow connects the two nodes to indicate the crossover operation. The textls command is used to adjust the letter spacing of the digits in the chromosome strings. The document class is set to standalone, which produces a single PDF image output. The fontenc package is used to set the font encoding to T1, and the lmodern and microtype packages are used to improve the overall appearance of the text.

Keywords

tikz, draw, dashed, node, text width, textls, arrow, midways

Source Code

ArtificialIntelligence

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\begin{document}
\begin{tikzpicture}
\node[draw=none, text width=3.5cm] at (0, 0)   (start) {Parent 1: \textls[100]{1324421} \hfill \newline Parent 2: \textls[100]{2751421}};
\draw[thick,dashed] (0.45,0.5) -- (0.45,-0.5);
\draw[->] (1.5, 0) -- (3, 0) node[below,midway] {crossover};
 
\node[draw=none, text width=3.5cm] at (4.9, 0)   (start) {Parent 1: \textls[100]{1321421} \hfill \newline Parent 2: \textls[100]{2754421}};
\draw[thick,dashed] (5.35,0.5) -- (5.35,-0.5);
% \node[draw=none, text width=3cm] at (3.5, 0)   (start) {Parent 2: 2754421};
\end{tikzpicture}
\end{document}
Deploy to Overleaf