I am trying to use a genetic algorithm with DEAP to solve an optimization problem not all that different from a knapsack problem. A chromosome is represented by a vector of integers and the constraint is that the sum of the vector must be equal to some number X. It seems inefficient to deal with this in the fitness evaluation as there are relatively few crossovers/mutations that will lead to having a vector with sum exactly equal to X.
Instead it seems like I should be remapping crossovers and mutations to be within the bounded set of possible solutions. Should I be implementing this with decorators in DEAP or does anyone know of a better way to deal with this? Does anyone have a link to example code for this type of situation?