How can i stop jMetalPy from generating the jmetalpy.log file?

25 Views Asked by At

Every time I run a jMetalPy algorithm it creates an unwanted log file that clutters my folder. In the docs I haven't found any way to disable this function. How can I achieve this?

My code:

problem = MyProblem()
front_observer = FrontObserver()

algorithm = NSGAII(
    problem=problem,
    population_size=4,
    offspring_population_size=2,
    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=10),
    population_evaluator=SpoolEvaluator()
)

algorithm.observable.register(front_observer)
algorithm.run()

Sample from the log file:

2023-02-21 11:25:38,256 [MainThread  ] [INFO ]  Output file (function values): ALL.NSGAII.EP
2023-02-21 11:25:38,256 [MainThread  ] [INFO ]  Output file (function values): FUN.NSGAII.EP
2023-02-21 11:25:38,257 [MainThread  ] [INFO ]  Output file (variables): VAR.NSGAII.EP
2023-02-21 15:33:41,008 [MainThread  ] [INFO ]  Output file (function values): ALL.NSGAII.EP
2023-02-21 15:33:41,013 [MainThread  ] [INFO ]  Output file (function values): FUN.NSGAII.EP
2023-02-21 15:33:41,015 [MainThread  ] [INFO ]  Output file (variables): VAR.NSGAII.EP
2023-02-21 17:47:06,298 [MainThread  ] [INFO ]  Output file (function values): ALL.NSGAII.EP
2023-02-21 17:47:06,298 [MainThread  ] [INFO ]  Output file (function values): FUN.NSGAII.EP
2023-02-21 17:47:06,299 [MainThread  ] [INFO ]  Output file (variables): VAR.NSGAII.EP
1

There are 1 best solutions below

0
Alex On

Apparently, jMetalPy uses Python's built-in logging module (found a hint here).

Therefore, I eventually solved this problem by simply disabling logging from the python module before calling anything else.

import logging


logging.disable()

# [...]
# algorithm = ...
# [...]