if __name__ == "__main__":
    # Defining problem Srinivas on the fly
    def f1(x: [float]):
        return 2.0 + (x[0] - 2.0) * (x[0] - 2.0) + (x[1] - 1.0) * (x[1] - 1.0)

    def f2(x: [float]):
        return 9.0 * x[0] - (x[1] - 1.0) * (x[1] - 1.0)

    def c1(x: [float]):
        return 1.0 - (x[0] * x[0] + x[1] * x[1]) / 225.0

    def c2(x: [float]):
        return (3.0 * x[1] - x[0]) / 10.0 - 1.0

    problem = (OnTheFlyFloatProblem().set_name("Srinivas").add_variable(
        -20.0, 20.0).add_variable(-20.0, 20.0).add_function(f1).add_function(
            f2).add_constraint(c1).add_constraint(c2))

    max_evaluations = 25000
    algorithm = SMPSO(
        problem=problem,
        swarm_size=100,
        mutation=PolynomialMutation(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
        leaders=CrowdingDistanceArchive(100),
        termination_criterion=StoppingByEvaluations(
            max_evaluations=max_evaluations),
    )

    algorithm.run()
from jmetal.core.problem import OnTheFlyFloatProblem
from jmetal.operator import PolynomialMutation
from jmetal.util.archive import CrowdingDistanceArchive
from jmetal.util.solution import print_function_values_to_file, print_variables_to_file
from jmetal.util.termination_criterion import StoppingByEvaluations

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)

    max_evaluations = 25000

    algorithm = SMPSO(problem=problem,
                      swarm_size=100,
                      mutation=PolynomialMutation(probability=1.0 /
                                                  problem.number_of_variables,
                                                  distribution_index=20),
                      leaders=CrowdingDistanceArchive(100),
                      termination_criterion=StoppingByEvaluations(
from jmetal.operator import PolynomialMutation
from jmetal.util.archive import CrowdingDistanceArchive
from jmetal.util.observer import ProgressBarObserver, VisualizerObserver
from jmetal.util.solutions_utils import print_function_values_to_file, print_variables_to_file
from jmetal.util.termination_criterion import StoppingByEvaluations

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)

    max_evaluations = 25000

    algorithm = SMPSO(
        problem=problem,
        swarm_size=100,
        mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20),
        leaders=CrowdingDistanceArchive(100),
        termination_criterion=StoppingByEvaluations(max=max_evaluations)
    )
Exemple #4
0
        return 2.0 + (x[0] - 2.0) * (x[0] - 2.0) + (x[1] - 1.0) * (x[1] - 1.0)

    def f2(x: [float]):
        return 9.0 * x[0] - (x[1] - 1.0) * (x[1] - 1.0)

    def c1(x: [float]):
        return 1.0 - (x[0] * x[0] + x[1] * x[1]) / 225.0

    def c2(x: [float]):
        return (3.0 * x[1] - x[0]) / 10.0 - 1.0


    problem = OnTheFlyFloatProblem() \
        .set_name('Srinivas') \
        .add_variable(-20.0, 20.0) \
        .add_variable(-20.0, 20.0) \
        .add_function(f1) \
        .add_function(f2) \
        .add_constraint(c1) \
        .add_constraint(c2)

    max_evaluations = 25000
    algorithm = SMPSO(
        problem=problem,
        swarm_size=100,
        mutation=PolynomialMutation(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
        leaders=CrowdingDistanceArchive(100),
        termination_criterion=StoppingByEvaluations(max=max_evaluations))

    algorithm.observable.register(observer=ProgressBarObserver(
from jmetal.operator import PolynomialMutation
from jmetal.util.archive import CrowdingDistanceArchive
from jmetal.util.observer import ProgressBarObserver, VisualizerObserver
from jmetal.util.solutions import print_function_values_to_file, print_variables_to_file
from jmetal.util.termination_criterion import StoppingByEvaluations

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)

    max_evaluations = 25000

    algorithm = SMPSO(
        problem=problem,
        swarm_size=100,
        mutation=PolynomialMutation(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
        leaders=CrowdingDistanceArchive(100),
Exemple #6
0
        return 2.0 + (x[0] - 2.0) * (x[0] - 2.0) + (x[1] - 1.0) * (x[1] - 1.0)

    def f2(x: [float]):
        return 9.0 * x[0] - (x[1] - 1.0) * (x[1] - 1.0)

    def c1(x: [float]):
        return 1.0 - (x[0] * x[0] + x[1] * x[1]) / 225.0

    def c2(x: [float]):
        return (3.0 * x[1] - x[0]) / 10.0 - 1.0


    problem = OnTheFlyFloatProblem() \
        .set_name('Srinivas') \
        .add_variable(-20.0, 20.0) \
        .add_variable(-20.0, 20.0) \
        .add_function(f1) \
        .add_function(f2) \
        .add_constraint(c1) \
        .add_constraint(c2)

    max_evaluations = 25000
    algorithm = SMPSO(
        problem=problem,
        swarm_size=100,
        mutation=PolynomialMutation(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
        leaders=CrowdingDistanceArchive(100),
        termination_criterion=StoppingByEvaluations(max=max_evaluations))

    algorithm.run()
Exemple #7
0
    read_solutions,
)
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),
Exemple #8
0
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,
        return 2.0 + (x[0] - 2.0) * (x[0] - 2.0) + (x[1] - 1.0) * (x[1] - 1.0)

    def f2(x: [float]):
        return 9.0 * x[0] - (x[1] - 1.0) * (x[1] - 1.0)

    def c1(x: [float]):
        return 1.0 - (x[0] * x[0] + x[1] * x[1]) / 225.0

    def c2(x: [float]):
        return (3.0 * x[1] - x[0]) / 10.0 - 1.0


    problem = OnTheFlyFloatProblem() \
        .set_name('Srinivas') \
        .add_variable(-20.0, 20.0) \
        .add_variable(-20.0, 20.0) \
        .add_function(f1) \
        .add_function(f2) \
        .add_constraint(c1) \
        .add_constraint(c2)

    problem.reference_front = read_solutions(
        filename='resources/reference_front/Srinivas.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,