public GeneticGUI(GeneticAlgorithm geneticAlgorithm, GeneticSettings geneticSettings, Size size) { this.geneticAlgorithm = geneticAlgorithm; this.geneticSettings = geneticSettings; agentStorageManager = new AgentStorageManager(); fontLarge = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); fontSmall = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); fontButton = new Font("Microsoft Sans Serif", 10F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); borderColor = SystemColors.ControlDark; AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; StartPosition = FormStartPosition.CenterScreen; Size = size; windowWidth = 1200; windowHeight = 650; MaximumSize = new Size(windowWidth, windowHeight); InitializeComponent(); timer = new Timer(); timer.Interval = 1; timer.Start(); timer.Tick += UpdateGraph; FormClosed += OnFormClosed; }
public void SaveAgentBinary(Agent agentToSave, GeneticSettings geneticSettings, string filePath) { SavedAgent savedAgent = new SavedAgent(agentToSave, geneticSettings); //string directory = GeneticConstants.INTERNAL_DIRECTORY_AGENTS_BINARY; SaveObject(savedAgent, filePath); }
/// <summary> /// Initializes a new instance of the <see cref="GeneticAlgorithm"/> class containing /// a random population using the specified <see cref="GeneticAlgorithmNS.GeneticSettings"/>. /// </summary> /// <param name="geneticSettings">The settings that the algorithm should use.</param> public GeneticAlgorithm(GeneticSettings geneticSettings) { // Start timer RunTimeStopWatch = new Stopwatch(); // Set up variables GenerationCount = 0; this.GeneticSettings = geneticSettings; TopKAgents = new TopKAgents(geneticSettings.TopKAgentsCount); // Make random start population MakeRandomPopulation(geneticSettings); IsRunning = true; IsPaused = false; }
public GeneticGUI(GeneticAlgorithm geneticAlgorithm, GeneticSettings geneticSettings) : this(geneticAlgorithm, geneticSettings, new Size(700, 500)) { }
/// <summary> /// Represents a agent that can be saved. /// </summary> /// <param name="agentToSave"></param> /// <param name="geneticSettingsToSave"></param> public SavedAgent(Agent agentToSave, GeneticSettings geneticSettingsToSave) { agent = agentToSave; geneticSettings = geneticSettingsToSave; }
// Makes a new random population from the recieved settings. private void MakeRandomPopulation(GeneticSettings geneticSettings) { CurrentPopulation = new Population(geneticSettings.PopulationSize, geneticSettings.GeneCount, GenerationCount, geneticSettings.RandomNumberGenerator); }