Esempio n. 1
0
 public static void OnResetEvolution(object sender, EvolutionEventsArgs eventArguments)
 {
     TryStopEvolution(eventArguments.userName);
     PopulationReadWrite.DeleteLocalEvolutionFiles(eventArguments.userName);
     // TODO: Probably unnecessary wait.
     Thread.Sleep(500);
     StartOrRestartEvolution(eventArguments.userName);
 }
Esempio n. 2
0
 public static void OnBranch(object sender, EvolutionEventsArgs eventArguments)
 {
     // If evolution has not been created or is not running this will not have effect!
     TryStopEvolution(eventArguments.userName);
     // TODO: Probably unnecessary wait.
     Thread.Sleep(500);
     StartOrRestartEvolution(eventArguments.userName);
 }
Esempio n. 3
0
        static void WhenPauseEvent(object sender, EvolutionEventsArgs arguments)
        {
            string userName = arguments.userName;

            // In this version we decide to stop the program at a pause event.
            // evolutionRunning = false here seems reiterative? (see TryStopEvolution)
            ActiveUsersList <NeatGenome> .SetRunningStatus(userName, false);

            SaveDataIfRunning(userName);
        }
Esempio n. 4
0
        static void WhenUpdateEvent(object sender, EvolutionEventsArgs arguments)
        {
            string userName = arguments.userName;
            NeatEvolutionAlgorithm <NeatGenome> evolutionAlgorithm = null;

            try
            {
                evolutionAlgorithm = ActiveUsersList <NeatGenome> .EvolutionAlgorithmForUser(userName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Null algorithm at WhenUpdateEvent in EvolutionCoordination: " + ex.Message);
            }
            if (evolutionAlgorithm != null)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("gen={0:N0} bestFitness={1:N6}",
                                                                 evolutionAlgorithm.CurrentGeneration,
                                                                 evolutionAlgorithm.Statistics._maxFitness));
                SaveDataIfRunning(userName);
            }
        }
Esempio n. 5
0
 public static void OnStopEvolution(object sender, EvolutionEventsArgs eventArguments)
 {
     TryStopEvolution(eventArguments.userName);
 }
Esempio n. 6
0
 public static void OnStartEvolution(object sender, EvolutionEventsArgs eventArguments)
 {
     StartOrRestartEvolution(eventArguments.userName);
 }