Definition of the initial population for the genetic algorithm by the user #171
-
Dear all, I am using Python's pypi genetic algorithm 1.0.2 and I want to run this genetic algorithm with my default initial population. How can I do this? And is it possible that, for example, out of 70 populations, I introduce only one and the genetic algorithm produces the other 69? Regards |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You can use the ga_instance = pygad.GA(...,
initial_population=
...) Can you further clarify the other question. Do you mean 70 generations or solutions? |
Beta Was this translation helpful? Give feedback.
-
@ahmedfgad import numpy as np def f(X): varbound=np.array([[0,10]]*3) algorithm_param = {'max_num_iteration': 3000, model=ga(function=f, model.run() I mean 70 solutions. |
Beta Was this translation helpful? Give feedback.
-
I am going to minimize a function. Its sample code is as follows; I don't know how to run this code using PyGAD def LEVYFUNCTION(x): varbound=np.array([[-10,10]]*2) y = (sin(3pix1))^2 + (x1-1)^2 * (1+(sin(3pix2))^2) + (x2-1)^2 * (1+(sin(2pix2))^2) Global Minimum: If possible please guide how can I run this code using PyGAD? And if the minimum and maximum range of x is not the same, how should it be defined? |
Beta Was this translation helpful? Give feedback.
This code is written for a different library, not PyGAD. It looks that some parameters can be mapped to PyGAD code easily and some others need your investigation. Please check the PyGAD documentation to map the code: https://pygad.readthedocs.io/en/latest
Once you write the PyGAD code, then we can help you solve your issues.