private async void buttonCrossingOver_Click(object sender, EventArgs e) { _InitCanvas(); _DrawMap(); Tour tour1 = new Tour(verticesNumber); tour1.FillRandomData(); textBoxPathLength.Text = graph.GetTourLength(tour1).ToString(); Painter.DrawTour(tour1, graph, pictureBoxCanvas); await PutTaskDelay(1500); _InitCanvas(); _DrawMap(); Tour tour2 = new Tour(verticesNumber); tour2.FillRandomData(); textBoxPathLength.Text = graph.GetTourLength(tour2).ToString(); Painter.DrawTour(tour2, graph, pictureBoxCanvas); await PutTaskDelay(1500); _InitCanvas(); _DrawMap(); Tour tour = new Tour(verticesNumber); tour = tour1.CrossingOver(tour2); textBoxPathLength.Text = graph.GetTourLength(tour).ToString(); Painter.DrawTour(tour, graph, pictureBoxCanvas); }
static private void _MCERoutine(object arg) { //MessageBox.Show("I am thread " + arg.ToString() + "!"); int verticesNumber = graph.VerticesNumber; Tour bestTour = new Tour(verticesNumber); bestTour.FillRandomData(); double minTourLength = graph.GetTourLength(bestTour); for (int i = 0; i < iteratonsNumber; i++) { Tour tempTour = new Tour(verticesNumber); tempTour.FillRandomData(); double currentTourLength = graph.GetTourLength(tempTour); if (currentTourLength < minTourLength) { minTourLength = currentTourLength; bestTour.CopyTour(tempTour); } } routineOutput[(int)arg] = new RoutineOutput(); routineOutput[(int)arg].RoutineTour = bestTour; routineOutput[(int)arg].TourWeight = graph.GetTourLength(bestTour); }
private async void buttonMutation_Click(object sender, EventArgs e) { _InitCanvas(); _DrawMap(); Tour tour = new Tour(verticesNumber); tour.FillRandomData(); textBoxPathLength.Text = graph.GetTourLength(tour).ToString(); Painter.DrawTour(tour, graph, pictureBoxCanvas); await PutTaskDelay(2000); _InitCanvas(); _DrawMap(); tour.Mutate(); textBoxPathLength.Text = graph.GetTourLength(tour).ToString(); Painter.DrawTour(tour, graph, pictureBoxCanvas); }
private void buttonRandomTour_Click(object sender, EventArgs e) { _InitCanvas(); _DrawMap(); Tour tour = new Tour(graph.VerticesNumber); tour.FillRandomData(); textBoxPathLength.Text = graph.GetTourLength(tour).ToString(); Painter.DrawTour(tour, graph, pictureBoxCanvas); if (drawRegion == true) { string[] temp = region.Split(','); Painter.DrawRegion(Convert.ToInt32(temp[0]), Convert.ToInt32(temp[1]), Convert.ToInt32(temp[2]) - 5, Convert.ToInt32(temp[3]) + 5, pictureBoxCanvas); } }