Fitness values in multi-objective optimization

378 views
Skip to first unread message

MaxiPigna

unread,
Dec 18, 2014, 3:36:30 PM12/18/14
to deap-...@googlegroups.com
I implemented a version of nsga2 algorithm looking this code.
My fitness consists of a tuple with two values to minimize. These values are of different order of size, because they represent different things.
Looking the statistics computed by the framework, a doubt came up. In fact, I saw that the max values correspond to the values of the first element of the fitness tuple, instead the min values correspond to the second ones. But this is normal, because of the different order of size.
What I expect from the algorithm is minimizing both the values in the fitness tuple at the same time. Can you confirm that the algorithm works in this way?
Because, I am afraid of that since the first value can not be lesser than the second one, the algorithm actually works only minimizing the last one. So it would be the equivalent of a GA single-objective, which is not what I want.

François-Michel De Rainville

unread,
Dec 22, 2014, 7:56:11 AM12/22/14
to deap-...@googlegroups.com
The minimum/maximum are computed by the statistics. Your statistics use numpy min/max functions wich return the absolute min and max for each objective. The behaviour you see is normal. To convince yourself, plot your population on each generation you'll see how it progress in the objective space.

Regards,
François-Michel

MaxiPigna

unread,
Dec 22, 2014, 10:48:32 AM12/22/14
to deap-...@googlegroups.com
I implemented the statistics object in this way
    stats = tools.Statistics(key=lambda ind: ind.fitness.values)
    stats.register("avg", numpy.mean)
    stats.register("max", numpy.max)
    stats.register("min", numpy.min)
but I get this output
gen,max,avg,min
0,6755.0,1509.2321111111107,-0.80000000000000016
...

As you can see the maximum value is extremely bigger than the minimum and this is due to the different order of size of the two objectives. What I expected was to see each measure for each objective and not the absolute minimum and maximum. Maybe I made some mistake.

Moreover, I have a second question. I defined my multi-objective evaluation function like this
    creator.create("FitnessMin", base.Fitness, weights=(-1.0, -1.5))
because I want to give an higher "priority" to the second objective, because it is more important for me. Did I do it right? Or should the weight be smaller than the first one? 

François-Michel De Rainville

unread,
Dec 22, 2014, 11:31:01 AM12/22/14
to deap-...@googlegroups.com
Just add the axis=0 to your statistics, you'll get the max and min for each objective. The NSGA-II algorithm does not use the statistics so it should be alright anyway. The stats are only used for screen output.

--
You received this message because you are subscribed to the Google Groups "deap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to deap-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

François-Michel De Rainville

unread,
Dec 22, 2014, 11:33:53 AM12/22/14
to deap-...@googlegroups.com
as in :

    stats = tools.Statistics(lambda ind: ind.fitness.values)
    stats.register("avg", numpy.mean, axis=0)
    stats.register("std", numpy.std, axis=0)
    stats.register("min", numpy.min, axis=0)
    stats.register("max", numpy.max, axis=0)

from the knapsack example

MaxiPigna

unread,
Dec 22, 2014, 1:49:04 PM12/22/14
to deap-...@googlegroups.com
Thank you, that was what I missed.

Instead, what about the second question?

Moreover, I have a second question. I defined my multi-objective evaluation function like this
    creator.create("FitnessMin", base.Fitness, weights=(-1.0, -1.5))
because I want to give an higher "priority" to the second objective, because it is more important for me. Did I do it right? Or should the weight be smaller than the first one? 

François-Michel De Rainville

unread,
Dec 27, 2014, 8:10:47 AM12/27/14
to deap-...@googlegroups.com

With NSGA-II the weights only influence the crowding distance everything else is made according to pareto dominance. Thus, you should see only little differences between different weightings. The weights are usually used to "normalise" two objectives that are on different scale.

Cheers,
François-Michel


Luca Valentini

unread,
Dec 29, 2014, 10:36:19 AM12/29/14
to deap-...@googlegroups.com
Ok, I understand so I was wrong.

But in my case sould I use those weights to normalise the objectives? I have one objective which is a value between 0 and 1, instead the second one is a value close to 1000-2000.
--
Luca Valentini

François-Michel De Rainville

unread,
Jan 7, 2015, 8:46:45 PM1/7/15
to deap-...@googlegroups.com

I really don't know, it depends mostly on your problem. I suggest you try both!

Reply all
Reply to author
Forward
0 new messages