title: Brute Force Optimization
body: <p>I am developing an application which uses a plug-ins, the plug-ins are developed by independent developers. I need to optimize the parameters for the plug-in using brute force.</p>
  
  <pre><code>public class Parameter
  {
      public double Start { get; set; }
      public double Step { get; set; }
      public double Stop { get; set; }
      public double Value { get; set; }
  }
  
  public class Plugin
  {
      public List&lt;Parameter&gt; Parameters { get; private set; }
  
      public Plugin()
      {
          Parameters = new List&lt;Parameter&gt;()
          {
              new Parameter() { Start = 1, Step = 1, Stop = 2 },
              new Parameter() { Start = 3, Step = 1, Stop = 4 }
          };
      }
  
      public void Execute()
      {
          double sum = 0;
          foreach (var parameter in Parameters)
          {
              sum += parameter.Value;
          }
          Console.WriteLine("Sum = " + sum);
      }
  }
  
  class Program
  {
      static void Main(string[] args)
      {
          var test = new Plugin();
          test.Parameters[0].Value = test.Parameters[0].Start;
          test.Parameters[1].Value = test.Parameters[1].Start;
          test.Execute();
          Console.ReadLine();
      }
  }
  </code></pre>
  
  <p>But unfortunately I can't invent algorithm of optimization of parameters. 
  Under brute force, I mean</p>
  
  <p><img src="https://i.stack.imgur.com/piQF9.jpg" alt="enter image description here"></p>
  
  <pre><code>Parameter1 = 1
  Parameter2 = 3
  
  Parameter1 = 1
  Parameter2 = 4
  
  Parameter1 = 2
  Parameter2 = 3
  
  Parameter1 = 2
  Parameter2 = 4
  </code></pre>
  
  <p>The main problem consists in that that the quantity of parameters in a plug-in can be any.
  Maybe you could suggest which algorithm to use in this case.</p>
  
  <p>P.S.: sorry for my bad English.</p>
  
  <p>-----addition--------</p>
  
  <p>In other words.</p>
  
  <p>I made a new example that illustrates what I want to do.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var test = new Plugin();
  
          for (double parameter_0 = test.Parameters[0].Start; parameter_0 &lt;= test.Parameters[0].Stop; parameter_0+= test.Parameters[0].Step)
          {
              for (double parameter_1 = test.Parameters[1].Start; parameter_1 &lt;= test.Parameters[1].Stop; parameter_1 += test.Parameters[1].Step)
              {
                  test.Parameters[0].Value = parameter_0;
                  test.Parameters[1].Value = parameter_1;
                  test.Execute();
              }
          }
          Console.ReadLine();
      }
  }
  
  public class Plugin
  {
      public List&lt;Parameter&gt; Parameters { get; private set; }
  
      public Plugin()
      {
          Parameters = new List&lt;Parameter&gt;()
          {
              new Parameter() { Start = 1, Value = 1, Step = 1, Stop = 2 },
              new Parameter() { Start = 3, Value = 3, Step = 1, Stop = 4 }
          };
      }
  
      public void Execute()
      {
          Console.WriteLine(Convert.ToString(Parameters[0].Value) + " " + Convert.ToString(Parameters[1].Value));
      }
  }
  </code></pre>
  
  <p>This code works correctly but unfortunately if the plugin to add a new parameter the code will break. I need to invent an algorithm which is not sensitive to the number of parameters.
  I know that I can use recursion but then I can not use multi-threading.</p>