private void btnSwarms_Click(object sender, EventArgs e) { Stopwatch sw = new Stopwatch(); //Creating matrix with points in PList Matrix X = new Matrix(dataLength, dimenssions); for (int i = 0; i < PList.Count; i++) { X[i, 0] = PList[i].X; X[i, 1] = PList[i].Y; } SwarmSystem ss = null; sw.Start(); for (int i = 2; i < 6; i++) { ss = new SwarmSystem(i); ss.Initialize(PList, i); sResults.Add(ss.DoPSO(i, 2, X, pic1)); } sResults.Sort(); sw.Stop(); Visualization.DrawClusters(pic1, sResults[0].BestList, sResults[0].SwarmId); MessageBox.Show("Time elapsed to compute (ms): " + sw.ElapsedMilliseconds); //MessageBox.Show("FIN"); }
private void btnClusters_Click(object sender, EventArgs e) { try { int clusters = Int32.Parse(txtCluster.Text); //pic1.Image = null; if (clusters > 1 && clusters < 6) { for (int i = 0; i < sResults.Count; i++) { if (sResults[i].SwarmId == clusters) { Visualization.DrawClusters(pic1, sResults[i].BestList, sResults[i].SwarmId); } } } } catch (Exception) { MessageBox.Show("Wrong input."); } }