示例#1
0
        public ICandidate[] CrossOver(ICandidate parentA, ICandidate parentB, int crossOverIndex)
        {
            //true true, false , false, true
            var piA = parentA.GetGenomes();
            var piB = parentB.GetGenomes();

            var childAItems = piA.Substring(0, crossOverIndex) + piB.Substring(crossOverIndex, geneCount - crossOverIndex);
            var childBItems = piB.Substring(0, crossOverIndex) + piA.Substring(crossOverIndex, geneCount - crossOverIndex);

            var childA = new Knapsack(childAItems);
            var childB = new Knapsack(childBItems);

            return(new Knapsack[] { childA, childB });
        }