LibCapy - diffevo

Differential evolution algorithm.

Macros:

Enumerations:

Initialisation modes

Evolution modes

Typedefs:

None.

Struct CapyDiffEvo :

Struct CapyDiffEvo's properties:

Current number of iteration

Size of the dna

Initial fitness (first fitness evaluated after calling run())

Current best fitness

Flag to stop the optimisation

Flag to memorise if the child is running

Current best agent DNA

Constraint value of the current best dna

Seed for the RNG By default, the current time. Can be modified before calling run()

Differential evolution algorithm coefficients By default, probMut = 0.9 and ampMut = 0.8 probMut in [0, 1], ampMut in [0, 2]. Can be modified before calling run(). probMut has no effect if mode==capyDiffEvoMode_sequential

Population size By default, nbAgent = 10 * dim. Can be modified before calling run()

The child thread

Exception value returned by the rendering thread

Semaphore to manage shared data access

Seed used to initialise the first DNA of the first agent if not null

Maximum number of iteration without improvement before randomising the agents (never reset if equals to 0, default: 0)

Initialisation mode (default: capyDiffEvoInitMode_random)

Coeff randomisation seed for initMode 'randomisedSeed' (in [0,1], default: 0.1). The seed is randomised as (1 - c) * seed + c * r, where c is coeffRandomisationSeed and r is a random value in the domain.

Evolution mode (default: capyDiffEvoMode_std)

Index and stride used when mode==capyDiffEvoMode_sequential. strideEq=1 by default, the stride is the number of gene evoluting per iteration

Struct CapyDiffEvo's methods:

Destructor

Run the differential evolution algorithm in its own thread

Input argument(s):

fitness: Object performing the fitness calculation, takes the agent's DNA as input and return the fitness value as output. The agent's DNA is an array of double values in fitness' domain. The higher the fitness the better the agent.
constraint: function of dimensions (fitness.dimIn, 1) encoding the
constraints on the intputs as follow: if the output value is positive or null the constraint is satisfied, else the constraint is not satisfied. The greater the value, the better the constraint is satisfied. A null argument indicates no constraint.

Output and side effect(s):

that->bestFitness, bestDna and bestConstraint are updated with the best agent. The best agent is either the one respecting the constraint and having highest fitness, or if no agent respecting constraint could be found it is the one with highest fitness regardless of the constraint.

Get the current best DNA (no effect if no optimisation currently running)

Input argument(s):

dna: array of double updated with the best dna
fitness: double updated with the fitness value of the dna
constraint: double updated with the constraint value of the dna

Stop the current optimisation (no effect if there is no optimisation currently running)

Struct CapyDiffEvoThreadData :

Struct CapyDiffEvoThreadData's properties:

the CapyDiffEvo

Object performing the fitness calculation, takes the agent's DNA as input and return the fitness value as output. The agent's DNA is an array of double values in fitness' domain. The higher the fitness the better the agent.

Constraint on the agent DNA values. If not null, takes the agent's DNA as input and return the constraint satisfaction as output (positive or null means satisfied).

Struct CapyDiffEvoThreadData's methods:

None.

Functions:

Create a CapyDiffEvo

Output and side effect(s):

Return a CapyDiffEvo

Allocate memory for a new CapyDiffEvo and create it

Output and side effect(s):

Return a CapyDiffEvo

Exception(s):

May raise CapyExc_MallocFailed.

Free the memory used by a CapyDiffEvo* and reset '*that' to NULL

Input argument(s):

that: a pointer to the CapyDiffEvo to free

2022-03-11
in LibCapy,
58 views
Copyright 2021-2024 Baillehache Pascal