/// <summary> /// Click on Bootstrap: bootstrap selected distribution, show two solutions at once /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BootstrapClick_Click(object sender, EventArgs e) { AfterBootstrap = true; _nextButton.Enabled = false; button1.Enabled = false; if (_model.Setting.NumberOfFeatures == 0) { NumberOfFeaturesLabel.Text = @"Select Number of Features first"; return; } Distribution[] results; if (OwnValues) { results = _model.ScaleDistribution(_model.DStore.SelectedFeatureDistribution, _model.Setting.NumberOfFeatures, 2); pictureBox1.ImageLocation = results[0].ImagePath; pictureBox3.ImageLocation = results[1].ImagePath; _model.Setting.SelectedFeature = 0; SelectFirstDist.Enabled = true; SelectSecondDist.Enabled = true; return; } switch (((Distribution)RealFeatureValuesBox.SelectedItem).DisplayName) { case "Normal": results = _model.CreateNormalDist(2, Distribution.DistributionType.Feature); FirstPLabel.Text = @"No test yet"; SecondPLabel.Text = @"No test yet"; break; case "Uniform": results = _model.CreateUnifDist(2, Distribution.DistributionType.Feature); FirstPLabel.Text = @"No test yet"; SecondPLabel.Text = @"No test yet"; break; default: NumberOfFeaturesLabel.Text = @"Scaling to " + _model.Setting.NumberOfFeatures; results = _model.ScaleDistribution(_model.DStore.FeatureToStrap, _model.Setting.NumberOfFeatures, 2); break; } pictureBox1.ImageLocation = results[0].ImagePath; pictureBox3.ImageLocation = results[1].ImagePath; //_model.Setting.SelectedFeature = 0; SelectFirstDist.Enabled = true; SelectFirstDist.Text = @"Select"; SelectSecondDist.Text = @"Select"; SelectSecondDist.Enabled = true; }
/// <summary> /// Bootstrap the interactions /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BootstrapInteractions_Click(object sender, EventArgs e) { //Should not happen at this point! was catched by previous flow if (_model.Setting.NumberOfInteractions == 0) { NumberOfInteractions.Text = @"Select Number of Interactions first"; return; } Distribution[] results; if (SelectedInteractionValues.SelectedItem == null) { results = _model.ScaleDistribution(_model.DStore.SelectedInteractionDistribution, _model.Setting.NumberOfInteractions, 2); } else { switch (((Distribution)SelectedInteractionValues.SelectedItem).DisplayName) { case "Normal": results = _model.CreateNormalDist(2, Distribution.DistributionType.Interaction); pValue1Label.Text = @"No test yet"; pValue2Label.Text = @"No test yet"; break; case "Uniform": results = _model.CreateUnifDist(2, Distribution.DistributionType.Interaction); pValue1Label.Text = @"No test yet"; pValue2Label.Text = @"No test yet"; break; default: results = _model.ScaleDistribution(_model.DStore.InteracToStrap, _model.Setting.NumberOfInteractions, 2); break; } } //var results = _model.ScaleDistribution(_model.DStore.SelectedInteractionDistribution, _model.Setting.NumberOfInteractions, 2); pictureBox2.ImageLocation = results[0].ImagePath; pictureBox4.ImageLocation = results[1].ImagePath; SelectSecond.Enabled = true; SelectFirst.Text = @"Select"; SelectSecond.Text = @"Select"; SelectFirst.Enabled = true; _nextButton.Enabled = false; button2.Enabled = false; _afterBootstrap = true; }
private void button1_Click(object sender, EventArgs e) { if (model.Setting.UnifMax <= model.Setting.UnifMin) { label1.Text = "Max is smaller than Min"; return; } if (double.IsNaN(model.Setting.UnifMin) && double.IsNaN(model.Setting.UnifMax)) { label1.Text = "One or more values were not set!"; return; } model.CreateUnifDist(2, Type); Close(); }
public void StartEvolution() { //Load and Scale Feature try { switch (featurepath) { case COMMAND_NORMAL_RANDOM_FUNCTION: _model.Setting.Mean = feature_random_function_values[0]; _model.Setting.StandardDeviation = feature_random_function_values[1]; _model.CreateNormalDist(1, Distribution.DistributionType.Feature); break; case COMMAND_UNIFORM_RANDOM_FUNCTION: _model.Setting.UnifMin = feature_random_function_values[0]; _model.Setting.UnifMax = feature_random_function_values[1]; _model.CreateUnifDist(1, Distribution.DistributionType.Feature); break; case COMMAND_EXP_RANDOM_FUNCTION: _model.Setting.ExpLambda = feature_random_function_values[0]; _model.CreateExpDist(1, Distribution.DistributionType.Feature); break; default: try { _model.DStore.SelectedFeatureDistribution = CreateDistFromFile(featurepath, "feature"); } catch (Exception e) { Console.WriteLine(e); } if (_model.Setting.SelectedFeature == 0) { _model.CreateNormalDist(2, Distribution.DistributionType.Feature); } else { _model.CreateUnifDist(2, Distribution.DistributionType.Feature); } Console.WriteLine("Selected Feature"); _model.BestDistribution(_model.DStore.SelectedFeatureDistribution, _model.Setting.NumberOfFeatures, 100, 2); break; } _model.DStore.SelectedFeatureDistribution = _model.DStore.ScaledFeatureDistributions[_model.Setting.SelectedFeature]; } catch (Exception e) { Console.WriteLine("Feature Scale failed"); } //Load and Scale Interaction try { switch (interactionpath) { case COMMAND_NORMAL_RANDOM_FUNCTION: _model.Setting.Mean = interaction_random_function_values[0]; _model.Setting.StandardDeviation = interaction_random_function_values[1]; _model.CreateNormalDist(1, Distribution.DistributionType.Interaction); break; case COMMAND_UNIFORM_RANDOM_FUNCTION: _model.Setting.UnifMin = interaction_random_function_values[0]; _model.Setting.UnifMax = interaction_random_function_values[1]; _model.CreateUnifDist(1, Distribution.DistributionType.Interaction); break; case COMMAND_EXP_RANDOM_FUNCTION: _model.Setting.ExpLambda = feature_random_function_values[0]; _model.CreateExpDist(1, Distribution.DistributionType.Interaction); break; default: _model.DStore.SelectedInteractionDistribution = CreateDistFromFile(interactionpath, "interaction"); if (_model.Setting.SelectedInteraction == 0) { _model.CreateNormalDist(2, Distribution.DistributionType.Interaction); } else { _model.CreateUnifDist(2, Distribution.DistributionType.Interaction); } Console.WriteLine("Selected Interaction"); _model.BestDistribution(_model.DStore.SelectedInteractionDistribution, _model.Setting.NumberOfInteractions, 100, 2); break; } _model.DStore.SelectedInteractionDistribution = _model.DStore.ScaledInteractionDistributions[_model.Setting.SelectedInteraction]; } catch (Exception e) { Console.WriteLine("Interaction Scale failed"); } //Load Variant _model.DStore.SelectedTargetDistribution = CreateDistFromFile(variantpath, "variant"); Console.WriteLine("Selected Variant"); //Evolution Console.WriteLine("Start Evolution"); try { //System.Windows.Forms.Application.DoEvents(); backgroundWorker1.RunWorkerAsync(_model); } catch (Exception e) { Console.WriteLine("Evolution failed"); } while (!write_finished) { //Wait half a second. System.Threading.Thread.Sleep(500); } }