jMetal / jMetalPy

A framework for single/multi-objective optimization with metaheuristics
https://jmetal.github.io/jMetalPy/index.html
MIT License
497 stars 150 forks source link

Fix PMXCrossover - don't create child that has references to parents #171

Closed piotmag769 closed 1 month ago

piotmag769 commented 1 month ago

Previously the PMXCrossover.execute function was returning a child solution with variables field referring to parts of parents' variables. It is due to variables being a list of lists, so the slice operator in _swap function was just copying the references of the lists in the list.

It resulted in unexpected behaviours like child mutation affecting its parents, which led to e.g. wrong solutions being reported as best.