private void rbtACOSolver_CheckedChanged(object sender, EventArgs e) { thePermutationGA = null; theSolver = null; rtbPheromone.Clear(); rtbSolution.Clear(); rtbBestSol.Clear(); rtbLen.Clear(); ACO.Refresh(); ppg.SelectedObject = null; theChart.Series[0].Points.Clear(); theChart.Series[1].Points.Clear(); theChart.Series[2].Points.Clear(); }
private void tsbOpen_Click(object sender, EventArgs e) { theSolver = null; thePermutationGA = null; //open int status = TSPBenchmarkProblem.ImportATSPFile(true, true); if (status == -1) { return; } ACO.Refresh(); title.Text = $"Title: { TSPBenchmarkProblem.Name }"; numCities.Text = $"Number Of Cities: { TSPBenchmarkProblem.NumberOfCities }"; ShortestLen.Text = $"Global Shortest Length: { TSPBenchmarkProblem.OptimumObjective:0.00}"; txtGreedy.Text = $"Greedy Route Length: {TSPBenchmarkProblem.ComputeRouteLength(TSPBenchmarkProblem.GetGreedyShortestRoute())}"; rtbDataDescription.Text = TSPBenchmarkProblem.Comment; int[] cities = new int[TSPBenchmarkProblem.NumberOfCities]; cities = TSPBenchmarkProblem.OptimalTour; if (cities != null) { rtbShort.AppendText("Global Shortest Route: \n"); for (int c = 0; c < TSPBenchmarkProblem.NumberOfCities; c++) { rtbShort.AppendText($"{cities[c]} "); } } cities = TSPBenchmarkProblem.GetGreedyShortestRoute(); if (cities != null) { rtbGreedy.AppendText("Greedy Shortest Route: \n"); for (int c = 0; c < TSPBenchmarkProblem.NumberOfCities; c++) { rtbGreedy.AppendText($"{cities[c]} "); } } rbtCreateGA.Enabled = true; rbtACOSolver.Enabled = true; btnReset.Enabled = true; }
private void createSolver() { if (rbtACOSolver.Checked) { theSolver = new AntColonySystemForTSP(TSPBenchmarkProblem.NumberOfCities, TSPBenchmarkProblem.ComputeRouteLength, TSPBenchmarkProblem.FromToDistanceMatrix); ppg.SelectedObject = theSolver; } else { thePermutationGA = new PermutationGA(TSPBenchmarkProblem.NumberOfCities, OptimizationType.Min, TSPBenchmarkProblem.ComputeObjectiveValue); ppg.SelectedObject = thePermutationGA; } ACO.Refresh(); btnReset.Enabled = true; cbxChecked.Enabled = true; }