private void PSO_OnIteration(object sender, IterationInfo e)
 {
     if (e.Iteration == 0 || e.Iteration == pso.Iterations - 1 || (e.Iteration + 1) % 10 == 0)
     {
         TbxOutput.AppendText(string.Format("Iteration {0:D4} | Best Objective = {1}", e.Iteration + 1, e.BestObjectiveValue) + Environment.NewLine);
     }
 }
        private void PSO_OnEnd(object sender)
        {
            TbxOutput.AppendText("PSO alghorithm finished." + Environment.NewLine);
            TbxOutput.AppendText(string.Format("{0}Final solution:{0}", Environment.NewLine));

            double[] temp = pso.BestSolution.ActualPosition;

            for (int i = 0; i < temp.Length; i++)
            {
                TbxOutput.AppendText(string.Format("\t{0}.    {1}", i + 1, temp[i]) + Environment.NewLine);
            }

            BtnRun.Enabled           = true;
            SettingsGroupBox.Enabled = true;
            BtnRun.BackColor         = Color.Silver;
            BtnRun.Text = "Start";
        }