from jmetal.algorithm import NSGAII from jmetal.operator import Polynomial, SBX, BinaryTournamentSelection from jmetal.component import RankingAndCrowdingDistanceComparator, BasicAlgorithmObserver from jmetal.problem import ZDT1 algorithm = NSGAII(problem=ZDT1(), population_size=100, max_evaluations=25000, mutation=Polynomial(probability=1.0 / problem.number_of_variables, distribution_index=20), crossover=SBX(probability=1.0, distribution_index=20), selection=BinaryTournamentSelection( comparator=RankingAndCrowdingDistanceComparator())) algorithm.run() front = algorithm.get_result() print(front)
with open('paramTuning.csv') as f: data = [tuple(line) for line in csv.reader(f)] data.pop(0) # to skip the header if len(sys.argv) < 2: run_id = '_NoRunProvided' else: run_id = '_' + sys.argv[ 1] # we use this value to name the solution output for conf in data: problem.run_id = conf[0] + run_id algorithm = NSGAII( problem=problem, population_size=int(conf[1]), max_evaluations=250, mutation=BitFlip( probability=float(conf[3])), #use the same values that in MoMS crossover=SP( probability=float(conf[2])), #use the same values that in MoMS selection=BinaryTournamentSelection( comparator=RankingAndCrowdingDistanceComparator())) #observer = VisualizerObserver(problem) progress_bar = ProgressBarObserver(step=10, maximum=250) #algorithm.observable.register(observer=observer) algorithm.observable.register(observer=progress_bar) algorithm.run() front = algorithm.get_result() # Plot frontier to file #pareto_front = ScatterMatplotlib(plot_title='NSGAII for IoT-Min', number_of_objectives=problem.number_of_objectives)
smpso.run() print("SMPSO HV {}".format(hv_comp.compute(smpso.get_result()))) print("SMPSO ITERATIONS {}".format(smpso.evaluations)) moqpso = MOQPSO( problem=problem, swarm_size=100, max_evaluations=100000, mutation=Polynomial(probability=0.3, distribution_index=10), leaders=CrowdingDistanceArchive(500), reference_point= [5] * problem.number_of_objectives ) moqpso.run() print("MOQPSO hv {}".format(hv_comp.compute(moqpso.get_result()))) print("MOQPSO ITERATIONS {}".format(moqpso.evaluations)) sm_hv.append(smpso.current_hv) q_hv.append(moqpso.current_hv) nsga = NSGAII( problem=problem, population_size=100, max_evaluations=1000, mutation=Uniform(0.01), crossover=SBX(probability=1.0, distribution_index=20), selection=BinaryTournamentSelection(comparator=RankingAndCrowdingDistanceComparator()) ) nsga.run() print("NSGAII hv {}".format(hv_comp.compute(nsga.get_result())))
from jmetal.operator import NullMutation, SBX, BinaryTournamentSelection, Polynomial from jmetal.problem import ZDT1, ZDT2 from jmetal.component.quality_indicator import HyperVolume from jmetal.util.laboratory import Experiment # Configure experiment problem_list = [ZDT1(), ZDT2()] algorithm_list = [] for problem in problem_list: algorithm_list.append( ('NSGAII_A', NSGAII(problem=problem, population_size=100, max_evaluations=25000, mutation=NullMutation(), crossover=SBX(probability=1.0, distribution_index=20), selection=BinaryTournamentSelection( comparator=RankingAndCrowdingDistanceComparator())))) algorithm_list.append( ('NSGAII_B', NSGAII(problem=problem, population_size=100, max_evaluations=25000, mutation=Polynomial(probability=1.0 / problem.number_of_variables, distribution_index=20), crossover=SBX(probability=1.0, distribution_index=20), selection=BinaryTournamentSelection( comparator=RankingAndCrowdingDistanceComparator()))))
from jmetal.algorithm import NSGAII from jmetal.problem import ZDT1 from jmetal.operator import SBX, Polynomial, BinaryTournamentSelection from jmetal.component import ProgressBarObserver, RankingAndCrowdingDistanceComparator, VisualizerObserver from jmetal.util import FrontPlot, SolutionList if __name__ == '__main__': problem = ZDT1(rf_path='../../resources/reference_front/ZDT1.pf') algorithm = NSGAII( problem=problem, population_size=100, max_evaluations=25000, mutation=Polynomial(probability=1.0 / problem.number_of_variables, distribution_index=20), crossover=SBX(probability=1.0, distribution_index=20), selection=BinaryTournamentSelection(comparator=RankingAndCrowdingDistanceComparator()) ) progress_bar = ProgressBarObserver(step=100, maximum=25000) visualizer = VisualizerObserver() algorithm.observable.register(observer=progress_bar) algorithm.observable.register(observer=visualizer) algorithm.run() front = algorithm.get_result() # Plot frontier to file pareto_front = FrontPlot(plot_title='NSGAII-ZDT1', axis_labels=problem.obj_labels) pareto_front.plot(front, reference_front=problem.reference_front) pareto_front.to_html(filename='NSGAII-ZDT1')
from jmetal.component.quality_indicator import HyperVolume if __name__ == '__main__': problem = Miniaturization() if len (sys.argv) < 3: print ('You must provide 2 arguments: number of run, js script to miniaturize') sys.exit(1) else: problem.run_id = '_' + sys.argv[1] # we use this value to name the solution output problem.algo_name = 'NSGAII' problem.script = sys.argv[2] # we parametrize the script algorithm = NSGAII( problem=problem, population_size=100, max_evaluations=1500, mutation=BitFlip(probability=0.1), #the best according to our test crossover=SP(probability=0.8),#the best according to our test selection=BinaryTournamentSelection(comparator=RankingAndCrowdingDistanceComparator()) ) ##observer = VisualizerObserver(problem) progress_bar = ProgressBarObserver(step=10, maximum=1500) ##algorithm.observable.register(observer=observer) algorithm.observable.register(observer=progress_bar) algorithm.run() front = algorithm.get_result() print (str(algorithm.get_evaluations())) ## Plot frontier to file ##pareto_front = ScatterMatplotlib(plot_title='NSGAII for IoT-Min', number_of_objectives=problem.number_of_objectives)
algorithm = [(NSGAII, { 'population_size': 100, 'max_evaluations': 25000, 'mutation': NullMutation(), 'crossover': SBX(1.0, 20), 'selection': BinaryTournamentSelection(RankingAndCrowdingDistanceComparator()) }), (NSGAII(population_size=100, max_evaluations=25000, mutation=NullMutation(), crossover=SBX(1.0, 20), selection=BinaryTournamentSelection( RankingAndCrowdingDistanceComparator()), problem=ZDT1()), {}), (SMPSO, { 'swarm_size': 100, 'max_evaluations': 25000, 'mutation': NullMutation(), 'leaders': CrowdingDistanceArchive(100) })] metric = [HyperVolume(reference_point=[1, 1])] problem = [(ZDT1, {}), (ZDT2, {})] results = experiment(algorithm, metric, problem) display(results)