Skip to content

Commit

Permalink
Fixed in more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
alcides committed Oct 22, 2024
1 parent 6042e4d commit e1bba05
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/benchmarks/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def example_run(b: Benchmark):
problem = b.get_problem()
grammar = b.get_grammar()
random = NativeRandomSource(1)
s = GeneticProgramming(
alg = GeneticProgramming(
problem=problem,
budget=TimeBudget(5),
representation=TreeBasedRepresentation(
Expand All @@ -31,7 +31,7 @@ def example_run(b: Benchmark):
random=random,
tracker=ProgressTracker(problem, recorders=[PopulationRecorder()]),
)
best = s.search()
best = alg.search()[0]
print(
f"Fitness of {best.get_fitness(problem)} by genotype: {best.genotype} with phenotype: {best.get_phenotype()}",
)
3 changes: 2 additions & 1 deletion examples/benchmarks/benchmark_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
recorders=[PopulationRecorder()],
)
instance = m(grammar, problem, random, budget, tracker)
best = instance.search()
bests = instance.search()
best = bests[0]
print(
f"Fitness of {best.get_fitness(problem)} by genotype: {best.genotype} with phenotype: {best.get_phenotype()}",
)
2 changes: 1 addition & 1 deletion examples/classification_unknown_length_objectives.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def main(self, **args):
budget=EvaluationBudget(1000),
population_size=50,
)
best = alg.search()
best = alg.search()[0]
print(
f"Fitness of {best.get_fitness(alg.get_problem())} by genotype: {best.genotype} with phenotype: {best.get_phenotype()}",
)
Expand Down
2 changes: 1 addition & 1 deletion examples/multi_target_lexicase.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def main(self, **args):
elitism=0,
**args,
)
best = alg.search()
best = alg.search()[0]
print(
f"Fitness of {best.get_fitness(alg.get_problem())} by genotype: {best.genotype} with phenotype: {best.get_phenotype()}",
)
Expand Down
2 changes: 1 addition & 1 deletion examples/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def main(seed=123):
representation=StackBasedGGGPRepresentation(grammar, 2048),
random=NativeRandomSource(seed),
)
best = alg.search()
best = alg.search()[0]
print(
f"Fitness of {best.get_fitness(alg.get_problem())} by genotype: {best.genotype} with phenotype: {best.get_phenotype()}",
)
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main(seed=123):
representation=GrammaticalEvolutionRepresentation(grammar, MaxDepthDecider(r, grammar, 10)),
random=r,
)
best = alg.search()
best = alg.search()[0]
print(
f"Fitness of {best.get_fitness(alg.get_problem())} by genotype: {best.genotype} with phenotype: {best.get_phenotype()}",
)
Expand Down

0 comments on commit e1bba05

Please sign in to comment.