Exemplo n.º 1
0
 private void GetInitialSolutions()
 {
     tspSolution            = new TspSolution(new TspProblem(tspCities));
     vehicleRoutingSolution = new VehicleRoutingSolution(new VehicleRoutingProblem(routingCustomers, routingVehicles));
     floorplanSolution      = new FloorplanSolution(new FloorplanProblem(floorplanRectangles)).Shuffle(1) as FloorplanSolution;
     for (int i = 0; i < 12; i++)
     {
         floorplanSolution = floorplanSolution.Transcode() as FloorplanSolution;
     }
 }
Exemplo n.º 2
0
        private void bwFloorplan_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = (BackgroundWorker)sender;

            algorithmStatus.Text = "Press ESC to cancel";

            FloorplanProblem  problem       = new FloorplanProblem(floorplanRectangles);
            FloorplanSolution startSolution = new FloorplanSolution(problem);

            Swap          swap  = new Swap(problem.Dimension, 10);
            Shift         shift = new Shift(problem.Dimension, 1);
            EmptyLeafMove eLeaf = new EmptyLeafMove(problem.Dimension, 5);
            FullLeafMove  fLeaf = new FullLeafMove(problem.Dimension, 5);
            FullNodeMove  fNode = new FullNodeMove(problem.Dimension, 5);

            MultistartParameters multistartParameters = (MultistartParameters)multistartOptions.Clone();

            LocalDescentParameters ldParameters = new LocalDescentParameters()
            {
                Name           = "VLSI LD",
                Seed           = seed,
                DetailedOutput = true,
                Operators      = new List <Operator> {
                    swap, fLeaf
                }
            };

            SimulatedAnnealingParameters saParameters = new SimulatedAnnealingParameters()
            {
                Name               = "VLSI SA",
                InitProbability    = 0.5,
                TemperatureCooling = 0.96,
                MinCostDeviation   = 0,
                Seed               = seed,
                DetailedOutput     = true,
                Operators          = new List <Operator> {
                    swap, fNode
                }
            };

            StackedParameters ssParameters = new StackedParameters()
            {
                Name                   = "B",
                DetailedOutput         = true,
                OptimizationAlgorithms = new Type[] { typeof(LocalDescent), typeof(SimulatedAnnealing), typeof(LocalDescent) },
                Parameters             = new OptimizationParameters[] { ldParameters, saParameters, ldParameters }
            };

            switch (optimizerType)
            {
            case 0:
            {
                multistartParameters.Parameters            = ldParameters;
                multistartParameters.OptimizationAlgorithm = typeof(LocalDescent);
            }
            break;

            case 1:
            {
                multistartParameters.Parameters            = saParameters;
                multistartParameters.OptimizationAlgorithm = typeof(SimulatedAnnealing);
            }
            break;

            case 2:
            {
                saParameters.InitProbability               = 0.005;
                saParameters.TemperatureCooling            = 0.95;
                multistartParameters.Parameters            = ssParameters;
                multistartParameters.OptimizationAlgorithm = typeof(StackedSearch);
            }
            break;

            case 3:
            {
                saParameters.InitProbability               = 0.005;
                saParameters.TemperatureCooling            = 0.95;
                multistartParameters.InstancesNumber       = 3;
                multistartParameters.Parameters            = ssParameters;
                multistartParameters.OptimizationAlgorithm = typeof(StackedSearch);
            }
            break;
            }

            floorplanOptimizer = new ParallelMultistart(multistartParameters);

            toRenderBackground = false;

            foreach (ISolution solution in floorplanOptimizer.Minimize(startSolution))
            {
                if (worker.CancellationPending)
                {
                    floorplanOptimizer.Stop();
                    e.Cancel = true;
                }
                worker.ReportProgress(0);
            }
        }