Exemple #1
0
 public void initializeComponents()
 {
     classicHS  = null;
     improvedHS = null;
     globalHS   = null;
     adaptiveHS = null;
 }
Exemple #2
0
 private void setHarmonySearch()
 {
     if (currentVariant == HarmonySearchVariant.Classic)
     {
         classicHS           = ClassicSearch.Instance;
         classicHS.Objective = objective;
         if (MaxRadioBtn.Checked)
         {
             classicHS.Optimum = OptimizationGoal.Max;
         }
         if (MinRadioBtn.Checked)
         {
             classicHS.Optimum = OptimizationGoal.Min;
         }
         if (MinAbsRadioBtn.Checked)
         {
             classicHS.Optimum = OptimizationGoal.MinAbs;
         }
         classicHS.NI            = Convert.ToInt32(NITextBox.Text);
         classicHS.TotalNotes    = countDecisionVariables();
         classicHS.MinimumValues = new double[classicHS.TotalNotes];
         classicHS.MaximumValues = new double[classicHS.TotalNotes];
         for (int i = 0; i < classicHS.TotalNotes; i++)
         {
             TextBox minTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MinTextBox", true)[0];
             classicHS.MinimumValues[i] = double.Parse(minTextBox.Text, CultureInfo.InvariantCulture);
             TextBox maxTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MaxTextBox", true)[0];
             classicHS.MaximumValues[i] = double.Parse(maxTextBox.Text, CultureInfo.InvariantCulture);
         }
         classicHS.HMSize = Convert.ToInt32(HMSTextBox.Text);
         classicHS.HMCR   = float.Parse(HMCRTextBox.Text, CultureInfo.InvariantCulture);
         classicHS.PAR    = float.Parse(PARTextBox.Text, CultureInfo.InvariantCulture);
         classicHS.BW     = double.Parse(BWTextBox.Text, CultureInfo.InvariantCulture);
     }
     if (currentVariant == HarmonySearchVariant.Improved)
     {
         improvedHS           = ImprovedSearch.Instance;
         improvedHS.Objective = objective;
         if (MaxRadioBtn.Checked)
         {
             improvedHS.Optimum = OptimizationGoal.Max;
         }
         if (MinRadioBtn.Checked)
         {
             improvedHS.Optimum = OptimizationGoal.Min;
         }
         if (MinAbsRadioBtn.Checked)
         {
             improvedHS.Optimum = OptimizationGoal.MinAbs;
         }
         improvedHS.NI            = Convert.ToInt32(NITextBox.Text);
         improvedHS.TotalNotes    = countDecisionVariables();
         improvedHS.MinimumValues = new double[improvedHS.TotalNotes];
         improvedHS.MaximumValues = new double[improvedHS.TotalNotes];
         for (int i = 0; i < improvedHS.TotalNotes; i++)
         {
             TextBox minTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MinTextBox", true)[0];
             improvedHS.MinimumValues[i] = double.Parse(minTextBox.Text, CultureInfo.InvariantCulture);
             TextBox maxTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MaxTextBox", true)[0];
             improvedHS.MaximumValues[i] = double.Parse(maxTextBox.Text, CultureInfo.InvariantCulture);
         }
         improvedHS.HMSize = Convert.ToInt32(HMSTextBox.Text);
         improvedHS.HMCR   = float.Parse(HMCRTextBox.Text, CultureInfo.InvariantCulture);
         improvedHS.PARmin = float.Parse(PARMinTextBox.Text, CultureInfo.InvariantCulture);
         improvedHS.PARmax = float.Parse(PARMaxTextBox.Text, CultureInfo.InvariantCulture);
         improvedHS.BWmin  = float.Parse(BWMinTextBox.Text, CultureInfo.InvariantCulture);
         improvedHS.BWmax  = float.Parse(BWMaxTextBox.Text, CultureInfo.InvariantCulture);
     }
     if (currentVariant == HarmonySearchVariant.GlobalBest)
     {
         globalHS           = GlobalBestSearch.Instance;
         globalHS.Objective = objective;
         if (MaxRadioBtn.Checked)
         {
             globalHS.Optimum = OptimizationGoal.Max;
         }
         if (MinRadioBtn.Checked)
         {
             globalHS.Optimum = OptimizationGoal.Min;
         }
         if (MinAbsRadioBtn.Checked)
         {
             globalHS.Optimum = OptimizationGoal.MinAbs;
         }
         globalHS.NI            = Convert.ToInt32(NITextBox.Text);
         globalHS.TotalNotes    = countDecisionVariables();
         globalHS.MinimumValues = new double[globalHS.TotalNotes];
         globalHS.MaximumValues = new double[globalHS.TotalNotes];
         for (int i = 0; i < globalHS.TotalNotes; i++)
         {
             TextBox minTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MinTextBox", true)[0];
             globalHS.MinimumValues[i] = double.Parse(minTextBox.Text, CultureInfo.InvariantCulture);
             TextBox maxTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MaxTextBox", true)[0];
             globalHS.MaximumValues[i] = double.Parse(maxTextBox.Text, CultureInfo.InvariantCulture);
         }
         globalHS.HMSize = Convert.ToInt32(HMSTextBox.Text);
         globalHS.HMCR   = float.Parse(HMCRTextBox.Text, CultureInfo.InvariantCulture);
         globalHS.PAR    = float.Parse(PARTextBox.Text, CultureInfo.InvariantCulture);
     }
     if (currentVariant == HarmonySearchVariant.SelfAdaptive)
     {
         adaptiveHS           = SelfAdaptiveSearch.Instance;
         adaptiveHS.Objective = objective;
         if (MaxRadioBtn.Checked)
         {
             adaptiveHS.Optimum = OptimizationGoal.Max;
         }
         if (MinRadioBtn.Checked)
         {
             adaptiveHS.Optimum = OptimizationGoal.Min;
         }
         if (MinAbsRadioBtn.Checked)
         {
             adaptiveHS.Optimum = OptimizationGoal.MinAbs;
         }
         adaptiveHS.NI            = Convert.ToInt32(NITextBox.Text);
         adaptiveHS.TotalNotes    = countDecisionVariables();
         adaptiveHS.MinimumValues = new double[adaptiveHS.TotalNotes];
         adaptiveHS.MaximumValues = new double[adaptiveHS.TotalNotes];
         for (int i = 0; i < adaptiveHS.TotalNotes; i++)
         {
             TextBox minTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MinTextBox", true)[0];
             adaptiveHS.MinimumValues[i] = double.Parse(minTextBox.Text, CultureInfo.InvariantCulture);
             TextBox maxTextBox = (TextBox)this.Controls.Find("x" + (i + 1) + "MaxTextBox", true)[0];
             adaptiveHS.MaximumValues[i] = double.Parse(maxTextBox.Text, CultureInfo.InvariantCulture);
         }
         adaptiveHS.HMSize = Convert.ToInt32(HMSTextBox.Text);
         adaptiveHS.HMCR   = float.Parse(HMCRTextBox.Text, CultureInfo.InvariantCulture);
         adaptiveHS.PAR    = float.Parse(PARTextBox.Text, CultureInfo.InvariantCulture);
     }
 }