Pmut: float = 0.05 generations: int = 50 pop_size: int = 30 Cr: float = 0.5 max_evaluations: float = generations * pop_size problem: MulticastProblem = MulticastProblem( Graph=gr, root_node=root_node, destination_nodes=destination_nodes) algorithm = MOEAD(problem=problem, population_size=pop_size, mutation=MulticastMutation(probability=Pmut, Pnmut=Pnmut, G=gr), crossover=MulticastCrossover( probability=0.5, root_node=root_node, destination_nodes=destination_nodes, graph=gr), aggregative_function=Tschebycheff( dimension=problem.number_of_objectives), neighbor_size=20, neighbourhood_selection_probability=0.9, max_number_of_replaced_solutions=1, weight_files_path='resources/MOEAD_weights', termination_criterion=StoppingByEvaluations( max_evaluations=max_evaluations)) algorithm.run() front = algorithm.get_result() # Save results to file print_function_values_to_file(front, 'FUN.' + algorithm.label) # print_variables_to_file(front, 'VAR.'+ algorithm.label)
if __name__ == '__main__': problem = DTLZ2() problem.reference_front = read_solutions( filename='../../resources/reference_front/DTLZ2.3D.pf'.format( problem.get_name())) max_evaluations = 150000 algorithm = MOEAD( problem=problem, population_size=300, crossover=DifferentialEvolutionCrossover(CR=1.0, F=0.5, K=0.5), mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20), aggregative_function=Tschebycheff( dimension=problem.number_of_objectives), neighbor_size=20, neighbourhood_selection_probability=0.9, max_number_of_replaced_solutions=2, weight_files_path='../../resources/MOEAD_weights', termination_criterion=StoppingByEvaluations(max=max_evaluations)) algorithm.observable.register(observer=ProgressBarObserver( max=max_evaluations)) algorithm.observable.register(observer=VisualizerObserver( reference_front=problem.reference_front, display_frequency=1000)) algorithm.run() front = algorithm.get_result()
from jmetal.algorithm.multiobjective.moead import MOEAD from jmetal.operator import Polynomial, DifferentialEvolution from jmetal.problem import LZ09_F2 from jmetal.util.aggregative_function import Chebyshev from jmetal.util.neighborhood import WeightVectorNeighborhood from jmetal.util.solution_list import read_front problem = LZ09_F2() problem.reference_front = read_front( file_path='/resources/reference_front/{}.pf'.format(problem.get_name())) population_size = 100 algorithm = MOEAD( problem=problem, population_size=population_size, max_evaluations=150000, crossover=DifferentialEvolution(CR=1.0, F=0.5, K=0.5), mutation=Polynomial(probability=1.0 / problem.number_of_variables, distribution_index=20), aggregative_function=Chebyshev(dimension=problem.number_of_objectives), neighbourhood=WeightVectorNeighborhood( population_size, 20, weights_path='/resources/MOEAD_weights/'), neighbourhood_selection_probability=0.9, max_number_of_replaced_solutions=2) progress_bar = ProgressBarObserver(initial=algorithm.population_size, step=algorithm.offspring_size, maximum=algorithm.max_evaluations) algorithm.observable.register(observer=progress_bar)