-
Notifications
You must be signed in to change notification settings - Fork 1
2. Example MAS applications
The following use cases are currently implemented as examples:
This application is a hybrid metaheurestic which combines multi-agent systems with evolutionary algorithms. It mainly provides a decentralized and emergent selection - agents migrate and fight in order to find the best individuals to reproduce with.
The algorithm does not depend on a particular encoding or mutation and crossover operators. Those are problem-dependent and are delegated to callbacks in a submodule.
Emas can be configured using a set of parameters that are documented in emas/etc/emas.config
. This file contains also their default values. They can be overloaded when starting emas with emas:start/3,4
by passing a list of key-value tuples as a third parameter.
Currently, the algorithm optimizes the Rastrigin benchmarking function as an example.
Two alternative modules are available:
-
rastrigin_ops
- an example implementation of genetic operators in pure Erlang -
rastrigin_nif_ops
- an implementation of the same genetic operators using Erlang NIFs (Native Implemented Function)
To use this application to solve some specific problem, you need to implement some callbacks as described below.
Custom operators can be provided as an Erlang module implementing the genetic_ops
behaviour. An atom representing the name of your module should be set as the value of a parameter genetic_ops
in emas.config
.
Your callbacks will only be called from the genetic
module.
The algorithm will maximize the objective function represented by the evaluation/2
callback.
This behaviour is defined in src/emas/genetic_ops.erl
. The four following callback functions need to be implemented:
solution(Params :: sim_params()) -> solution().
Returns an initial solution for given Params#sim_params.problem_size
. It is called during the creation of the initial population.
evaluation(Solution :: solution(), Params :: sim_params()) -> float().
Evaluates a given solution. This function will be maximized.
mutation(Solution :: solution(), Params :: sim_params()) -> solution().
Mutates a given solution.
recombination(ParentSolutionA :: solution(), ParentSolutionB :: solution(),
Params :: sim*params()) ->
{ChildSolutionC :: solution(), ChildSolutionD :: solution()}.
Recombinates the two given parent solutions in order to obtain two children solutions.