-
-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathexample_generate_report.py
More file actions
28 lines (24 loc) · 1.07 KB
/
Copy pathexample_generate_report.py
File metadata and controls
28 lines (24 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Build a PDF report for a small multi-objective GA run.
Requires the optional ``report`` extra: pip install pygad[report].
The output file ``pygad_report.pdf`` is written next to this script.
"""
import numpy
import pygad
def fitness_func(ga_instance, solution, solution_idx):
return [float(numpy.sum(solution)),
-float(numpy.sum(numpy.asarray(solution) ** 2))]
ga_instance = pygad.GA(num_generations=30,
num_parents_mating=8,
fitness_func=fitness_func,
sol_per_pop=20,
num_genes=4,
parent_selection_type="nsga2",
save_solutions=True,
random_seed=42,
suppress_warnings=True,)
ga_instance.run()
output_path = ga_instance.generate_report(filename="pygad_report",
title="PyGAD multi-objective demo",
notes="A short two-objective example with 30 generations.",)
print(f"Report written to: {output_path}")