/// <summary> /// Starts up the TSP class. /// This function executes on a thread pool thread. /// </summary> /// <param name="stateInfo">Not used</param> private void BeginTsp(Object stateInfo) { int Col; string nCol = string.Empty; // Assume the StartButton_Click did all the error checking int populationSize = Convert.ToInt32(populationSizeTextBox.Text, CultureInfo.CurrentCulture); int maxGenerations = Convert.ToInt32(maxGenerationTextBox.Text, CultureInfo.CurrentCulture);; int mutation = Convert.ToInt32(mutationTextBox.Text, CultureInfo.CurrentCulture); int groupSize = Convert.ToInt32(groupSizeTextBox.Text, CultureInfo.CurrentCulture); int seed = 0; //Convert.ToInt32(randomSeedTextBox.Text, CultureInfo.CurrentCulture); int numberOfCloseCities = Convert.ToInt32(NumberCloseCitiesTextBox.Text, CultureInfo.CurrentCulture); int chanceUseCloseCity = Convert.ToInt32(CloseCityOddsTextBox.Text, CultureInfo.CurrentCulture); Col = cityList.CalculateCityDistances(numberOfCloseCities); nCol = Convert.ToString(Col); if (label1.InvokeRequired) { label1.Invoke(new Action <string>((s) => label1.Text = s), nCol); } else { label1.Text = nCol; } tsp = new Tsp(); tsp.foundNewBestTour += new Tsp.NewBestTourEventHandler(tsp_foundNewBestTour); tsp.Begin(populationSize, maxGenerations, groupSize, mutation, seed, chanceUseCloseCity, cityList, Col); tsp.foundNewBestTour -= new Tsp.NewBestTourEventHandler(tsp_foundNewBestTour); tsp = null; }
/// Starts up the TSP class. /// This function executes on a thread pool thread. /// stateInfo - Not used private void BeginTsp(Object stateInfo) { // Assume the StartButton_Click did all the error checking int populationSize = Convert.ToInt32(populationSizeTextBox.Text, CultureInfo.CurrentCulture); int maxGenerations = Convert.ToInt32(maxGenerationTextBox.Text, CultureInfo.CurrentCulture);; int mutation = Convert.ToInt32(mutationTextBox.Text, CultureInfo.CurrentCulture); int groupSize = Convert.ToInt32(groupSizeTextBox.Text, CultureInfo.CurrentCulture); int seed = Convert.ToInt32(randomSeedTextBox.Text, CultureInfo.CurrentCulture); int numberOfCloseCities = Convert.ToInt32(NumberCloseCitiesTextBox.Text, CultureInfo.CurrentCulture); int chanceUseCloseCity = Convert.ToInt32(CloseCityOddsTextBox.Text, CultureInfo.CurrentCulture); cityList.CalculateCityDistances(numberOfCloseCities); tsp = new Tsp(); tsp.foundNewBestTour += new Tsp.NewBestTourEventHandler(tsp_foundNewBestTour); tsp.Begin(populationSize, maxGenerations, groupSize, mutation, seed, chanceUseCloseCity, cityList); tsp.foundNewBestTour -= new Tsp.NewBestTourEventHandler(tsp_foundNewBestTour); tsp = null; }