示例#1
0
        public void Evaluate(BinaryChromosome chromosome)
        {
            var binaryValues = chromosome.GetValues().Select(gene => Convert.ToInt64(gene.ToBinaryString(), 2)).ToArray();
            var floatValues  =
                binaryValues.Select(
                    (i, index) =>
                    _lowerBounds[index] +
                    i * (_upperBounds[index] - _lowerBounds[index]) / (Math.Pow(2, chromosome.GetValue(index).Length) - 1))
                .ToArray();

            chromosome.Fitness = _function.Value(floatValues);
        }
示例#2
0
 public BinaryChromosome(BinaryChromosome chromosome) : base(chromosome)
 {
 }