Ejemplo n.º 1
0
        private void batchAddButton_Click(object sender, EventArgs e)
        {
            if (architectureTextBox.Text.Trim() == "" || processTextBox.Text.Trim() == "" || learningTextBox.Text.Trim() == "" || newStimuliPackFileDictionary.Count < 1)
            {
                MessageBox.Show("Set the simulation files.");
            }
            else if (!RegularExpression.PositiveIntCheck(repeatTextBox.Text))
            {
                MessageBox.Show("Repeat has to be a positive integer.\nIf you do not want repeat, insert 1.");
            }
            else
            {
                List <BatchData> newBatchDataList = new List <BatchData>();
                for (int repeatIndex = 0; repeatIndex < int.Parse(repeatTextBox.Text); repeatIndex++)
                {
                    BatchData newBatchData = new BatchData();

                    newBatchData.Name                      = batchName;
                    newBatchData.ArchitectureFile          = architectureTextBox.Text;
                    newBatchData.ProcessFile               = processTextBox.Text;
                    newBatchData.LearningSetupFile         = learningTextBox.Text;
                    newBatchData.StimuliPackFileDictionary = newStimuliPackFileDictionary;

                    Simulator newSimulator = new Simulator(random);
                    newSimulator.Architecture_Load(architectureTextBox.Text);
                    newSimulator.Process_Load(processTextBox.Text);
                    foreach (string key in newBatchData.StimuliPackFileDictionary.Keys)
                    {
                        newSimulator.StimuliImport(key, newBatchData.StimuliPackFileDictionary[key]);
                    }
                    newBatchData.Simulator         = newSimulator;
                    newBatchData.LearningSetupList = LearningSetup_Load(learningTextBox.Text);
                    newBatchDataList.Add(newBatchData);
                }
                VariableApply(newBatchDataList);

                newStimuliPackFileDictionary = new Dictionary <string, string>();
                architectureTextBox.Text     = "";
                processTextBox.Text          = "";
                learningTextBox.Text         = "";
                repeatTextBox.Text           = "1";

                StimuliPackList_Refresh();
                BatchDataList_Refresh();
            }
        }
Ejemplo n.º 2
0
        private void batchAddButton_Click(object sender, EventArgs e)
        {
            if (architectureTextBox.Text.Trim() == "" || processTextBox.Text.Trim() == "" || learningTextBox.Text.Trim() == "" || newStimuliPackFileDictionary.Count < 1)
            {
                MessageBox.Show("Set the simulation files.");
            }
            else if (!RegularExpression.PositiveIntCheck(repeatTextBox.Text))
            {
                MessageBox.Show("Repeat has to be a positive integer.\nIf you do not want repeat, insert 1.");
            }
            else
            {
                List<BatchData> newBatchDataList = new List<BatchData>();
                for (int repeatIndex = 0; repeatIndex < int.Parse(repeatTextBox.Text); repeatIndex++)
                {
                    BatchData newBatchData = new BatchData();

                    newBatchData.Name = batchName;
                    newBatchData.ArchitectureFile = architectureTextBox.Text;
                    newBatchData.ProcessFile = processTextBox.Text;
                    newBatchData.LearningSetupFile = learningTextBox.Text;
                    newBatchData.StimuliPackFileDictionary = newStimuliPackFileDictionary;

                    Simulator newSimulator = new Simulator(random);
                    newSimulator.Architecture_Load(architectureTextBox.Text);
                    newSimulator.Process_Load(processTextBox.Text);
                    foreach (string key in newBatchData.StimuliPackFileDictionary.Keys) newSimulator.StimuliImport(key, newBatchData.StimuliPackFileDictionary[key]);
                    newBatchData.Simulator = newSimulator;
                    newBatchData.LearningSetupList = LearningSetup_Load(learningTextBox.Text);
                    newBatchDataList.Add(newBatchData);
                }
                VariableApply(newBatchDataList);

                newStimuliPackFileDictionary = new Dictionary<string, string>();
                architectureTextBox.Text = "";
                processTextBox.Text = "";
                learningTextBox.Text = "";
                repeatTextBox.Text = "1";

                StimuliPackList_Refresh();
                BatchDataList_Refresh();
            }
        }
Ejemplo n.º 3
0
        private void VariableApply(List<BatchData> batchDataList)
        {
            int totalVariousSize = 1;
            foreach (Variable variable in variableList) totalVariousSize *= variable.VariousSize;

            List<List<Change>> changeListList = new List<List<Change>>();
            for (int index = 0; index < totalVariousSize; index++)
            {
                List<Change> newChangeList = new List<Change>();
                changeListList.Add(newChangeList);
            }

            for (int variableIndex = 0; variableIndex < variableList.Count; variableIndex++)
            {
                for (int index = 0; index < totalVariousSize; index += variableList[variableIndex].VariousSize)
                {
                    int subIndex = 0;
                    for (decimal point = (decimal)variableList[variableIndex].StartPoint; point <= (decimal)variableList[variableIndex].EndPoint; point += (decimal)variableList[variableIndex].Step)
                    {
                        Change newChange = new Change();
                        newChange.LayerConnectionName = variableList[variableIndex].LayerConnectionName;
                        newChange.ProcessName = variableList[variableIndex].ProcessName;
                        newChange.VariableType = variableList[variableIndex].VariableType;
                        newChange.Point = (double)point;

                        changeListList[index + subIndex].Add(newChange);
                        subIndex++;
                    }
                }
            }

            List<BatchData> variableBatchData = new List<BatchData>();
            foreach (BatchData batchData in batchDataList)
            {
                for (int index = 0; index < changeListList.Count; index++)
                {
                    BatchData newBatchData = new BatchData();

                    newBatchData.Name = batchName;
                    newBatchData.ArchitectureFile = batchData.ArchitectureFile;
                    newBatchData.ProcessFile = batchData.ProcessFile;
                    newBatchData.LearningSetupFile = batchData.LearningSetupFile;
                    foreach (string key in batchData.StimuliPackFileDictionary.Keys) newBatchData.StimuliPackFileDictionary[key] = batchData.StimuliPackFileDictionary[key];

                    Simulator newBatchSimulator = new Simulator(random);
                    newBatchSimulator.Architecture_Load(newBatchData.ArchitectureFile);
                    newBatchSimulator.Process_Load(newBatchData.ProcessFile);
                    foreach (string key in newBatchData.StimuliPackFileDictionary.Keys) newBatchSimulator.StimuliImport(key, newBatchData.StimuliPackFileDictionary[key]);
                    newBatchData.Simulator = newBatchSimulator;
                    newBatchData.LearningSetupList = LearningSetup_Load(newBatchData.LearningSetupFile);
                    newBatchData.ChangeList = changeListList[index];

                    variableBatchData.Add(newBatchData);
                }
            }

            foreach (BatchData batchData in variableBatchData)
            {
                foreach (Change change in batchData.ChangeList)
                {
                    switch (change.VariableType)
                    {
                        case VariableType.Layer_Unit:
                            List<string> renewalConnectionKeyList = new List<string>();
                            foreach (string key in batchData.Simulator.ConnectionDictionary.Keys)
                            {
                                if (batchData.Simulator.ConnectionDictionary[key].SendLayer.Name == change.LayerConnectionName || batchData.Simulator.ConnectionDictionary[key].ReceiveLayer.Name == change.LayerConnectionName) renewalConnectionKeyList.Add(key);
                            }
                            batchData.Simulator.LayerMaking(change.LayerConnectionName, (int)change.Point, batchData.Simulator.LayerDictionary[change.LayerConnectionName].CleanupUnitCount);
                            foreach (string key in renewalConnectionKeyList)
                            {
                                batchData.Simulator.ConnectionMaking(key, batchData.Simulator.ConnectionDictionary[key].SendLayer.Name, batchData.Simulator.ConnectionDictionary[key].ReceiveLayer.Name);
                            }
                            break;
                        case VariableType.Layer_DamagedSD:
                            if (change.Point != 0) batchData.Simulator.ProcessDictionary[change.ProcessName].LayerStateDictionary[change.LayerConnectionName] = LayerState.Damaged;
                            else batchData.Simulator.ProcessDictionary[change.ProcessName].LayerStateDictionary[change.LayerConnectionName] = LayerState.On;
                            batchData.Simulator.ProcessDictionary[change.ProcessName].LayerDamagedSDDictionary[change.LayerConnectionName] = change.Point;
                            break;
                        case VariableType.Connection_DamagedSD:
                            if (change.Point != 0) batchData.Simulator.ProcessDictionary[change.ProcessName].ConnectionStateDictionary[change.LayerConnectionName] = ConnectionState.Damaged;
                            else batchData.Simulator.ProcessDictionary[change.ProcessName].ConnectionStateDictionary[change.LayerConnectionName] = ConnectionState.On;
                            batchData.Simulator.ProcessDictionary[change.ProcessName].ConnectionDamagedSDDictionary[change.LayerConnectionName] = change.Point;
                            break;
                        case VariableType.LearningRate:
                            batchData.Simulator.LearningRate = change.Point;
                            break;
                        case VariableType.InitialWeight:
                            batchData.Simulator.WeightRange = change.Point;
                            break;
                    }
                }
                batchData.Simulator.SimulatorRenewal();
            }

            this.batchDataList.AddRange(variableBatchData);
        }
Ejemplo n.º 4
0
        private void batchDataListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            StringBuilder newText = new StringBuilder();

            if (batchDataListBox.SelectedIndex >= 0)
            {
                BatchData selectedBatchData = batchDataList[batchDataListBox.SelectedIndex];

                newText.Append("Architecture File: " + selectedBatchData.ArchitectureFile); newText.AppendLine();
                newText.Append("Process File: " + selectedBatchData.ProcessFile); newText.AppendLine();
                newText.Append("Learning Setup File: " + selectedBatchData.LearningSetupFile); newText.AppendLine();
                newText.AppendLine("Stimuli Pack Files");
                foreach (string key in selectedBatchData.StimuliPackFileDictionary.Keys)
                {
                    newText.Append("- " + key + ": " + selectedBatchData.StimuliPackFileDictionary[key]);
                }
                newText.AppendLine();

                newText.AppendLine();
                newText.AppendLine("Layer List");
                foreach (string key in selectedBatchData.Simulator.LayerDictionary.Keys)
                {
                    newText.AppendLine("- " + key + "(" + selectedBatchData.Simulator.LayerDictionary[key].UnitCount + ")");
                }

                newText.AppendLine();
                newText.AppendLine("Connection List");
                foreach (string key in selectedBatchData.Simulator.ConnectionDictionary.Keys)
                {
                    newText.AppendLine("- " + key + "(" + selectedBatchData.Simulator.ConnectionDictionary[key].SendLayer.Name + " -> " + selectedBatchData.Simulator.ConnectionDictionary[key].ReceiveLayer.Name + ")");
                }

                newText.AppendLine();
                newText.AppendLine("Process List");
                foreach (string key in selectedBatchData.Simulator.ProcessDictionary.Keys)
                {
                    newText.Append("- " + key);
                }
                newText.AppendLine();

                newText.AppendLine();
                newText.Append("Stimuli Pack List \n");
                foreach (string key in selectedBatchData.Simulator.StimuliPackDictionary.Keys)
                {
                    newText.AppendLine("- " + key + "(" + selectedBatchData.Simulator.StimuliPackDictionary[key].Count + ")");
                }

                newText.AppendLine();
                newText.Append("Learning Setup List \n");
                foreach (LearningSetup learningSetup in selectedBatchData.LearningSetupList)
                {
                    newText.AppendLine("-Training Info.(" + learningSetup.TrainingMatchingInformationList.Count + ")/" + "Test Info.(" + learningSetup.TestMatchingInformationList.Count + ")");
                }

                newText.AppendLine();
                newText.AppendLine("Applied Variable");
                foreach (Change change in selectedBatchData.ChangeList)
                {
                    switch (change.VariableType)
                    {
                    case VariableType.Layer_Unit:
                        newText.Append("Layer Unit Variable | ");
                        break;

                    case VariableType.Layer_DamagedSD:
                        newText.Append("Layer Damaged SD Variable | ");
                        break;

                    case VariableType.Connection_DamagedSD:
                        newText.Append("Connection Damaged SD Variable | ");
                        break;

                    case VariableType.LearningRate:
                        newText.Append("Learning Rate Variable | ");
                        break;

                    case VariableType.InitialWeight:
                        newText.Append("Initial Weight Variable | ");
                        break;
                    }
                    switch (change.VariableType)
                    {
                    case VariableType.Layer_Unit:
                    case VariableType.Layer_DamagedSD:
                        newText.Append("Layer: " + change.LayerConnectionName + " | ");
                        break;

                    case VariableType.Connection_DamagedSD:
                        newText.Append("Connection: " + change.LayerConnectionName + " | ");
                        break;
                    }
                    switch (change.VariableType)
                    {
                    case VariableType.Layer_DamagedSD:
                    case VariableType.Connection_DamagedSD:
                        newText.Append("Process: " + change.ProcessName + " | ");
                        break;
                    }
                    newText.Append(change.Point.ToString());
                    newText.AppendLine();
                }
            }
            BatchDataInformationRichTextBox.Text = newText.ToString();
        }
Ejemplo n.º 5
0
        private void VariableApply(List <BatchData> batchDataList)
        {
            int totalVariousSize = 1;

            foreach (Variable variable in variableList)
            {
                totalVariousSize *= variable.VariousSize;
            }

            List <List <Change> > changeListList = new List <List <Change> >();

            for (int index = 0; index < totalVariousSize; index++)
            {
                List <Change> newChangeList = new List <Change>();
                changeListList.Add(newChangeList);
            }

            for (int variableIndex = 0; variableIndex < variableList.Count; variableIndex++)
            {
                for (int index = 0; index < totalVariousSize; index += variableList[variableIndex].VariousSize)
                {
                    int subIndex = 0;
                    for (decimal point = (decimal)variableList[variableIndex].StartPoint; point <= (decimal)variableList[variableIndex].EndPoint; point += (decimal)variableList[variableIndex].Step)
                    {
                        Change newChange = new Change();
                        newChange.LayerConnectionName = variableList[variableIndex].LayerConnectionName;
                        newChange.ProcessName         = variableList[variableIndex].ProcessName;
                        newChange.VariableType        = variableList[variableIndex].VariableType;
                        newChange.Point = (double)point;

                        changeListList[index + subIndex].Add(newChange);
                        subIndex++;
                    }
                }
            }


            List <BatchData> variableBatchData = new List <BatchData>();

            foreach (BatchData batchData in batchDataList)
            {
                for (int index = 0; index < changeListList.Count; index++)
                {
                    BatchData newBatchData = new BatchData();

                    newBatchData.Name              = batchName;
                    newBatchData.ArchitectureFile  = batchData.ArchitectureFile;
                    newBatchData.ProcessFile       = batchData.ProcessFile;
                    newBatchData.LearningSetupFile = batchData.LearningSetupFile;
                    foreach (string key in batchData.StimuliPackFileDictionary.Keys)
                    {
                        newBatchData.StimuliPackFileDictionary[key] = batchData.StimuliPackFileDictionary[key];
                    }

                    Simulator newBatchSimulator = new Simulator(random);
                    newBatchSimulator.Architecture_Load(newBatchData.ArchitectureFile);
                    newBatchSimulator.Process_Load(newBatchData.ProcessFile);
                    foreach (string key in newBatchData.StimuliPackFileDictionary.Keys)
                    {
                        newBatchSimulator.StimuliImport(key, newBatchData.StimuliPackFileDictionary[key]);
                    }
                    newBatchData.Simulator         = newBatchSimulator;
                    newBatchData.LearningSetupList = LearningSetup_Load(newBatchData.LearningSetupFile);
                    newBatchData.ChangeList        = changeListList[index];

                    variableBatchData.Add(newBatchData);
                }
            }

            foreach (BatchData batchData in variableBatchData)
            {
                foreach (Change change in batchData.ChangeList)
                {
                    switch (change.VariableType)
                    {
                    case VariableType.Layer_Unit:
                        List <string> renewalConnectionKeyList = new List <string>();
                        foreach (string key in batchData.Simulator.ConnectionDictionary.Keys)
                        {
                            if (batchData.Simulator.ConnectionDictionary[key].SendLayer.Name == change.LayerConnectionName || batchData.Simulator.ConnectionDictionary[key].ReceiveLayer.Name == change.LayerConnectionName)
                            {
                                renewalConnectionKeyList.Add(key);
                            }
                        }
                        batchData.Simulator.LayerMaking(change.LayerConnectionName, (int)change.Point, batchData.Simulator.LayerDictionary[change.LayerConnectionName].CleanupUnitCount);
                        foreach (string key in renewalConnectionKeyList)
                        {
                            batchData.Simulator.ConnectionMaking(key, batchData.Simulator.ConnectionDictionary[key].SendLayer.Name, batchData.Simulator.ConnectionDictionary[key].ReceiveLayer.Name);
                        }
                        break;

                    case VariableType.Layer_DamagedSD:
                        if (change.Point != 0)
                        {
                            batchData.Simulator.ProcessDictionary[change.ProcessName].LayerStateDictionary[change.LayerConnectionName] = LayerState.Damaged;
                        }
                        else
                        {
                            batchData.Simulator.ProcessDictionary[change.ProcessName].LayerStateDictionary[change.LayerConnectionName] = LayerState.On;
                        }
                        batchData.Simulator.ProcessDictionary[change.ProcessName].LayerDamagedSDDictionary[change.LayerConnectionName] = change.Point;
                        break;

                    case VariableType.Connection_DamagedSD:
                        if (change.Point != 0)
                        {
                            batchData.Simulator.ProcessDictionary[change.ProcessName].ConnectionStateDictionary[change.LayerConnectionName] = ConnectionState.Damaged;
                        }
                        else
                        {
                            batchData.Simulator.ProcessDictionary[change.ProcessName].ConnectionStateDictionary[change.LayerConnectionName] = ConnectionState.On;
                        }
                        batchData.Simulator.ProcessDictionary[change.ProcessName].ConnectionDamagedSDDictionary[change.LayerConnectionName] = change.Point;
                        break;

                    case VariableType.LearningRate:
                        batchData.Simulator.LearningRate = change.Point;
                        break;

                    case VariableType.InitialWeight:
                        batchData.Simulator.WeightRange = change.Point;
                        break;
                    }
                }
                batchData.Simulator.SimulatorRenewal();
            }

            this.batchDataList.AddRange(variableBatchData);
        }