...

/

Solving the One-Max Problem Again

Solving the One-Max Problem Again

Learn how our defined framework can solve the One-Max problem along with seeing a brief overview of what to expect in the next chapter.

Applying our framework to the One-Max problem

With our framework built, it’s time to apply it to the One-Max problem. Firstly, open a terminal and create a new file in the scripts directory named one_max.exs. This has already been done.

Next, open the one_max.exs file. Now, think about what the framework already accomplishes and what parts of the problem need to be defined. What are the problem-specific parameters needed to pass into run?

Once the parameters are determined, we’ll start defining them. Logically, the first one is how we encode chromosomes. Remember, for the One-Max problem, we’re looking for the maximum sum of a bitstring of length N. To keep things consistent, the length should be 1000. This means the solutions should be bitstrings of length N.

To define the genotype, add the ...

Ask