-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Working on implementing a IntegerFloatSolution class * Add unit test cases for class IntegerFloatProblem * Add class NMMin * Add class IntegerFloatSBXCrossover * Add test cases for SBXCrossover * Still working on implementing an approach for the IntegerFloatSolution class * Add user defined exceptiones in file checking.py * Working on the implementation of class CompositeSolution * Workon on class CompositeSolution * Class CompositeMutation implemented and tested * Fix a bug in class Neighborhood * Class CompositeCrossover implemented and tested * Add class * Add class * Rename file * Add problem ZDT1Modified * Add examples with NSGA-II * Add NSGA-II examples * Optimize imports * Minor changes * Changes on attribute name Co-authored-by: Yebisu <[email protected]>
- Loading branch information
Showing
81 changed files
with
1,131 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
examples/multiobjective/nsgaii/gnsgaii_solving_zdt2_with_reference_point.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from jmetal.algorithm.multiobjective.nsgaii import NSGAII | ||
from jmetal.lab.visualization import Plot, InteractivePlot | ||
from jmetal.operator import SBXCrossover, PolynomialMutation | ||
from jmetal.problem import ZDT2 | ||
from jmetal.util.comparator import GDominanceComparator | ||
from jmetal.util.observer import ProgressBarObserver, VisualizerObserver | ||
from jmetal.util.solution import print_function_values_to_file, print_variables_to_file, read_solutions | ||
from jmetal.util.termination_criterion import StoppingByEvaluations | ||
|
||
""" | ||
Program to configure and run G-NSGA-II (NSGA-II with G-Dominance) to solve problem ZDT2 with | ||
reference point = [0.2, 0.5]. | ||
""" | ||
|
||
if __name__ == '__main__': | ||
problem = ZDT2() | ||
problem.reference_front = read_solutions(filename='resources/reference_front/ZDT2.pf') | ||
|
||
reference_point = [0.2, 0.5] | ||
|
||
max_evaluations = 25000 | ||
algorithm = NSGAII( | ||
problem=problem, | ||
population_size=100, | ||
offspring_population_size=100, | ||
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20), | ||
crossover=SBXCrossover(probability=1.0, distribution_index=20), | ||
dominance_comparator=GDominanceComparator(reference_point), | ||
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations) | ||
) | ||
|
||
algorithm.observable.register(observer=ProgressBarObserver(max=max_evaluations)) | ||
algorithm.observable.register( | ||
observer=VisualizerObserver(reference_front=problem.reference_front, reference_point=reference_point)) | ||
|
||
algorithm.run() | ||
front = algorithm.get_result() | ||
|
||
# Plot front | ||
plot_front = Plot(title='Pareto front approximation. Problem: ' + problem.get_name(), | ||
reference_front=problem.reference_front, axis_labels=problem.obj_labels) | ||
plot_front.plot(front, label=algorithm.label, filename=algorithm.get_name()) | ||
|
||
# Plot interactive front | ||
plot_front = InteractivePlot(title='Pareto front approximation. Problem: ' + problem.get_name(), | ||
reference_front=problem.reference_front, axis_labels=problem.obj_labels) | ||
plot_front.plot(front, label=algorithm.label, filename=algorithm.get_name()) | ||
|
||
# Save results to file | ||
print_function_values_to_file(front, 'FUN.' + algorithm.label) | ||
print_variables_to_file(front, 'VAR.' + algorithm.label) | ||
|
||
print('Algorithm (continuous problem): ' + algorithm.get_name()) | ||
print('Problem: ' + problem.get_name()) | ||
print('Computing time: ' + str(algorithm.total_computing_time)) |
49 changes: 49 additions & 0 deletions
49
examples/multiobjective/nsgaii/nsgaii_defining_schaffer_problem_on_the_fly.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from jmetal.algorithm.multiobjective.nsgaii import NSGAII | ||
from jmetal.core.problem import OnTheFlyFloatProblem | ||
from jmetal.operator import SBXCrossover, PolynomialMutation | ||
from jmetal.util.solution import get_non_dominated_solutions, read_solutions, print_function_values_to_file, \ | ||
print_variables_to_file | ||
from jmetal.util.termination_criterion import StoppingByEvaluations | ||
|
||
""" | ||
Program to configure and run the NSGA-II algorithm configured with standard settings. | ||
""" | ||
|
||
if __name__ == '__main__': | ||
# Defining problem Schaffer on the fly | ||
def f1(x: [float]): | ||
return x[0] * x[0] | ||
|
||
def f2(x: [float]): | ||
return (x[0] - 2) * (x[0] - 2) | ||
|
||
problem = OnTheFlyFloatProblem() | ||
problem \ | ||
.set_name('Schaffer') \ | ||
.add_variable(-10000.0, 10000.0) \ | ||
.add_function(f1) \ | ||
.add_function(f2) | ||
|
||
problem.reference_front = read_solutions(filename='resources/reference_front/ZDT1.pf') | ||
|
||
max_evaluations = 25000 | ||
algorithm = NSGAII( | ||
problem=problem, | ||
population_size=100, | ||
offspring_population_size=100, | ||
mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20), | ||
crossover=SBXCrossover(probability=1.0, distribution_index=20), | ||
termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations) | ||
) | ||
|
||
algorithm.run() | ||
front = get_non_dominated_solutions(algorithm.get_result()) | ||
|
||
# Save results to file | ||
print_function_values_to_file(front, 'FUN.' + algorithm.label) | ||
print_variables_to_file(front, 'VAR.'+ algorithm.label) | ||
|
||
print('Algorithm (continuous problem): ' + algorithm.get_name()) | ||
print('Problem: ' + problem.get_name()) | ||
print('Computing time: ' + str(algorithm.total_computing_time)) | ||
|
Oops, something went wrong.