예제 #1
0
        public static OptimiserBuilder GetBuilder(DecisionSpace problemSpace)
        {
            var hyps = EvolutionaryAlgorithmHyperParameters.GetDefaultHyperParameters();

            var population = new Population(
                200);

            hyps.UpdateHyperParameterValue(
                EvolutionaryAlgorithmHyperParameters.Population_Size,
                200);

            IParentSelectionOperator parentSelector = new ParentSelectionTournament(
                20, false);

            IRecombinationOperator recombinationOperator = new CrossoverSimulatedBinary(
                2);;

            hyps.UpdateHyperParameterValue(
                EvolutionaryAlgorithmHyperParameters.Number_Of_Parents, 2);

            IMutationOperator mutationOperator = new MutationAddRandomNumber(
                0.1,
                0.1,
                1);

            IReinsertionOperator reinsertionOperator = new ReinsertionReplaceRandom();

            return(new EvolutionaryAlgorithmBuilderContinuousMO(population, problemSpace, hyps,
                                                                parentSelector, recombinationOperator, mutationOperator, reinsertionOperator));
        }
예제 #2
0
        public void Operate_VeryHighEta_ReturnsOneOrOtherParent()
        {
            var cx    = new CrossoverSimulatedBinary(int.MaxValue - 10);
            var child = cx.Operate(parent1, parent2)
                        .Select(d => (double)d).ToArray();

            // Since we've set eta so high, the child should always be very close to one or other parent.
            Assert.True(
                child
                .Select((d, i) => Math.Abs(d - (double)parent1.ElementAt(i)))
                .All(d => d < 1e-6) ||
                child
                .Select((d, i) => Math.Abs(d - (double)parent2.ElementAt(i)))
                .All(d => d < 1e-6));
        }