...

/

Treating Chromosomes as Processes

Treating Chromosomes as Processes

Learn how to create an agent to treat chromosomes as processes.

Creating the Agent module

The strongest aspect of the BEAM is its ability to create and work with processes. We saw how easy it was to spin up new processes using the Task module in the last lesson. In this lesson, we’ll use the Agent module to accomplish parallelization in a different manner.

An Agent is an abstraction around the state. Agents allow us to keep track of state between entities. In the original genetic algorithm framework, you perform transformations on Chromosome structs. Using an Agent, we can replace these transformations with interactions between processes. These processes will naturally run in parallel, and our algorithms will achieve parallelism naturally.

Note: You probably won’t see significant performance increases using this approach on normal machines. Using this approach in practice requires a massively parallel system to be viable. It also requires some additional complexities to implement correctly.

In this lesson, we’ll implement a basic agent and see how to evaluate a population of agents.

Basic agent implementation

Start by opening chromosome.ex ...