# Schema (genetic algorithms)

A schema is a template in computer science used in the field of genetic algorithms that identifies a subset of strings with similarities at certain string positions. Schemata are a special case of cylinder sets; and so form a topological space.[1]

## Description

For example, consider binary strings of length 6. The schema 1**0*1 describes the set of all words of length 6 with 1's at the first and sixth positions and a 0 at the fourth position. The * is a wildcard symbol, which means that positions 2, 3 and 5 can have a value of either 1 or 0. The order of a schema is defined as the number of fixed positions in the template, while the defining length ${\displaystyle \delta (H)}$ is the distance between the first and last specific positions. The order of 1**0*1 is 3 and its defining length is 5. The fitness of a schema is the average fitness of all strings matching the schema. The fitness of a string is a measure of the value of the encoded problem solution, as computed by a problem-specific evaluation function.

### Length

The length of a schema ${\displaystyle H}$, called ${\displaystyle N(H)}$, is defined as the total number of nodes in the schema. ${\displaystyle N(H)}$ is also equal to the number of nodes in the programs matching ${\displaystyle H}$.[2]

### Disruption

If the child of an individual that matches schema H does not itself match H, the schema is said to have been disrupted.[2]

## Propagation of schema

In evolutionary computing such as genetic algorithms and genetic programming, propagation refers to the inheritance of characteristics of one generation by the next. For example, a schema is propagated if individuals in the current generation match it and so do those in the next generation. Those in the next generation may be (but don't have to be) children of parents who matched it.

## The Expansion and Compression Operators

Recently schema have been studied using order theory.[3]

Two basic operators are defined for schema: expansion and compression. The expansion maps a schema onto a set of words which it represents, while the compression maps a set of words on to a schema.

In the following definitions ${\displaystyle \Sigma }$ denotes an alphabet, ${\displaystyle \Sigma ^{l}}$ denotes all words of length ${\displaystyle l}$ over the alphabet ${\displaystyle \Sigma }$, ${\displaystyle \Sigma _{*}}$ denotes the alphabet ${\displaystyle \Sigma }$ with the extra symbol ${\displaystyle *}$. ${\displaystyle \Sigma _{*}^{l}}$ denotes all schema of length ${\displaystyle l}$ over the alphabet ${\displaystyle \Sigma _{*}}$ as well as the empty schema ${\displaystyle \epsilon _{*}}$.

For any schema ${\displaystyle s\in \Sigma _{*}^{l}}$ the following operator ${\displaystyle {\uparrow }s}$, called the ${\displaystyle expansion}$ of ${\displaystyle s}$, which maps ${\displaystyle s}$ to a subset of words in ${\displaystyle \Sigma ^{l}}$:

${\displaystyle {\uparrow }s:=\{b\in \Sigma ^{l}|b_{i}=s_{i}{\mbox{ or }}s_{i}=*{\mbox{ for each }}i\in \{1,...,l\}\}}$

Where subscript ${\displaystyle i}$ denotes the character at position ${\displaystyle i}$ in a word or schema. When ${\displaystyle s=\epsilon _{*}}$ then ${\displaystyle {\uparrow }s=\emptyset }$. More simply put, ${\displaystyle {\uparrow }s}$ is the set of all words in ${\displaystyle \Sigma ^{l}}$ that can be made by exchanging the ${\displaystyle *}$ symbols in ${\displaystyle s}$ with symbols from ${\displaystyle \Sigma }$. For example, if ${\displaystyle \Sigma =\{0,1\}}$, ${\displaystyle l=3}$ and ${\displaystyle s=10*}$ then ${\displaystyle {\uparrow }s=\{100,101\}}$.

Conversely, for any ${\displaystyle A\subseteq \Sigma ^{l}}$ we define ${\displaystyle {\downarrow }{A}}$, called the ${\displaystyle compression}$ of ${\displaystyle A}$, which maps ${\displaystyle A}$ on to a schema ${\displaystyle s\in \Sigma _{*}^{l}}$:

${\displaystyle {\downarrow }A:=s}$
where ${\displaystyle s}$ is a schema of length ${\displaystyle l}$ such that the symbol at position ${\displaystyle i}$ in ${\displaystyle s}$ is determined in the following way: if ${\displaystyle x_{i}=y_{i}}$ for all ${\displaystyle x,y\in A}$ then ${\displaystyle s_{i}=x_{i}}$ otherwise ${\displaystyle s_{i}=*}$. If ${\displaystyle A=\emptyset }$ then ${\displaystyle {\downarrow }A=\epsilon _{*}}$. One can think of this operator as stacking up all the items in ${\displaystyle A}$ and if all elements in a column are equivalent, the symbol at that position in ${\displaystyle s}$ takes this value, otherwise there is a wild card symbol. For example, let ${\displaystyle A=\{100,000,010\}}$ then ${\displaystyle {\downarrow }A=**0}$.

Schemata can be partially ordered. For any ${\displaystyle a,b\in \Sigma _{*}^{l}}$ we say ${\displaystyle a\leq b}$ if and only if ${\displaystyle {\uparrow }a\subseteq {\uparrow }b}$. It follows that ${\displaystyle \leq }$ is a partial ordering on a set of schemata from the reflexivity, antisymmetry and transitivity of the subset relation. For example, ${\displaystyle \epsilon _{*}\leq 11\leq 1*\leq **}$. This is because ${\displaystyle {\uparrow }\epsilon _{*}\subseteq {\uparrow }11\subseteq {\uparrow }1*\subseteq {\uparrow }**=\emptyset \subseteq \{11\}\subseteq \{11,10\}\subseteq \{11,10,01,00\}}$.

The compression and expansion operators form a Galois connection, where ${\displaystyle \downarrow }$ is the lower adjoint and ${\displaystyle \uparrow }$ the upper adjoint.[3]

## The Schematic Completion and The Schematic Lattice

For a set ${\displaystyle A\subseteq \Sigma ^{l}}$, we call the process of calculating the compression on each subset of A, that is ${\displaystyle \{{\downarrow }X|X\subseteq A\}}$, the schematic completion of ${\displaystyle A}$, denoted ${\displaystyle {\mathcal {S}}(A)}$.[3]

For example, let ${\displaystyle A=\{110,100,001,000\}}$. The schematic completion of ${\displaystyle A}$, results in the following set:

${\displaystyle {\mathcal {S}}(A)=\{001,100,000,110,00*,*00,1*0,**0,*0*,***,\epsilon _{*}\}}$

The poset ${\displaystyle ({\mathcal {S}}(A),\leq )}$ always forms a complete lattice called the schematic lattice.

The Schematic lattice formed from the schematic completion on the set ${\displaystyle A=\{111,011,001\}}$. Here the schematic lattice ${\displaystyle ({\mathcal {S}}(A),\leq )}$ is shown as a Hasse diagram.

The schematic lattice is similar to the concept lattice found in Formal concept analysis.