示例#1
0
        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;
        }
示例#2
0
        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);
        }
示例#3
0
        /// <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;
        }
示例#4
0
 public GeneticGUI(GeneticAlgorithm geneticAlgorithm, GeneticSettings geneticSettings) : this(geneticAlgorithm,
                                                                                              geneticSettings,
                                                                                              new Size(700, 500))
 {
 }
示例#5
0
 /// <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;
 }
示例#6
0
 // Makes a new random population from the recieved settings.
 private void MakeRandomPopulation(GeneticSettings geneticSettings)
 {
     CurrentPopulation = new Population(geneticSettings.PopulationSize, geneticSettings.GeneCount, GenerationCount, geneticSettings.RandomNumberGenerator);
 }