Exemple #1
0
 private void ShowNewNetworkDialog()
 {
     using (var form = new PropertyGridForm("New Network"))
     {
         var networkDefinition = new AgentNetworkDefinition(null, 2, 26, 12);
         form.PropertyGrid.SelectedObject = networkDefinition;
         form.FormClosing += (s, closingEvent) =>
         {
             if (form.DialogResult == DialogResult.OK)
             {
                 try
                 {
                     var network = new AgentNetwork(networkDefinition, new He(0));
                     Workspace.Instance.Add(networkDefinition.Name, network);
                 }
                 catch (Exception exception)
                 {
                     closingEvent.Cancel = true;
                     MessageBox.Show(exception.Message, "New Network", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         };
         form.ShowDialog();
     }
 }
 public NeuralSimulationPlugin(FileInfo networkFile, AgentNetworkTrainingConfiguration trainingConfiguration, int trainingSeed) : base(new NeuralAgentFactory())
 {
     TrainingRandom        = new Random(trainingSeed);
     NetworkFile           = networkFile;
     Network               = new AgentNetwork(networkFile);
     TrainingConfiguration = trainingConfiguration;
 }
Exemple #3
0
        public string GetNetworkDescription(string name)
        {
            if (networksDescriptions.TryGetValue(name, out string description) == false)
            {
                description = networksDescriptions[name] = new AgentNetwork(GetNetworkFile(name)).ToString();
            }

            return(description);
        }
Exemple #4
0
 private void RandomiseAgentNetwork(ListViewItem item)
 {
     if (item.Tag is NeuralSimulationPluginFactory pluginFactory)
     {
         var networkFile = Workspace.Instance.GetNetworkFile(pluginFactory.Network);
         var network     = new AgentNetwork(networkFile);
         network.InitializeLayers(0);
         network.Save(networkFile);
     }
 }
Exemple #5
0
        public static void InitialiseNetwork(string networkName, NeuralAgentTrainerConfiguration configuration)
        {
            var networkFile   = Workspace.Instance.GetNetworkFile(networkName);
            var createNetwork = true;

            if (networkFile.Exists)
            {
                var overwrite = MessageBox.Show($"Do you want to reset existing network '{networkName}'?", "Training", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                createNetwork = overwrite == DialogResult.Yes;
            }

            if (createNetwork)
            {
                var networkDefinition = new AgentNetworkDefinition(networkName, configuration.ViewRadius, configuration.LayersSizes);
                var network           = new AgentNetwork(networkDefinition, new He(configuration.NetworkSeed));
                Workspace.Instance.SaveNetwork(networkName, network, overwrite: true);
            }
        }
Exemple #6
0
        public void SaveNetwork(string name, AgentNetwork network, bool overwrite)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException($"Name can't be empty.");
            }

            var fileName    = GetNetworkFileName(name);
            var networkFile = NetworksDirectory.GetFile(fileName);

            if (networkFile.Exists && overwrite == false)
            {
                throw new ArgumentException($"File '{fileName}' already exists.");
            }
            else
            {
                network.Save(networkFile);
            }
        }
Exemple #7
0
 public void Add(string name, AgentNetwork network) => SaveNetwork(name, network, false);