Beispiel #1
0
        protected OrderedPopulation(GAConfiguration configuration, Chromosome[] chromosomes, int generationNumber, Gene[] possibleValues, List <Chromosome> retired = null)
        {
            Chromosomes      = chromosomes;
            Configuration    = configuration;
            GenerationNumber = ++generationNumber;
            PossibleValues   = possibleValues;
            Retired          = retired;

            StandardConstructorLogic();
        }
Beispiel #2
0
        protected UnorderedPopulation(GAConfiguration configuration, Chromosome[] chromosomes, int generationNumber, Type geneType, List <Chromosome> retired = null)
        {
            Chromosomes      = chromosomes;
            Configuration    = configuration;
            GenerationNumber = ++generationNumber;
            GeneType         = geneType;
            Retired          = retired;

            StandardConstructorLogic();
        }
Beispiel #3
0
        public UnorderedPopulation(GAConfiguration configuration, Chromosome[] chromosomes, Type geneType)
        {
            if (configuration == null || chromosomes == null || chromosomes.Length <= 2 || geneType == null)
            {
                throw new ArgumentException("Invalid parameters passed to the Population");
            }
            GeneType      = geneType;
            Chromosomes   = chromosomes;
            Configuration = configuration;

            StandardConstructorLogic();
        }
Beispiel #4
0
        public OrderedPopulation(GAConfiguration configuration, Chromosome[] chromosomes, params Gene[] possibleValues)
        {
            if (configuration == null || chromosomes == null || chromosomes.Length <= 2 || possibleValues == null || possibleValues.Length <= 2)
            {
                throw new ArgumentException("Invalid parameters passed to the Population");
            }

            Chromosomes    = chromosomes;
            Configuration  = configuration;
            PossibleValues = possibleValues;

            StandardConstructorLogic();
        }
Beispiel #5
0
        public bool ShouldRetire(GAConfiguration config)
        {
            switch (config.RetirementStrategy)
            {
            case RetirementStrategy.None:
                return(false);

            case RetirementStrategy.MaxAge:
                return(Age >= config.MaxRetirement && config.MaxRetirement != 0);

            case RetirementStrategy.MaxChildren:
                return(Children >= config.MaxRetirement && config.MaxRetirement != 0);
            }

            return(false);
        }