Condition on individuals in ga function

I am currently trying to use genetic algorithm for a changepoint detection on a time series, using the GA-package in R. The algorithm would then work with binary vectors being the individuals, where tho ones on the vectors would represent the potential possible positions of the changepoints (for example, if the 100th component of the individual is 1, then the 100th date is a changepoint).

Since two consecutive dates cannot be 2 changepoints, I want to prohibit the algorithm from taking or generating binary vectors with consecutive ones.

Does anyone have an idea how that can be done ?

I tried to put a very low fitness score on such vectors, so that the algorithm doesn't take them into account for the next generation (since the ga function maximises the fitness function). But that didn't work. Thanks a lot

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.