Skip to content

Commit

Permalink
Fix bugs in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnebro committed May 28, 2024
1 parent 7efd2e2 commit 730fd92
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
mu=10,
lambda_=10,
elitist=True,
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables),
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables()),
termination_criterion=StoppingByEvaluations(max_evaluations=25000),
)

algorithm.run()
result = algorithm.result()

print("Algorithm: " + algorithm.get_name())
print("Problem: " + problem.get_name())
print("Problem: " + problem.name())
print("Solution: " + str(result.variables[0]))
print("Fitness: " + str(result.objectives[0]))
print("Computing time: " + str(algorithm.total_computing_time))
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

algorithm = SimulatedAnnealing(
problem=problem,
mutation=BitFlipMutation(probability=1.0 / problem.number_of_bits),
mutation=BitFlipMutation(probability=1.0 / problem.total_number_of_bits()),
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
)

algorithm.run()
result = algorithm.result()

# Save results to file
print_function_values_to_file(result, "FUN." + algorithm.get_name() + "." + problem.get_name())
print_variables_to_file(result, "VAR." + algorithm.get_name() + "." + problem.get_name())
print_function_values_to_file(result, "FUN." + algorithm.get_name() + "." + problem.name())
print_variables_to_file(result, "VAR." + algorithm.get_name() + "." + problem.name())

print("Algorithm: " + algorithm.get_name())
print("Problem: " + problem.get_name())
print("Problem: " + problem.name())
print("Solution: " + result.get_binary_string())
print("Fitness: " + str(result.objectives[0]))
print("Computing time: " + str(algorithm.total_computing_time))
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

algorithm = SimulatedAnnealing(
problem=problem,
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20.0),
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables(), distribution_index=20.0),
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
)

algorithm.run()
result = algorithm.result()

# Save results to file
print_function_values_to_file(result, "FUN." + algorithm.get_name() + "." + problem.get_name())
print_variables_to_file(result, "VAR." + algorithm.get_name() + "." + problem.get_name())
print_function_values_to_file(result, "FUN." + algorithm.get_name() + "." + problem.name())
print_variables_to_file(result, "VAR." + algorithm.get_name() + "." + problem.name())

print("Algorithm: " + algorithm.get_name())
print("Problem: " + problem.get_name())
print("Problem: " + problem.name())
print("Solution: " + str(result.variables[0]))
print("Fitness: " + str(result.objectives[0]))
print("Computing time: " + str(algorithm.total_computing_time))

0 comments on commit 730fd92

Please sign in to comment.