jMetal / jMetalPy

A framework for single/multi-objective optimization with metaheuristics
https://jmetal.github.io/jMetalPy/index.html
MIT License
497 stars 150 forks source link

SPEA2 Progress bar #126

Closed mishras9 closed 2 years ago

mishras9 commented 2 years ago

I am not sure why the progress bar is not able to show the progress properly. The progress bar gets stuck at the point and then takes hours. See the code and progress bar below. Since, SPEA2 is a robust algorithm it takes more time but why am I not able to see the change in progress. @ajnebro

from jmetal.algorithm.multiobjective.spea2 import SPEA2
from jmetal.operator import SBXCrossover, PolynomialMutation
from jmetal.util.termination_criterion import StoppingByEvaluations
from jmetal.util.observer import ProgressBarObserver

problem = MyProblem()

algorithm = SPEA2(
    problem=problem,
    population_size=500,
    offspring_population_size=500,
    mutation=PolynomialMutation(probability=0.01, distribution_index=20),
    crossover=SBXCrossover(probability=0.9, distribution_index=15),
    termination_criterion=StoppingByEvaluations(max_evaluations=5000)
)

progress_bar = ProgressBarObserver(max=5000)
algorithm.observable.register(progress_bar)

algorithm.run()
solutions = algorithm.get_result()

Progress:   0%|          | 0/5000 [00:00<?, ?it/s]

Progress:  20%|##        | 1000/5000 [00:55<03:40, 18.16it/s]

Progress:  20%|##        | 1000/5000 [01:14<03:40, 18.16it/s]