@@ -845,7 +845,7 @@ Release Date: 28 September 2021
845
845
``save_solutions=True ``.
846
846
847
847
2. The user can use the ``tqdm `` library to show a progress bar.
848
- https://github.com/ahmedfgad/GeneticAlgorithmPython/discussions/50
848
+ https://github.com/ahmedfgad/GeneticAlgorithmPython/discussions/50.
849
849
850
850
.. code :: python
851
851
@@ -874,6 +874,50 @@ Release Date: 28 September 2021
874
874
875
875
ga_instance.plot_result()
876
876
877
+ But this work does not work if the ``ga_instance `` will be pickled (i.e.
878
+ the ``save() `` method will be called.
879
+
880
+ .. code :: python
881
+
882
+ ga_instance.save(" test" )
883
+
884
+ To solve this issue, define a function and pass it to the
885
+ ``on_generation `` parameter. In the next code, the
886
+ ``on_generation_progress() `` function is defined which updates the
887
+ progress bar.
888
+
889
+ .. code :: python
890
+
891
+ import pygad
892
+ import numpy
893
+ import tqdm
894
+
895
+ equation_inputs = [4 ,- 2 ,3.5 ]
896
+ desired_output = 44
897
+
898
+ def fitness_func (solution , solution_idx ):
899
+ output = numpy.sum(solution * equation_inputs)
900
+ fitness = 1.0 / (numpy.abs(output - desired_output) + 0.000001 )
901
+ return fitness
902
+
903
+ def on_generation_progress (ga ):
904
+ pbar.update(1 )
905
+
906
+ num_generations = 100
907
+ with tqdm.tqdm(total = num_generations) as pbar:
908
+ ga_instance = pygad.GA(num_generations = num_generations,
909
+ sol_per_pop = 5 ,
910
+ num_parents_mating = 2 ,
911
+ num_genes = len (equation_inputs),
912
+ fitness_func = fitness_func,
913
+ on_generation = on_generation_progress)
914
+
915
+ ga_instance.run()
916
+
917
+ ga_instance.plot_result()
918
+
919
+ ga_instance.save(" test" )
920
+
877
921
1. Solved the issue of unequal length between the ``solutions `` and
878
922
``solutions_fitness `` when the ``save_solutions `` parameter is set to
879
923
``True ``. Now, the fitness of the last population is appended to the
@@ -1366,8 +1410,8 @@ A number of research papers used PyGAD and here are some of them:
1366
1410
- Jaros, Marta, and Jiri Jaros. "Performance-Cost Optimization of
1367
1411
Moldable Scientific Workflows."
1368
1412
1369
- - Thorat, Divya. * Enhanced genetic algorithm to reduce makespan of
1370
- multiple jobs in map-reduce application on serverless platform * .
1413
+ - Thorat, Divya. " Enhanced genetic algorithm to reduce makespan of
1414
+ multiple jobs in map-reduce application on serverless platform" .
1371
1415
Diss. Dublin, National College of Ireland, 2020.
1372
1416
1373
1417
- Koch, Chris, and Edgar Dobriban. "AttenGen: Generating Live
@@ -1389,6 +1433,19 @@ A number of research papers used PyGAD and here are some of them:
1389
1433
Long Short-Term Memory Network for Long-Term Load Forecasting." *IEEE
1390
1434
Access * 9 (2021): 68511-68522.
1391
1435
1436
+ - Antunes, E. D. O., Caetano, M. F., Marotta, M. A., Araujo, A.,
1437
+ Bondan, L., Meneguette, R. I., & Rocha Filho, G. P. (2021, August).
1438
+ Soluções Otimizadas para o Problema de Localização de Máxima
1439
+ Cobertura em Redes Militarizadas 4G/LTE. In *Anais do XXVI Workshop
1440
+ de Gerência e Operação de Redes e Serviços * (pp. 152-165). SBC.
1441
+
1442
+ More Links
1443
+ ==========
1444
+
1445
+ https://rodriguezanton.com/identifying-contact-states-for-2d-objects-using-pygad-and/
1446
+
1447
+ https://torvaney.github.io/projects/t9-optimised
1448
+
1392
1449
For More Information
1393
1450
====================
1394
1451
0 commit comments