public static void Run(CostFunction f, int max_iterations = 200) { NelderMeadMethod s = new NelderMeadMethod(); double[] x_0 = f.CreateRandomSolution(); s.SolutionUpdated += (best_solution, step) => { Console.WriteLine("Step {0}: Fitness = {1}", step, best_solution.Cost); }; s.Minimize(x_0, f, max_iterations); }
public MainForm() { InitializeComponent(); valveCoefficientLabel.Text = ControlSystems.SystemSettings.Interference.ToString(); kTextBox.Text = SystemSettings.DefaultK.ToString(); kiTextBox.Text = SystemSettings.DefaultKi.ToString(); kdTextBox.Text = SystemSettings.DefaultK.ToString(); controlSystem = new TankControlSystem(dt); controlSystem2 = new TankControlSystem(dt); optimization = new NelderMeadMethod(); double[] X = controlSystem.Regulator.GetConfig(); controlSystem2.Regulator.RewriteConfig(optimization.nelMead(ref X)); Optimal.Text += string.Format("\nK = {0}\nKi = {1}\nKd = {2}", controlSystem2.Regulator.K, controlSystem2.Regulator.Ki, controlSystem.Regulator.Kd); }