Ejemplo n.º 1
0
        void Order()
        {
            CreateInitialOrderInLayers();
            TryPushingOutStrangersFromHorizontalBlocks();
            int n = 5;

            ConstrainedOrderMeasure measure = null;

            while (n-- > 0 && noGainSteps <= MaxNumberOfNoGainSteps)
            {
                SetXPositions();

                ConstrainedOrderMeasure newMeasure = CreateMeasure();
                if (measure == null || newMeasure < measure)
                {
                    noGainSteps = 0;
                    Ordering.CloneLayers(LayerArrays.Layers, ref yetBestLayers);
                    measure = newMeasure;
                }
                else
                {
                    noGainSteps++;
                    RestoreState();
                }
            }
        }
        void Order()
        {
            CreateInitialOrderInLayers();
            TryPushingOutStrangersFromHorizontalBlocks();
            int n = 5;

            ConstrainedOrderMeasure measure = null;

            while (n-- > 0 && noGainSteps <= MaxNumberOfNoGainSteps)
            {
                SetXPositions();

                ConstrainedOrderMeasure newMeasure = CreateMeasure();
                if (measure == null || newMeasure < measure)
                {
                    noGainSteps = 0;
                    Ordering.CloneLayers(LayerArrays.Layers, ref yetBestLayers);
                    measure = newMeasure;
                }
                else
                {
                    noGainSteps++;
                    RestoreState();
                }
            }

            #region old code

            /*
             * int noGainSteps = 0;
             * for (int i = 0; i < NumberOfSweeps && noGainSteps <= MaxNumberOfNoGainSteps && !measure.Perfect(); i++) {
             *   SweepDown(false);
             *   SweepUp(false);
             *   ConstrainedOrderMeasure newMeasure = CreateMeasure();
             *   if (newMeasure < measure) {
             *       noGainSteps = 0;
             *       Ordering.CloneLayers(LayerArrays.Layers, ref yetBestLayers);
             *       measure = newMeasure;
             *   } else {
             *       noGainSteps++;
             *       RestoreState();
             *   }
             * }
             *
             * SwitchXPositions();
             * SweepUpWithoutChangingLayerOrder(true);
             *
             * SwitchXPositions();
             * SweepDownWithoutChangingLayerOrder(true);
             * AverageXPositions();
             */
            #endregion
        }