forked fromahmedfgad/GeneticAlgorithmPython
- Notifications
You must be signed in to change notification settings - Fork0
Commit19bac06
authored
PyGAD 2.16.1
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.ahmedfgad#50```pythonimport pygadimport numpyimport tqdmequation_inputs = [4,-2,3.5]desired_output = 44def fitness_func(solution, solution_idx): output = numpy.sum(solution * equation_inputs) fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001) return fitnessnum_generations = 10000with 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.ahmedfgad#644. 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.ahmedfgad#625. Bug fixes when adaptive mutation is used (`mutation_type="adaptive"`).ahmedfgad#651 parentc87641b commit19bac06
2 files changed
+30
-10
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 |
| - | |
| 3 | + |
Lines changed: 29 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1169 | 1169 |
| |
1170 | 1170 |
| |
1171 | 1171 |
| |
1172 |
| - | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
1173 | 1180 |
| |
1174 | 1181 |
| |
1175 | 1182 |
| |
| |||
1290 | 1297 |
| |
1291 | 1298 |
| |
1292 | 1299 |
| |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1293 | 1304 |
| |
1294 | 1305 |
| |
1295 | 1306 |
| |
| |||
1316 | 1327 |
| |
1317 | 1328 |
| |
1318 | 1329 |
| |
1319 |
| - | |
| 1330 | + | |
1320 | 1331 |
| |
1321 | 1332 |
| |
1322 | 1333 |
| |
| |||
2075 | 2086 |
| |
2076 | 2087 |
| |
2077 | 2088 |
| |
2078 |
| - | |
2079 |
| - | |
2080 |
| - | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
2081 | 2101 |
| |
2082 | 2102 |
| |
2083 |
| - | |
| 2103 | + | |
2084 | 2104 |
| |
2085 | 2105 |
| |
2086 | 2106 |
| |
2087 |
| - | |
| 2107 | + | |
2088 | 2108 |
| |
2089 | 2109 |
| |
2090 | 2110 |
| |
| |||
3433 | 3453 |
| |
3434 | 3454 |
| |
3435 | 3455 |
| |
3436 |
| - | |
| 3456 | + | |
3437 | 3457 |
| |
3438 | 3458 |
| |
3439 | 3459 |
| |
| |||
3460 | 3480 |
| |
3461 | 3481 |
| |
3462 | 3482 |
| |
3463 |
| - | |
| 3483 | + | |
3464 | 3484 |
|
0 commit comments
Comments
(0)