-
-
Notifications
You must be signed in to change notification settings - Fork 481
Solution_FItness array and solutions arrays are in different length. #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello Javid-B
Just a speculative suggestion here from me.
You may think that 600 != 640 is a mismatch here. But, in fact, I think maybe when you say “40 populations” you mean n=40 competing algos in a generation?
Dividing 640 by 40 gives 15. So I suppose you have 15 “genes” and that 640 is the size of the whole “generation” of siblings.
It is just a thought. I hope this is the answer for you. If I wrong I apologise.
Best wishes
Keith
…Sent from my iPhone
On 13 Sep 2021, at 08:23, javid-b ***@***.***> wrote:
I am using pygad, for GA, to find combination of solutions which would satisfy conditions. I have got a code, which runs 15 generations with 40 populations. When GA stops running, the size of array is 640 where as array is 600. I am looking for a single array which would have solutions for all trials with fitness array next to it. However, i was expecting them to be equal. May be i am doing something wrong?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Hi Keith, Regards, |
I think I was talking nonsense and I’m sorry to have wasted your time. Either that or I was right and I have forgotten what I meant.
All best wishes, apologies,
Keith
…
On 16 Sep 2021, at 03:55, javid-b ***@***.***> wrote:
Hi Keith,
Thanks for response. I did not quite understood, why 640/40 would give 15?
Yes, you are right i have got 15 genes and 40 competing algos in a generation.
Regardless if it gives 600 or 640, my expectation would be that number of iterated solutions would be equal to number of fitness values. Sorry, if i am saying something non-sensible.
Regards,
Javid
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Hi @javid-b, Thanks for opening this issue. You are right as the fitness of the last population was not saved in the if self.save_solutions:
self.solutions_fitness.extend(self.last_generation_fitness) The project will be updated soon and a new release of PyGAD will be published too. Please let me know if you have any bugs or enhancements. |
1. Reuse the fitness of previously explored solutions rather than recalculating them. This feature only works if `save_solutions=True`. 2. The user can use the `tqdm` library to show a progress bar. #50 ```python import pygad import numpy import tqdm equation_inputs = [4,-2,3.5] desired_output = 44 def fitness_func(solution, solution_idx): output = numpy.sum(solution * equation_inputs) fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001) return fitness num_generations = 10000 with tqdm.tqdm(total=num_generations) as pbar: ga_instance = pygad.GA(num_generations=num_generations, sol_per_pop=5, num_parents_mating=2, num_genes=len(equation_inputs), fitness_func=fitness_func, on_generation=lambda _: pbar.update(1)) ga_instance.run() ga_instance.plot_result() ``` 3. Solved the issue of unequal length between the `solutions` and `solutions_fitness` when the `save_solutions` parameter is set to `True`. Now, the fitness of the last population is appended to the `solutions_fitness` array. #64 4. There was an issue of getting the length of these 4 variables (`solutions`, `solutions_fitness`, `best_solutions`, and `best_solutions_fitness`) doubled after each call of the `run()` method. This is solved by resetting these variables at the beginning of the `run()` method. #62 5. Bug fixes when adaptive mutation is used (`mutation_type="adaptive"`). #65
I am using pygad, for GA, to find combination of solutions which would satisfy conditions. I have got a code, which runs 15 generations with 40 populations. When GA stops running, the size of array is 640 where as array is 600. I am looking for a single array which would have solutions for all trials with fitness array next to it. However, i was expecting them to be equal. May be i am doing something wrong?
The text was updated successfully, but these errors were encountered: