예제 #1
0
 /// <summary>
 /// Returns single instance
 /// </summary>
 /// <returns>Single instance</returns>
 static public IndividualFactory GetInstance()
 {
     if (instance == null)
     {
         instance = new IndividualFactory();
     }
     return(instance);
 }
예제 #2
0
 // CONSTRUCTEUR
 /// <summary>
 /// Creates an instance of the EvolutionaryProcess class
 /// </summary>
 /// <param name="a_program">Reference to the application object instance that must implement the IUserInterface</param>
 /// <param name="a_problem">Problem type</param>
 public EvolutionaryProcess(IUserInterface a_program, string a_problem)
 {
     program = a_program;
     problem = a_problem;
     IndividualFactory.GetInstance().Init(problem);
     population = new List <Individual>();
     for (int i = 0; i < Parameters.IndividualsNb; i++)
     {
         population.Add(IndividualFactory.GetInstance().GetIndividual(problem));
     }
 }
예제 #3
0
        /// <summary>
        /// Reproduction step
        /// </summary>
        protected void Reproduction()
        {
            bool twoParents = Parameters.RandomGenerator.NextDouble() < Parameters.CrossoverRate;

            if (twoParents)
            {
                Individual father = Selection();
                Individual mother = Selection();
                newGeneration.Add(IndividualFactory.GetInstance().GetIndividual(problem, father, mother));
            }
            else
            {
                Individual father = Selection();
                newGeneration.Add(IndividualFactory.GetInstance().GetIndividual(problem, father));
            }
        }