Numerix v0.6.0 Numerix.Optimization View Source

Optimization algorithms to select the best element from a set of possible solutions.

Link to this section Summary

Functions

Genetic algorithm to find the solution with the lowest cost where domain is a set of all possible values (i.e. ranges) in the solution and cost_fun determines how optimal each solution is.

Link to this section Functions

Link to this function

genetic(domain, cost_fun, opts \\ [])

View Source
genetic([Range.t()], ([integer()] -> number()), Keyword.t()) :: [integer()]

Genetic algorithm to find the solution with the lowest cost where domain is a set of all possible values (i.e. ranges) in the solution and cost_fun determines how optimal each solution is.

Example

iex> domain = [0..9] |> Stream.cycle |> Enum.take(10)
iex> cost_fun = fn(x) -> Enum.sum(x) end
iex> Numerix.Optimize.genetic(domain, cost_fun)
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Options

  • :population_size - the size of population to draw the solutions from
  • :mutation_prob - the minimum probability that decides if mutation should occur
  • :elite_fraction - the percentage of population that will form the elite group in each generation
  • :iterations - the maximum number of generations to evolve the solutions