Beispiel #1
0
        public Solution SimulateThis(int[] people, bool[] bus)
        {
            /*  s.bestOrderlijst = null;
             * s.bestOverCapacity = null;
             * s.bestOverTime = null;*/
            /* if (bestSolution != null)
             * {
             *   if (s.score <= bestSolution.score)
             *       bestSolution = s;
             * }
             * else
             *   bestSolution = s;*/

            Solution solution = new Solution(people, bus);

            solution.solutionScore   = Simulation.CompleteSimulation(solution.peopleDistribution, solution.busDistribution);
            solution.peopleRemaining = Simulation.waitingLine.Count;

            bestSolution = solution.Copy();

            while (!StopCondition(solution)) // als aan de conditie niet voldaan is
            {
                BuurtRuimte r = zoeker.ZoekBuurtRuimte(solution);

                int cost = r.GetDifference(solution);

                if (cost <= 0)
                { // buurtruimte is beter? accepteer
                    r.AcceptNewSolution(solution);
                    if (solution.solutionScore <= bestSolution.solutionScore)
                    {
                        bestSolution = solution;
                    }
                    aftermath(r);
                    teller = 0;
                    continue;
                }

                // accepteren we minder? nee? dan gaan we door met de volgende iteratie
                if (!AcceptWorse(cost))
                {
                    aftermath(r);
                    teller++;
                    continue;
                }

                if (solution.solutionScore <= bestSolution.solutionScore)
                {
                    bestSolution = bestSolution.Copy();
                }

                // we accepteren? we voegen samen
                r.AcceptNewSolution(solution);
                aftermath(r);
                teller = 0;
            }


            return(bestSolution);
        }
Beispiel #2
0
        // dingen als aantal iteraties bij houden en iets met q en t doen
        private void aftermath(BuurtRuimte r)
        {
            qCounter--;

            // moeten we t verlagen?
            if (qCounter <= 0)
            {
                t       *= alpha;
                qCounter = _maxQ;
            }

            iteraties++;

            /*  if (iteraties % 10000 == 0)
            *     Console.WriteLine(iteraties);*/
        }