Exemple #1
0
        private void btnLoadScene_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            IList <ICartesianCoordinate> coordinates = null;
            CostMatrix <double>          costs       = null;

            if (radioButton1.Checked)
            {
                coordinates = LoadCSV_Coordinates(Path.Combine(dropboxlocation, @"10001.csv"));
            }
            else if (radioButton2.Checked)
            {
                coordinates = new[] { new Point(3, 0), new Point(3, 5), new Point(5, 2), new Point(1, 1), new Point(4, 6) };
            }

            if (radioButton4.Checked)
            {
                costs = LoadCSV_Costs(Path.Combine(dropboxlocation, @"dump.csv"), coordinates.Count);
            }
            else if (radioButton3.Checked)
            {
                var costWithFunction = new CostWithFunction <ICartesianCoordinate>(coordinates, Diverse.DistanceSquared);
                costs = new CostMatrix <double>(costWithFunction, coordinates.Count);
            }

            boundingRectangle = coordinates.BoundingRectangle(); // for viewport

            algorithmSet = new AlgorithmSet <ICartesianCoordinate>(coordinates, costs);
            algorithmSet.ClusterAfterIterationEvent += algorithmSet_ClusterAfterIterationEvent;
            algorithmSetClusters      = null;
            lastTSPResultWithClusters = null;

            panel1.Refresh();
        }
Exemple #2
0
        private void btnRunClustering_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (algorithmSet != null)
            {
                algorithmSet.RunCluster((AlgorithmSet <ICartesianCoordinate> .ClusterAlgorithm)comboBox2.SelectedItem, int.Parse(textBox2.Text), int.Parse(textBox3.Text));

                clusteredGraph = new ClusteredGraphToCostMatrix <ICartesianCoordinate>(algorithmSet.costByReference, algorithmSet.Clusters);

                var costMatrixClusters = clusteredGraph.CostMatrix;

                algorithmSetClusters = new AlgorithmSet <Cluster <ICartesianCoordinate, double> >(algorithmSet.Clusters, costMatrixClusters);
                algorithmSetClusters.ClusterAfterIterationEvent += algorithmSetClusters_ClusterAfterIterationEvent;
            }
            else
            {
                Report("First load a scene");
            }

            panel1.Refresh();
        }