Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            checkBoxRunning.Checked      += new RoutedEventHandler(checkBoxRunning_Checked);
            checkBoxRunning.Unchecked    += new RoutedEventHandler(checkBoxRunning_Unchecked);
            buttonResetSearch.Click      += new RoutedEventHandler(buttonResetSearch_Click);
            buttonNewDestinations.Click  += new RoutedEventHandler(buttonNewDestinations_Click);
            buttonMoreDestinations.Click += new RoutedEventHandler(buttonMoreDestinations_Click);
            buttonLessDestinations.Click += new RoutedEventHandler(buttonLessDestinations_Click);

            checkBoxMutateFailedCrossOvers.Checked   += new RoutedEventHandler(checkBoxMutateFailedCrossOvers_Checked);
            checkBoxMutateFailedCrossOvers.Unchecked += new RoutedEventHandler(checkBoxMutateFailedCrossOvers_Unchecked);
            checkBoxMutateDuplicates.Checked         += new RoutedEventHandler(checkBoxMutateDuplicates_Checked);
            checkBoxMutateDuplicates.Unchecked       += new RoutedEventHandler(checkBoxMutateDuplicates_Unchecked);
            checkBoxDoCrossover.Checked   += new RoutedEventHandler(checkBoxDoCrossover_Checked);
            checkBoxDoCrossover.Unchecked += new RoutedEventHandler(checkBoxDoCrossover_Unchecked);

            _randomLocations = RandomProvider.GetRandomDestinations(_destinationCount);
            _algorithm       = new TravellingSalesmanAlgorithm(_startLocation, _randomLocations, _populationCount);

            _bestSolutionSoFar = _algorithm.GetBestSolutionSoFar().ToArray();
            _DrawLines();

            var thread = new Thread(_Thread);

            thread.Start();
        }
Пример #2
0
        void buttonResetSearch_Click(object sender, RoutedEventArgs e)
        {
            lock (_algorithmLock)
                _algorithm = new TravellingSalesmanAlgorithm(_startLocation, _randomLocations, _populationCount);

            _bestSolutionSoFar = _algorithm.GetBestSolutionSoFar().ToArray();
            _DrawLines();
        }
Пример #3
0
        void buttonNewDestinations_Click(object sender, RoutedEventArgs e)
        {
            _randomLocations = RandomProvider.GetRandomDestinations(_destinationCount);

            lock (_algorithmLock)
                _algorithm = new TravellingSalesmanAlgorithm(_startLocation, _randomLocations, _populationCount);

            _bestSolutionSoFar = _algorithm.GetBestSolutionSoFar().ToArray();
            _DrawLines();
        }
Пример #4
0
        private void _AdjustDestinations()
        {
            labelDestinationCount.Text       = _destinationCount.ToString() + " ";
            buttonMoreDestinations.IsEnabled = _destinationCount < 57;
            buttonLessDestinations.IsEnabled = _destinationCount > 6;

            _randomLocations = RandomProvider.GetRandomDestinations(_destinationCount);

            lock (_algorithmLock)
                _algorithm = new TravellingSalesmanAlgorithm(_startLocation, _randomLocations, _populationCount);

            _bestSolutionSoFar = _algorithm.GetBestSolutionSoFar().ToArray();
            _DrawLines();
        }