Closed GitLD closed 1 year ago
It seems that I misunderstood the eliminate_duplicates, maybe I should apply the unrepeatable by adding constains
Yes, the eliminate_duplicates
operators on a population level. Not individual level.
Adding a constraint with a Repair operator is the best fix for what you want to achieve!
I'm solving an optimization problem with n_var=5, where all variable should be unrepeatable integers in range between x_min and x_max, however when I set
eliminate_duplicates = True
, did't work fine?Here is my snapshot of code:
algorithm = NSGA2( pop_size=6, sampling=IntegerRandomSampling(), crossover=SBX(repair=RoundingRepair()), mutation=PM(repair=RoundingRepair()), eliminate_duplicates=True )
And the Results give out as:Best solution found: [[ 4 2 9 4 30] [13 36 23 5 6] [13 35 22 5 6] [ 4 36 22 14 36]
which obviously variable did't meet the requirement of unrepeatable.It will appreciate if any advice is give.