You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @AllSundayCroco ,
Have you check the file: examples/evolutionary_based/run_test_GA.py
Basically, with sphere function.
from numpy import sum
from mealpy.evolutionary_based import GA
def sphere(solution):
return sum(solution**2)
## Setting parameters
epoch = 10 # Maximum number of generations
pop_size = 50 # Population size
lb = [-3, -5, 1, -10, ...] # Enter your lower bound (50 dimensions)
ub = [5, 10, 100, 30, ...] # Enter your upper bound (50 dimensions)
verbose = True # Print out the training process
model = GA.BaseGA(sphere, lb, ub, verbose, epoch, pop_size) # Create model object
best_position, best_fitness, list_loss = model.train() # Call train() function from object
# List loss is the best fitness found in each iterations.
Depend on the algorithm you choose, some algorithms have several variant versions, such as PSO.
You can call the class to create a object like above:
model1 = PSO.BasePSO()
model2 = PSO.HPSO_TVAC()
Check the end of the readme.md file to see the variant versions of each algorithm.
Could you please give an example for running N-dimensional functions such as [sphere dim = 50] with GA optimizer
Thank you so much !!!!!!!!
The text was updated successfully, but these errors were encountered: