Skip to content

Commit

Permalink
update to accommodate refactoring of Individual to Record
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasWeise committed Oct 20, 2020
1 parent d8e4d50 commit 2bf8b8a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions book/metaheuristics/antColonyOptimization/README.md
Expand Up @@ -30,7 +30,8 @@ In each step, a vertex is added to the path until no nodes can be added anymore
The choice which vertex to add is probabilistic.
It depends on two factors: the model $M$ and the heuristic information $H$.

The model $M$ is a two-dimensional table called "pheromone matrix."
\text.block{definition}{acoPheromoneMatrix}{The model $M$ used in ACO is a two-dimensional table called *pheromone matrix* and the values stored in it are called *pheromones*.}

Each row $i\in 0\dots(v-1)$ stands for one of the vertices and holds a value $\arrayIndexx{M}{i}{j}$ for each other vertex $j\in 0\dots(v-1)$ with $j\neq i$.
The higher the value $\arrayIndexx{M}{i}{j}$, the more likely should it be that the edge $(i,j)$ is added to the path, i.e., that vertex $j$ follows after vertex $i$.

Expand Down Expand Up @@ -72,6 +73,8 @@ The model sampling then works as follows:
g. Set $\arrayIndex{\sespel}{i}=\arrayIndex{N}{k}$, i.e., append the vertex to $\sespel$.
6. Return the completed path $\sespel$.

\text.block{definition}{acoAnt}{A completed path $\sespel$ sampled from the model in ACO is called an *ant*.}

We implement [@eq:aco:vertex:probability] in *lines 5.e* and *5.f*.
Obviously, if there is only $v'=1$ node that could be added, then it will have probability 1 and we do not need to actually compute the equation.
If $v'>1$, then we need to compute the product $\arrayIndex{P}{j}$ of the model value $\arrayIndexx{M}{\arrayIndex{\sespel}{i-1}}{\arrayIndex{N}{j}}^{\alpha}$ and heuristic value $\arrayIndexx{H}{\arrayIndex{\sespel}{i-1}}{\arrayIndex{N}{j}}^{\beta}$ for each vertex.
Expand All @@ -95,7 +98,7 @@ In the traditional ACO approach, the model will be sampled $\lambda>0$ time
Here, we discuss the model update procedure for the first ACO algorithm, the *Ant System* (AS) [@DMC1996ASOBACOCA; @D1992OLANA] and its improved version, the *Max-Min Ant System* (MMAS) [@SH2000MMAS].

Let $\searchSpaceSubset$ be the list of the $\mu$ selected paths.
Then, the model values (called "pheromones") in the matrix $M$ are updated as follows:
Then, the model values in the matrix $M$ are updated as follows:

$$ \arrayIndexx{M}{i}{j} = \min\{U, \max\{L, (1-\rho)\arrayIndexx{M}{i}{j} + \sum_{\forall \sespel\in \searchSpaceSubset} \arrayIndexx{\tau^{\sespel}}{i}{j} \}\} $$ {#eq:aco:update}

Expand Down
Expand Up @@ -95,7 +95,7 @@ The search space $\searchSpace$ is represented by the generic parameter&nbs
In our previous example, it could be equivalent the `double[2]`.
The model used in our example would internally store four `double` values, namely the means and standard deviations along both dimensions.

We can update the model by passing $\mu$ samples from the search space `X` to the `update` method.
We can update the model by passing $\mu$&nbsp;samples from the search space `X` to the `update` method in form of the `Record<X>` records we already used in our implementation of EAs.
The source for these samples can be any `Java` collection (all of which implement `Iterable`).
In our example in the previous section, the `update` method could iterate over the `double[2]` values provided to it and compute, for both of their dimensions, the means and standard deviations.

Expand Down
8 changes: 5 additions & 3 deletions book/metaheuristics/evolutionaryAlgorithm/README.md
Expand Up @@ -40,7 +40,9 @@ The basic $(\mu+\lambda)$&nbsp;Evolutionary Algorithm works as follows:
\repo.listing{lst:EAwithoutCrossover}{An excerpt of the implementation of the Evolutionary Algorithm **without** recombination.}{java}{src/main/java/aitoa/algorithms/EA.java}{}{relevant,withoutcrossover}

This algorithm is implemented in [@lst:EAwithoutCrossover].
Basically, it starts out by creating and evaluating&nbsp;$\mu+\lambda$ random candidate solutions (*point&nbsp;3*).
There, we make use of instances of the utility class `Record<X>`, which holds one point&nbsp;`x` in the search space along with their corresponding objective values stored in the field&nbsp;`quality`.

Basically, the algorithm starts out by creating and evaluating&nbsp;$\mu+\lambda$ random candidate solutions (*point&nbsp;3*).

\text.block{definition}{generationEA}{Each iteration of the main loop of an Evolutionary Algorithm is called a *generation*.}

Expand Down Expand Up @@ -410,15 +412,15 @@ We will only investigate one very simple approach:
Avoiding objective value duplicates&nbsp;[@S2012NIEA; @FHN2007RAOSDM].
In the rest of this section, we will call this method *clearing*, as it can be viewed as the strictest possible variant of the clearing&nbsp;[@P1996ACPAANMFGA; @P1997AEHCTFS] applied in the objective space.

Put simply, we will ensure that all individuals that "survive" selection have different objective values.
Put simply, we will ensure that all records that "survive" selection have different objective values.
If two good solutions have the same objective value, we will discard one of them.
This way, we will ensure that our population remains diverse.
No single candidate solution can take over the population.

#### The Algorithm (with Recombination and Clearing)

We can easily extend our $(\mu+\lambda)$&nbsp;EA with recombination from [@sec:evolutionaryAlgorithmWithRecombinationImpl] to remove duplicates of the objective value.
We need to consider that a full population of $\mu+\lambda$ individuals may contain less than $\mu$ different objective values.
We need to consider that a full population of $\mu+\lambda$ records may contain less than $\mu$ different objective values.
Thus, in the selection step, we may obtain $1\leq u \leq \mu$ elements, where $u$ can be different in each generation.
If $u=1$, we cannot apply the binary operator regardless of the crossover rate&nbsp;$cr$.

Expand Down

0 comments on commit 2bf8b8a

Please sign in to comment.