Skip to content

Commit a739748

Browse files
authored
Format
1 parent 8496c99 commit a739748

1 file changed

Lines changed: 14 additions & 26 deletions

File tree

examples/example_generate_report.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,23 @@
66
"""
77

88
import numpy
9-
109
import pygad
1110

12-
1311
def fitness_func(ga_instance, solution, solution_idx):
1412
return [float(numpy.sum(solution)),
1513
-float(numpy.sum(numpy.asarray(solution) ** 2))]
1614

17-
18-
def main():
19-
ga_instance = pygad.GA(
20-
num_generations=30,
21-
num_parents_mating=8,
22-
fitness_func=fitness_func,
23-
sol_per_pop=20,
24-
num_genes=4,
25-
parent_selection_type="nsga2",
26-
save_solutions=True,
27-
random_seed=42,
28-
suppress_warnings=True,
29-
)
30-
ga_instance.run()
31-
output_path = ga_instance.generate_report(
32-
filename="pygad_report",
33-
title="PyGAD multi-objective demo",
34-
notes="A short two-objective example with 30 generations.",
35-
)
36-
print(f"Report written to: {output_path}")
37-
38-
39-
if __name__ == "__main__":
40-
main()
15+
ga_instance = pygad.GA(num_generations=30,
16+
num_parents_mating=8,
17+
fitness_func=fitness_func,
18+
sol_per_pop=20,
19+
num_genes=4,
20+
parent_selection_type="nsga2",
21+
save_solutions=True,
22+
random_seed=42,
23+
suppress_warnings=True,)
24+
ga_instance.run()
25+
output_path = ga_instance.generate_report(filename="pygad_report",
26+
title="PyGAD multi-objective demo",
27+
notes="A short two-objective example with 30 generations.",)
28+
print(f"Report written to: {output_path}")

0 commit comments

Comments
 (0)