Matteo-Pietro-Pillitteri / Computational-Intelligence

Repository CI 23/24
MIT License
0 stars 0 forks source link

Lab 9 peer review - Gabriele Ferro s308552 #5

Open Gabbo62 opened 10 months ago

Gabbo62 commented 10 months ago

Hello Matteo Pietro!! I want to congratulate with you for your implementation before analyzing it and I hope I can help you improve it some way.

Mutation/Crossover selection

In your definitive implementation I've noticed that you have used a random selector for the crossover strategy meanwhile for the mutation you have implemented some sort of heuristic in order to have at least a number of offsprings generated via some of your strategies: If the MUTATION_PROBABILITY is below a certain threshold, the mutation selection starts. For the first POPULATION_SIZE - 15 elements you use randomly one of your implementations, 10 of the remaining are mutated via strategy 1 or 2 and the last 5 via strategy 1. If the draw is below mutation probability the selected strategy is applied. If I understood correctly, I think there is a problem in this part, probably given by a typo,

if MUTATION_PROBABILITY > 15:
            type = 3
        else:
            ...

I think that the 15 should have been a .15 in order to make sense, given that the variable value should represent a probability. (I'm curious to know how you ended up with this kind of solution, that could be enlightening.)

Selected strategy

I find your idea of using a GA pretty much on point (looking at the base definition of the strategy that use the bit-string representation) and also the elitism was very useful in order to make sure to not lose best individuals between generations (given the generational refresh of the population given by GA). Also the dynamic adaptation is very important in your implementation to better balance exploration and exploitation.

Conclusion

Looking at the results plots it can be seen that for 1 and 2-problem the curve is smoother than the one of the other two problems, but it can be seen that thanks to the dynamic adaptation you algorithm is capable of escaping from the local maxima found. Meanwhile, your implementation of different mutation strategy choice is able to increase the probability of finding something different, and probably better, even when the research is stuck in the same point.

I found your implementation very interesting, I hope that the error I found is indeed an error and that can help you improve even more your solution. I wish you good luck and I'm thrilled to see your future implementations.

Gabbo62 commented 10 months ago

Last advice I feel to give you is about the use of caps variables like MUTATION_PROBABILITY: Usually this notation is used for constants, but the problem is that python does not implement a real way of defining them and the conservation of the value is based on the trust that a person do not modify it when he sees it's name being in caps. It's not a real error modifying it's value but can generate some problem if done in programs written collectively with others. I hope this can be useful for you and for your future projects.

Matteo-Pietro-Pillitteri commented 10 months ago

Hi Gabriele! Thanks for your review! Yes there is a typo in that part of my code, thank you for reporting it. Otherwise, you’re right, I shouldn’t use an upper case variable if it changes!