private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            //Example graph from AI
            GraphGenerationMethods graphGenerator = new GraphGenerationMethods(_parameters);

            graphGenerator.GenerateTriangulationOfGraph();

            //Refresh pareto front
            var cutsSum     = EdgeMethod.GetCutsWeightsSum(_parameters.GeneratedBasicGraph, _parameters.Population);
            var cutsCount   = EdgeMethod.GetCutsCount(_parameters.GeneratedBasicGraph, _parameters.Population);
            var paretoArray = cutsCount.
                              Zip(cutsSum, (first, second) => (first, second)).
                              Select(x => new double[] { x.first, x.second }).ToList();

            _parameters.RewriteThePoints(paretoArray);
            _parameters.MainWindow.ParetoChart.EditSeriesCollection(_parameters.ListOfPoints);

            //aktualizacja macierzy incydencji
            MatrixMethod matrixMethod = new MatrixMethod(_parameters);

            _parameters.incidenceMatrix = matrixMethod.FillTheSecondHalfOfTheMatrix(_parameters.incidenceMatrix);

            _parameters.GeneratedBasicGraph = EdgeMethod.GenerateEdges(_parameters.incidenceMatrix, _parameters.verticesBasicGeneratedGraph, _parameters.GeneratedBasicGraph);

            //aktualizacja wyświetlanej macierzy incydencji i wag (frontend)
            VertexMethod.CalculateTheSum(_parameters.incidenceMatrix, _parameters.verticesTriangulationOfGraph);
            VertexMethod.SetVertexNeighbors(_parameters.incidenceMatrix, _parameters.verticesTriangulationOfGraph);

            _parameters.MainWindow.OverallFluctuationChart.EditASeries(
                _parameters.FitnessArray.Average(),
                _parameters.IterationNumber);

            _parameters.MainWindow.SecondChart.EditBSeries(
                _parameters.FitnessArray.Min(),
                _parameters.IterationNumber);

            var minimumFitnessGraphIndex = _parameters.FitnessArray.ToList().IndexOf(_parameters.FitnessArray.Min());

            //var minimumFitnessGraphIndex = 0;
            _parameters.CountedExtremum = $"({cutsCount[minimumFitnessGraphIndex]}; {cutsSum[minimumFitnessGraphIndex]})";

            _parameters.MainWindow.ProgressBar.Value = _parameters.IterationNumber;

            _parameters.CurrentGroupsVertices = GraphGenerationMethods.GetGroupsVertices(
                _parameters.GeneratedBasicGraph,
                _parameters.Population,
                minimumFitnessGraphIndex);
            string groupsVerticesString = "";

            if (_parameters.CurrentGroupsVertices.ContainsValue(0))
            {
                groupsVerticesString += "Warning: group 0 detected. ";
            }
            _parameters.CurrentGroupsVertices.OrderBy(x => x.Key.Index).ToList().ForEach(x => groupsVerticesString += $"V: {x.Key.Index + 1}, G: {x.Value}; ");
            _parameters.MainWindow.GroupList.Content = groupsVerticesString;

            matrixMethod.RefreshMatrixUi(_parameters.TriangulationOfGraph);

            _parameters.MainWindow.ResetZoomControl(_parameters.MainWindow.TriangulationGraphZoomControl);
        }
        private void GenerateGraph(object sender, RoutedEventArgs e)
        {
            Start.IsEnabled = true;

            //Generujemy basic graf, który później nie będzie już zupełnie modyfikowany
            GraphGenerationMethods graphGenerator = new GraphGenerationMethods(_parameters);

            graphGenerator.GenerateBasicGraph();

            //Reset pareto, triangulation graph
            ParetoChart.ResetAll();
            _parameters.TriangulationOfGraph = new Graph(true);

            ResetZoomControl(BasicGraphZoomControl);
        }
Example #3
0
        //function to count edges
        public int[] EdgeCounts()
        {
            var population = parameters.Population;
            var result = new int[population[0].Length];

            for (int i = 0; i < population[0].Length; i++)
            {
                //var edgeCount = 0;
                var groupGraphs = GraphGenerationMethods.GenerateGraphFromCaran(population, i).
                    Where(x => x != null).
                    Where(x => x.VertexCount != 0);
                groupGraphs.ToList().ForEach(x => EdgeMethod.ConnectAllVertices(x));
                var edgeCount = groupGraphs.Select(x => x.EdgeCount).Sum();

                result[i] = edgeCount;
            }

            return result;
        }