How can I see the details of the output result in DEAP

99 views
Skip to first unread message

Naoki Maeda

unread,
Dec 14, 2015, 4:15:52 AM12/14/15
to deap-users
Hi.

I'm looking at the knapsack example to try to understand multiobjective optimization
What
can not be seen or have been calculated from the individual population is?
For example, MAX and has been calculated as [49. 865.83549407], but I think of it is calculated by the combination of any such individuals.

Currently, I am aware and is calculated in [1. 40] [3 .60] of the individual, such as ..... combination.
I tried changing the code like the following is considered as content may if you look of items go well not match the calculation of the 1 th of contents calculated in this and one eyes that have been calculated by the population for its It did not.

def evalKnapsack(individual):
    weight = 0.0
    value = 0.0
    for item in individual:
        weight += items[item][0]
        value += items[item][1]
        print items[item][0]
        print items[item][1]
    if len(individual) > MAX_ITEM or weight > MAX_WEIGHT:
        return 10000, 0   

    return weight, value

François-Michel De Rainville

unread,
Dec 14, 2015, 9:05:30 AM12/14/15
to deap-...@googlegroups.com
If you look a little further in the code you'll see that the statistics are computed by numpy operators: max, min, std, and mean. You can see your population as a matrix where each columns is an objective and each row an individual. Using the numpy operators with argument axis=1 will give you the computed results.

Best regards,
François-Michel

--
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.

Message has been deleted

Naoki Maeda

unread,
Dec 16, 2015, 5:49:53 AM12/16/15
to deap-users
Thank you to answer me.

I've tried
.But it did not work


And I was thinking as follows.
"population [:] = toolbox.select (population + offspring, mu)" in this part if you selected mu number of individuals from the current population + descendants, that immediately after the record = stats.compile the (population) to cage, because max of generation has been calculated here, it will be the individual list can be obtained if here in `print population`.
It was inserted in this way in the order def eaMuPlusLambda.

# Update the statistics with the new population
    record = stats.compile(population) if stats is not None else {}

    max_ind = record['max'].item(0)
    for ind in population:
        if ind.fitness.values[0] == max_ind:
            print "MAX", ind
            break

But it did not go well.

Please tell me the solution


2015年12月14日月曜日 23時05分30秒 UTC+9 François-Michel De Rainville:

François-Michel De Rainville

unread,
Dec 25, 2015, 8:46:09 AM12/25/15
to deap-...@googlegroups.com
What did not worked? Equality between floating point numbers might cause problems because of floating point approximation. Does it work if you use numpy almost equal operator?
Reply all
Reply to author
Forward
0 new messages