MIGA class documentation

class miga.MIGA

Mutual Information Genetic Algorithm main class.

This class stores the current state of the genetic algorithm and dispatch its calculations to the selected platform.

death

Genetic algorithm death rate.

This rate indicates the proportion of entities (based on population size) that will be killed between the generations. Worst fitness entities are killed first. Elite entities never get killed. Death rate must be a value in the range [0, 1).

See also

pop_size, minimize, elite

elite

Genetic algorithm elite ratio.

This ratio indicates the proportion of entities (based on population size) that will never be killed or mutated between generations. Elite ratio must be a value in the range [0, 1).

fitness

Population fitness

Read-only copy of of the array containing each entity fitness value. This array is first initialized with zeros.

See also

run()

genome

Population genome.

Encoded genome for each entity. Each number indicates to which sequence in group B the current index is paired. Genomes are randomly initialized when set_msa is called or when pop_size is increased. When setting genome to another matrix, shape must be preserved.

See also

pop_size, set_msa()

lambda_

Mutual information pseudocounter parameter.

Parameter used by the pseudocounter in the mutual information calculations.

See also

q, run()

minimize

Optimization target.

True if the genetic algorithm must minimize the fitness, False otherwise.

See also

fitness, run()

mutation

Genetic algorithm mutation rate.

This rate indicates the proportion of swaps (based on genome size) that will be applied to each entity between the generations. Mutations are not applied to elite entities. Mutation rate must be a non-zero value.

See also

genome, elite

platform

Platform which will be used by the genetic algorithm.

Platform where the genetic algorithm calculations will run. Possible values are ‘CPU’, ‘GPU’ and ‘SimpleGPU’. Platforms ‘GPU’ and ‘SimpleGPU’ will be available only if the package was compiled with CUDA support. Platform ‘SimpleGPU’ is a non-optimized reference platform to help on writing new platforms for GPU use.

See also

run()

pop_size

Population size.

Number of entities used by the genetic algorithm. There must be at least one entity.

See also

elite, death, genome

q

Number of symbols in the MSA.

Total number of possible symbols used to encode both MSAs. Must be a non-zero value.

See also

seq_a, seq_b, set_msa()

run()

Run the genetic algorithm.

Run the genetic algorithm for generations generations with the current state (e.g. population, MSA, platform). In each generation the following steps are repeated:

  1. Entities will be sorted based on their fitness (see minimize).
  2. Worst fitness entities will be replaced by copies of the remaining entities (see death).
  3. Non-elite entities genomes will be mutated (see elite and mutation).
Parameters:generations (:type:`int`) – Number of generations to run the genetic algorithm. If it’s 0, population will be sorted based on the calculated fitness values.
seq_a

Read-only copy of encoded MSA representing the first group.

See also

set_msa()

seq_b

Read-only copy of encoded MSA representing the second group.

See also

set_msa()

set_msa()

Set MSA used to do MI calculations.

Set the MSA that represents the two groups used in the calculation and initialize the genomes of all population to a random state.

Parameters:
  • seq_a (numpy.ndarray) – First group encoded MSA. All entries must be positive and lower then q.
  • seq_b (numpy.ndarray) – Second group encoded MSA. All entries must be positive and lower then q.

See also

genome, seq_a, seq_b, q

threads

Number of threads to be used by multithreading platforms.

There must be at least 1 thread. This attribute is innefective when using any GPU platform.