Using the New Framework in spelling word problem
Explore how to apply a new genetic algorithm framework in Elixir to solve a spelling problem. Learn to define the genotype, design a fitness function using string similarity, and set termination criteria to guide algorithm convergence. Understand the role of abstraction and encoding in solving optimization problems. Prepare for upcoming lessons on improving algorithm performance and testing.
We'll cover the following...
To illustrate the power of our new framework, we’ll use it to solve a new basic problem: spelling. We’ll teach your algorithm to spell an impossibly long word: “supercalifragilistic”.
Start by creating a new file called speller.exs in scripts and define a new problem:
Now define a Problem implementation for the tasks. In this chapter, we learned there are three parts to every problem: a genotype, a fitness function, and termination criteria.
The first thing to decide is the genotype. The goal is to spell “supercalifragilistic”, which is a 20-letter word. That means the search space is all 20-letter words. We can define the genotype like this:
The ...