Skip to content

2. Example MAS applications

Piotr Anielski edited this page Oct 8, 2014 · 4 revisions

Example use cases

The following use cases are currently implemented as examples:

Evolutionary Multi-Agent Systems

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 stack

Configuration

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.

Example operators

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

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.

genetic_ops behaviour

This behaviour is defined in src/emas/genetic_ops.erl. The four following callback functions need to be implemented:

solution/1
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/2
evaluation(Solution :: solution(), Params :: sim_params()) -> float().

Evaluates a given solution. This function will be maximized.

mutation/2
mutation(Solution :: solution(), Params :: sim_params()) -> solution().

Mutates a given solution.

recombination/3
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.