Gravitational Search Algorithm
Example:
from bejoor.physics_based import GravitationalSearchAlgorithm
def sphere_function(sol):
return sum(x**2 for x in sol)
solution_vector = [{"type": "float", "lower_bound": -5.12, "upper_bound": 5.12}] * 7
gsa = GravitationalSearchAlgorithm(objective_function=sphere_function, solution_vector_size=7,
solution_vector=solution_vector, optimization_side="min",
G_initial=100, G_decay=0.99, population_size=30, epochs=50)
gsa.run()
print(f'Best Global Objective Value: {gsa.global_best_objective_value}')
print(f'Best Global Solution: {gsa.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.
-
G_initial
: Initial value of gravitational constant.
-
G_decay
: Decay rate of gravitational constant per iteration.
BibTeX citation to the algorithm
@article{rashedi2009gsa,
title={GSA: a gravitational search algorithm},
author={Rashedi, Esmat and Nezamabadi-Pour, Hossein and Saryazdi, Saeid},
journal={Information sciences},
volume={179},
number={13},
pages={2232--2248},
year={2009},
publisher={Elsevier}
}
More useful resources about the algorithm:
-
Rashedi, Esmat, Elaheh Rashedi, and Hossein Nezamabadi-Pour. "A comprehensive survey on gravitational search algorithm." Swarm and evolutionary computation 41 (2018): 141-158.
-
Hashemi, Amin, Mohammad Bagher Dowlatshahi, and Hossein Nezamabadi-Pour. "Gravitational search algorithm: Theory, literature review, and applications." Handbook of AI-based Metaheuristics (2021): 119-150.
-
Sabri, Norlina Mohd, Mazidah Puteh, and Mohamad Rusop Mahmood. "An overview of Gravitational Search Algorithm utilization in optimization problems." 2013 IEEE 3rd International Conference on System Engineering and Technology. IEEE, 2013.