aarongarrett / inspyred

Python library for bio-inspired computational intelligence
MIT License
190 stars 57 forks source link

NSGA2 minimizaton fits only the first fitness value in the multiobjective optimization problem #19

Closed rat-h closed 4 years ago

rat-h commented 4 years ago

Description

I'm trying to follow this paper Optimizing computer models of corticospinal neurons to replicate in vitro dynamics and employ NSGA2 for parameter fitting of neurons.

I found that NSGA2 optimizes only the first fitness value in the multiobjective optimization problem.

I think, there is a problem in inspyred/ec/replacers, function: nsga_replacement line 350:

combined[p] < combined[q]

which leads to inspyred/ec/ec class Individual, operator __lt__, where two fitness lists are comparing (lines 335 and 337)

return self.fitness < other.fitness

A simple test shows that python compares only the first element of the list and, seems, ignores others:

>>> [11.1 , 0. , 0.]<[ 11.0 , 3393.63 , 3411.87 ] 
False

For non-dominant minimization, fitness function on the left of < is the dominant solution, but compassing makes it non-dominant.

aarongarrett commented 4 years ago

If you use a multiobjective method, you have to wrap your fitness in a Pareto object in the evaluator, as described in the documentation. The Pareto class overloads less-than to provide a dominance operator.