Exemplo n.º 1
0
        private async void BtnPlot_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidateData())
            {
                return;
            }

            PlotInfo plotInfo = new PlotInfo();

            myPso = new PsoAlgorithm(numParticles, maxEpochs, minX, maxX, values);
            FunctionDelegate functionDelegate = null;

            switch (ComboBox.SelectedIndex)
            {
            case 0:
                functionDelegate = Functions.Michalewicz;
                break;

            case 1:
                functionDelegate = Functions.Rosenbrock;
                break;

            case 2:
                functionDelegate = Functions.Ackley;
                break;

            case 3:
                functionDelegate = Functions.Rastrigin;
                break;

            case 4:
                functionDelegate = Functions.Sphere;
                break;

            case 5:
                functionDelegate = Functions.Levy;
                break;

            case 6:
                functionDelegate = Functions.Griewank;
                break;

            case 7:
                functionDelegate = Functions.Schwefel;
                break;

            default:
                break;
            }
            plotInfo = await CalculatePlotInfo(myPso, functionDelegate);

            ShowDetails(plotInfo.BestPostion, plotInfo.TrueMin, plotInfo.Val, plotInfo.Error);
            GeneratePlot(plotInfo);
        }
Exemplo n.º 2
0
 public Task <PlotInfo> CalculatePlotInfo(PsoAlgorithm myFirefly, FunctionDelegate functionDelegate)
 {
     return(Task.Factory.StartNew(() => myFirefly.Start(functionDelegate)));
 }