Customizing Selection in Your Framework

Learn how to customize your genetic algorithm framework to accept different selection rates.

Incorporating the new selection hyperparameters

In the lesson Understanding Hyperparameters, we briefly learned about hyperparameters and how to pass configuration options to the framework. At the time, the only hyperparameter we could change was population size.

Selection introduces two more hyperparameters: selection strategy and selection rate. In this lesson, we’ll tweak your framework to allow for changes in both.

Creating a selection toolbox

Before beginning, we’ll want a place to store some common selection strategies that we may need to solve some of the problems we encounter. Over here, we will create a new folder called toolbox which will be our toolbox of genetic operators. We will be implementing modules for selection, crossover, and mutation in the toolbox so we always have them available when we need them.

For now, create selection.ex and add the following module definition:

Get hands-on with 1200+ tech skills courses.