Evaluate solutions

The lifecycle of metaheuristics often requires to evaluate list of solutions on every iteration. In evolutionary algorithms, for example, this list of solutions is known as population.

In order to evaluate a population, NSGA-II (and in general, any generational algorithms in jMetalPy) uses an evaluator object.

Sequential

The default evaluator runs in a sequential fashion (i.e., one solution at a time):

from jmetal.util.evaluator import SequentialEvaluator

algorithm = NSGAII(
   problem=problem,
   population_size=100,
   offspring_population_size=100,
   ...
   population_evaluator = SequentialEvaluator(),
 )

API

class jmetal.util.evaluator.SequentialEvaluator[source]

Bases: Evaluator[S]

evaluate(solution_list: List[S], problem: Problem) List[S][source]

Parallel and distributed

Solutions can also be evaluated in parallel, using threads or processes:

from jmetal.util.evaluator import MapEvaluator
from jmetal.util.evaluator import MultiprocessEvaluator

jMetalPy includes an evaluator based on Apache Spark, so the solutions can be evaluated in a variety of parallel systems (multicores, clusters):

from jmetal.util.evaluator import SparkEvaluator

algorithm = NSGAII(
   problem=problem,
   population_size=100,
   offspring_population_size=100,
   ...
   population_evaluator = SparkEvaluator(processes=8),
 )

Or by means of Dask:

from jmetal.util.evaluator import DaskEvaluator

algorithm = NSGAII(
   problem=problem,
   population_size=100,
   offspring_population_size=100,
   ...
   population_evaluator = DaskEvaluator(),
 )

Warning

SparkEvaluator and DaskEvaluator requires pySpark and Dask, respectively.

API

class jmetal.util.evaluator.MapEvaluator(processes: int | None = None)[source]

Bases: Evaluator[S]

evaluate(solution_list: List[S], problem: Problem) List[S][source]
class jmetal.util.evaluator.MultiprocessEvaluator(processes: int | None = None)[source]

Bases: Evaluator[S]

evaluate(solution_list: List[S], problem: Problem) List[S][source]
class jmetal.util.evaluator.SparkEvaluator(processes: int = 8)[source]

Bases: Evaluator[S]

evaluate(solution_list: List[S], problem: Problem) List[S][source]
class jmetal.util.evaluator.DaskEvaluator(scheduler='processes')[source]

Bases: Evaluator[S]

evaluate(solution_list: List[S], problem: Problem) List[S][source]