-
Notifications
You must be signed in to change notification settings - Fork 5
Custom operators
The application is provided with example operators optimising the Rastrigin function. These operators are implemented in src/emas_test_ops.erl
module, however other modules can be used when necessary. A proper program optimising the Rastrigin function using EMAS can be found here.
In order to ensure complience with the EMAS application, the custom operators need to implement some specific callbacks as described below.
Custom operators can be provided as an Erlang module implementing the emas_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
.
The algorithm will maximize the objective function represented by the emas_evaluation/2
callback.
This behaviour is defined in src/emas_genetic_ops.erl
. The five 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.
config() -> Extra :: term().
Enables the user to create an arbitrary data structure with custom parameters, which can later be accessed in the sim_params()
object under the extra
field.