Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="state"></param>
        private void Setup(PGState state)
        {
            State = state ?? throw new ArgumentNullException("state");

            for (int i = 0; i < State.ValueCount; i++)
            {
                if (State.Values[i] <= State.TargetValue)
                {
                    lowerValueIndicies.Add(i);
                }
                else if (State.Values[i] > State.TargetValue)
                {
                    higherValueIndicies.Add(i);
                }
            }

            State.Pool = new ObjectPool <Chromosome>(State.PopulationSize * State.MutationCount * 2, () => new Chromosome(State));
        }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="state"></param>
 public ProbabilityGenerator(PGState state) => Setup(state);