Пример #1
0
        public void run_szenario(int times, String sz, String s)
        {
            int render_every = 5120; //model evaluations

            //n mal laufen lassen für empirische Auswertung
            //(bei den direkten Heuristiken (greedy,insertion,savings nicht nötig, daher n = 1)
            for (int i = 0; i < times; i++)
            {
                //solange ein Prozess läuft mache nichts!
                while (optimizer_running)
                {
                    Thread.Sleep(5000);
                }

                String problemInstance = File.ReadAllText(sz + ".json");
                model = new MEPModel.MEP();
                model.LoadModelString(problemInstance);
                scenario = sz + "_" + s + "_" + i;
                Console.WriteLine("Starting Szenario:" + scenario);
                //setze Kontext
                model.AllowTripContinuation     = true;
                model.PermutateOptions          = false;
                model.AllowUnprofitableRequests = true;
                model.AvgTravelSpeed            = 400;
                model.HotelCostPerNight         = -100;
                model.HourlyWage          = -60;
                model.MilageAllowance     = -0.1;
                model.RevenuePerDayOnsite = 2000;

                Solver.Solver so = null;
                switch (s)
                {
                case "Greedy":
                    so = new GreedySolver(model);
                    break;

                case "SA":
                    so = new SimulatedAnnealingSolver(model, 10000, 1600, render_every, 64);    //somit maximal 10.000*16 = 160.000 modell evaluationen!
                    break;

                case "GA":
                    so = new GeneticSolver(model, 19, 5120, 5, render_every);     //somit maximal 100 * 1.600 = 160.000 modell evaluationen!
                    break;

                case "Insertion":
                    so = new NearestInsertionSolver(model);
                    break;

                case "Savings":
                    so = new SavingsSolver(model);
                    break;
                }
                start = DateTime.Now;
                Start_Optimizer(so);
            }
        }
Пример #2
0
        private void btnRunAsync_Click(object sender, RoutedEventArgs e)
        {
            output_to_file = false;
            tokensource    = new CancellationTokenSource();
            if (model != null && model.Requests.Count > 0)
            {
                btnRunAsync.IsEnabled = false;
                set_model_parameter();
                //clear optimizer Output:
                txtOptimizerOutput.Text = "";

                Solver.Solver s = null;
                if (rbGeneticAlgorithm.IsChecked == true)
                {
                    s = new GeneticSolver(model, Convert.ToInt32(txtGenerations.Text), Convert.ToInt32(txtPopulationSize.Text), Convert.ToInt32(txtMutationProbability.Text), Convert.ToInt32(txtReportProgress.Text));
                }
                if (rbBruteForce.IsChecked == true)
                {
                    if (model.GetNumberOfElements() > 11)
                    {
                        MessageBox.Show("I´m sorry Dave, I`m afraid I can`t do that!");
                    }
                    else
                    {
                        s = new BruteForceSolver(model);
                    }
                }
                if (rbSimulatedAnnealing.IsChecked == true)
                {
                    s = new SimulatedAnnealingSolver(model, Convert.ToInt32(txtStartTemp.Text), Convert.ToInt32(txtSteps.Text), Convert.ToInt32(txtReportProgress.Text), Convert.ToInt32(txtParallelAnnealings.Text));
                }
                if (rbGreedy.IsChecked == true)
                {
                    s = new GreedySolver(model);
                }
                if (rbInsertion.IsChecked == true)
                {
                    s = new NearestInsertionSolver(model);
                }
                if (rbSavings.IsChecked == true)
                {
                    s = new SavingsSolver(model);
                }

                if (s != null)
                {
                    Start_Optimizer(s);
                }
            }
        }