/// <summary> /// Event handler startButton_Click /// </summary> private void startButton_Click(object sender, EventArgs e) { if (this.startButton.Text == "Start") { // get input neuron try { this.inputLayerNeurons = Math.Max(1, Math.Min(48, Math.Min(this.variable.Observations / 2, int.Parse(this.inputLayerBox.Text)))); } catch { this.inputLayerNeurons = Math.Min(this.variable.Observations / 2, 12); } if (this.variable.SeriesValuesNoNaN.Count - this.inputLayerNeurons < 8) { MessageBox.Show("Unsufficent number of observations\nModel cannot be estimated with these variable", "Neural Network Analysis", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (this.variable.SeriesValuesNoNaN.Count - this.inputLayerNeurons < 28) { MessageBox.Show("Too few number of observations\nModel may be not adequate", "Neural Network Analysis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // get hidden neuron try { this.hiddenLayerNeurons = Math.Max(1, Math.Min(48, int.Parse(this.hiddenLayerBox.Text))); } catch { this.hiddenLayerNeurons = 12; } // get learning rate try { this.learningRate = Math.Max(0.00001, Math.Min(1, double.Parse(this.learningRateBox.Text))); } catch { this.learningRate = 0.05; } // get momentum try { this.momentum = Math.Max(0.00, Math.Min(1, double.Parse(this.momentumBox.Text))); } catch { this.momentum = 0.5; } // get max iteration try { this.maxIteration = Math.Max(10, Math.Min(1000000, int.Parse(this.maxIterationBox.Text))); } catch { this.maxIteration = 10000; } //get activationfunction if (this.semiLinearRadio.Checked == true) this.selectedActivationFunction = ActivationFunctionEnumeration.SemiLinearFunction; else if (this.sigmoidRadio.Checked == true) this.selectedActivationFunction = ActivationFunctionEnumeration.SigmoidFunction; else if (this.bipolarSigmoidRadio.Checked == true) this.selectedActivationFunction = ActivationFunctionEnumeration.BipolarSigmoidFunction; else if (this.hyperbolicTangentRadio.Checked == true) this.selectedActivationFunction = ActivationFunctionEnumeration.HyperbolicTangentFunction; //get with checking cycle this.withCheckingCycle = this.withCheckingCycleCheck.Checked; //get checking cycle try { this.checkingCycle = Math.Max(1, Math.Min(10000, int.Parse(this.checkingCycleBox.Text))); } catch { this.checkingCycle = 100; } //get checking method if (this.byMSEValueRadio.Checked == true) this.checkingMethod = CheckingMethodEnumeration.byMSEValue; else if (this.byMSEChangeRadio.Checked == true) this.checkingMethod = CheckingMethodEnumeration.byMSEChange; //get bymsevalue try { this.byMSEValueStopping = Math.Max(0.000001, double.Parse(this.byMSEValueBox.Text)); } catch { this.byMSEValueStopping = 0.1; } //get bymsechange try { this.byMSEChangeStopping = Math.Max(0.0000001, double.Parse(this.byMSEChangeBox.Text)); } catch { this.byMSEChangeStopping = 0.01; } //get use advance early stopping this.useAdvanceEarlyStopping = this.useAdvanceCheck.Checked; //get advance early stopping method if (this.generalizationLossRadio.Checked == true) this.advanceStoppingMethod = AdvanceStoppingMethodEnumeration.GeneralizationLoss; else if (this.PQRadio.Checked == true) this.advanceStoppingMethod = AdvanceStoppingMethodEnumeration.ProgressQuotient; // get validation set ratio try { this.validationSetRatio = Math.Max(0.0, Math.Min(0.5, double.Parse(this.validationSetRatioBox.Text))); } catch { this.validationSetRatio = 0.3; } // get generalization loss treshold try { this.generalizationLossTreshold = Math.Max(0.0, Math.Min(90.0, double.Parse(this.generalizationLossTresholdBox.Text))); } catch { this.generalizationLossTreshold = 2.0; } // get PQ treshold try { this.pqTreshold = Math.Max(0.0, Math.Min(90.0, double.Parse(this.PQTresholdBox.Text))); } catch { this.pqTreshold = 1.5; } //get strip try { this.strip = Math.Max(2, Math.Min(20, int.Parse(this.stripBox.Text))); } catch { this.strip = 5; } this.updateSettings(); this.enableControls(false); this.setProgressView(); needToStop = false; this.learningThread = new Thread(new ThreadStart(this.searchSolution)); this.learningThread.Start(); } else { // check if worker thread is running if ((learningThread != null) && (learningThread.IsAlive)) { // stop worker thread needToStop = true; learningThread.Join(); learningThread = null; } this.enableControls(true); } }
/// <summary> /// Event handler startButton_Click /// </summary> private void startButton_Click(object sender, EventArgs e) { if (this.startButton.Text == "Start") { // get input neuron try { this.inputLayerNeurons = Math.Max(1, Math.Min(48, Math.Min(this.variable.Observations / 2, int.Parse(this.inputLayerBox.Text)))); } catch { this.inputLayerNeurons = Math.Min(this.variable.Observations / 2, 12); } if (this.variable.SeriesValuesNoNaN.Count - this.inputLayerNeurons < 8) { MessageBox.Show("Unsufficent number of observations\nModel cannot be estimated with these variable", "Neural Network Analysis", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (this.variable.SeriesValuesNoNaN.Count - this.inputLayerNeurons < 28) { MessageBox.Show("Too few number of observations\nModel may be not adequate", "Neural Network Analysis", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } // get hidden neuron try { this.hiddenLayerNeurons = Math.Max(1, Math.Min(48, int.Parse(this.hiddenLayerBox.Text))); } catch { this.hiddenLayerNeurons = 12; } // get learning rate try { this.learningRate = Math.Max(0.00001, Math.Min(1, double.Parse(this.learningRateBox.Text))); } catch { this.learningRate = 0.05; } // get momentum try { this.momentum = Math.Max(0.00, Math.Min(1, double.Parse(this.momentumBox.Text))); } catch { this.momentum = 0.5; } // get max iteration try { this.maxIteration = Math.Max(10, Math.Min(1000000, int.Parse(this.maxIterationBox.Text))); } catch { this.maxIteration = 10000; } //get activationfunction if (this.semiLinearRadio.Checked == true) { this.selectedActivationFunction = ActivationFunctionEnumeration.SemiLinearFunction; } else if (this.sigmoidRadio.Checked == true) { this.selectedActivationFunction = ActivationFunctionEnumeration.SigmoidFunction; } else if (this.bipolarSigmoidRadio.Checked == true) { this.selectedActivationFunction = ActivationFunctionEnumeration.BipolarSigmoidFunction; } else if (this.hyperbolicTangentRadio.Checked == true) { this.selectedActivationFunction = ActivationFunctionEnumeration.HyperbolicTangentFunction; } //get with checking cycle this.withCheckingCycle = this.withCheckingCycleCheck.Checked; //get checking cycle try { this.checkingCycle = Math.Max(1, Math.Min(10000, int.Parse(this.checkingCycleBox.Text))); } catch { this.checkingCycle = 100; } //get checking method if (this.byMSEValueRadio.Checked == true) { this.checkingMethod = CheckingMethodEnumeration.byMSEValue; } else if (this.byMSEChangeRadio.Checked == true) { this.checkingMethod = CheckingMethodEnumeration.byMSEChange; } //get bymsevalue try { this.byMSEValueStopping = Math.Max(0.000001, double.Parse(this.byMSEValueBox.Text)); } catch { this.byMSEValueStopping = 0.1; } //get bymsechange try { this.byMSEChangeStopping = Math.Max(0.0000001, double.Parse(this.byMSEChangeBox.Text)); } catch { this.byMSEChangeStopping = 0.01; } //get use advance early stopping this.useAdvanceEarlyStopping = this.useAdvanceCheck.Checked; //get advance early stopping method if (this.generalizationLossRadio.Checked == true) { this.advanceStoppingMethod = AdvanceStoppingMethodEnumeration.GeneralizationLoss; } else if (this.PQRadio.Checked == true) { this.advanceStoppingMethod = AdvanceStoppingMethodEnumeration.ProgressQuotient; } // get validation set ratio try { this.validationSetRatio = Math.Max(0.0, Math.Min(0.5, double.Parse(this.validationSetRatioBox.Text))); } catch { this.validationSetRatio = 0.3; } // get generalization loss treshold try { this.generalizationLossTreshold = Math.Max(0.0, Math.Min(90.0, double.Parse(this.generalizationLossTresholdBox.Text))); } catch { this.generalizationLossTreshold = 2.0; } // get PQ treshold try { this.pqTreshold = Math.Max(0.0, Math.Min(90.0, double.Parse(this.PQTresholdBox.Text))); } catch { this.pqTreshold = 1.5; } //get strip try { this.strip = Math.Max(2, Math.Min(20, int.Parse(this.stripBox.Text))); } catch { this.strip = 5; } this.updateSettings(); this.enableControls(false); needToStop = false; this.learningThread = new Thread(new ThreadStart(this.searchSolution)); this.learningThread.Start(); } else { // check if worker thread is running if ((learningThread != null) && (learningThread.IsAlive)) { // stop worker thread needToStop = true; learningThread.Join(); learningThread = null; } this.enableControls(true); } }