Differential Evolution

Example:


from bejoor.population_based import DifferentialEvolution

def rosenbrock_function(sol):
    return sum(100 * (sol[i+1] - sol[i]**2)**2 + (sol[i] - 1)**2 for i in range(len(sol) - 1))

solution_vector = [{"type": "float", "lower_bound": -5, "upper_bound": 10}] * 7

de = DifferentialEvolution(objective_function=rosenbrock_function, solution_vector_size=7,
                           solution_vector=solution_vector, optimization_side="min",
                           F=0.5, CR=0.7, population_size=300, epochs=50)
de.run()

print(f'Best Global Objective Value: {de.global_best_objective_value}')
print(f'Best Global Solution: {de.global_best_solution}')

Parameters:

  • objective_function: Objective function needs to be optimized.
  • solution_vector_size: Vector size of the candidate solutions.
  • solution_vector: A vector which determines the types of each variable in solution vectors.
  • optimization_side: Determines maximize or minimize the objective function.
  • target_objective_value: Target Objective value.
  • target_objective_lower_bound: Target Objective lower bound.
  • target_objective_upper_bound: Target Objective upper bound.
  • population_size: Number of individuals in the population.
  • epochs: Number of generations to run the algorithm.
  • F: Scaling factor for mutation (0 < F < 2).
  • CR: Crossover probability (0 <= CR <= 1).

BibTeX citation to the algorithm


@article{storn1997differential,
  title={Differential evolution--a simple and efficient heuristic for global optimization over continuous spaces},
  author={Storn, Rainer and Price, Kenneth},
  journal={Journal of global optimization},
  volume={11},
  pages={341--359},
  year={1997},
  publisher={Springer}
}

More useful resources about the algorithm: