コード例 #1
0
        void Calculate()
        {
            Init();

            CloneLayers(layers, ref layerArraysCopy);
            int countOfNoGainSteps = 0;

            measure = new OrderingMeasure(layerArraysCopy, GetCrossingsTotal(properLayeredGraph, layerArrays),
                                          startOfVirtNodes, optimalOriginalGroupSize,
                                          optimalVirtualGroupSize);

            //Stopwatch sw = Stopwatch.StartNew();
            for (int i = 0; i < MaxOfIterations && countOfNoGainSteps < NoGainStepsBound && !measure.IsPerfect(); i++)
            {
                this.ProgressStep();

                bool up = i % 2 == 0;

                LayerByLayerSweep(up);


                if (!balanceVirtAndOrigNodes)
                {
                    AdjacentExchange();
                }
                else
                {
                    AdjacentExchangeWithBalancingVirtOrigNodes();
                }


                var newMeasure = new OrderingMeasure(layerArrays.Layers,
                                                     GetCrossingsTotal(properLayeredGraph, layerArrays),
                                                     startOfVirtNodes,
                                                     optimalOriginalGroupSize, optimalVirtualGroupSize);

                if (measure < newMeasure)
                {
                    Restore();
                    countOfNoGainSteps++;
                }
                else if (newMeasure < measure || HeadOfTheCoin())
                {
                    countOfNoGainSteps = 0;
                    CloneLayers(layers, ref layerArraysCopy);
                    measure = newMeasure;
                }
            }
            //Console.WriteLine("DONE == Calcuate {0}\n\n", sw.ElapsedMilliseconds);
        }
コード例 #2
0
        void Calculate()
        {
            Init();

            CloneLayers(layers, ref layerArraysCopy);
            int countOfNoGainSteps = 0;

            measure = new OrderingMeasure(layerArraysCopy, GetCrossingsTotal(properLayeredGraph, layerArrays),
                                          startOfVirtNodes, optimalOriginalGroupSize,
                                          optimalVirtualGroupSize);

            //Stopwatch sw = Stopwatch.StartNew();
            for (int i = 0; i < MaxOfIterations && countOfNoGainSteps < NoGainStepsBound && !measure.IsPerfect(); i++)
            {
                this.ProgressStep();

                bool up = i % 2 == 0;

                LayerByLayerSweep(up);

                AdjacentExchange();

                var newMeasure = new OrderingMeasure(layerArrays.Layers,
                                                     GetCrossingsTotal(properLayeredGraph, layerArrays),
                                                     startOfVirtNodes,
                                                     optimalOriginalGroupSize, optimalVirtualGroupSize);

                if (measure < newMeasure)
                {
                    Restore();
                    countOfNoGainSteps++;
                }
                else if (newMeasure < measure || HeadOfTheCoin())
                {
                    countOfNoGainSteps = 0;
                    CloneLayers(layers, ref layerArraysCopy);
                    measure = newMeasure;
                }
            }
        }
コード例 #3
0
        void Calculate() {
            Init();

            CloneLayers(layers, ref layerArraysCopy);
            int countOfNoGainSteps = 0;
            measure = new OrderingMeasure(layerArraysCopy, GetCrossingsTotal(properLayeredGraph, layerArrays),
                                          startOfVirtNodes, optimalOriginalGroupSize,
                                          optimalVirtualGroupSize);

            //Stopwatch sw = Stopwatch.StartNew();
            for (int i = 0; i < MaxOfIterations && countOfNoGainSteps < NoGainStepsBound && !measure.IsPerfect(); i++) {
                this.ProgressStep();

                bool up = i%2 == 0;

                LayerByLayerSweep(up);


                if (!balanceVirtAndOrigNodes)
                    AdjacentExchange();
                else
                    AdjacentExchangeWithBalancingVirtOrigNodes();


                var newMeasure = new OrderingMeasure(layerArrays.Layers,
                                                     GetCrossingsTotal(properLayeredGraph, layerArrays),
                                                     startOfVirtNodes,
                                                     optimalOriginalGroupSize, optimalVirtualGroupSize);

                if (measure < newMeasure) {
                    Restore();
                    countOfNoGainSteps++;
                } else if (newMeasure < measure || HeadOfTheCoin()) {
                    countOfNoGainSteps = 0;
                    CloneLayers(layers, ref layerArraysCopy);
                    measure = newMeasure;
                }
            }
            //Console.WriteLine("DONE == Calcuate {0}\n\n", sw.ElapsedMilliseconds);
        }