コード例 #1
0
        static void begin(LowerTriangularMatrix <double> lt, int start, int antCount, double alpha,
                          double beta, double pheromoneEvaporationCoef, double pheromoneConstant, int maxIters,
                          Queue <IterationContext> cq)
        {
            AntColony ac = new AntColony(lt, start, antCount, alpha, beta, pheromoneEvaporationCoef,
                                         pheromoneConstant, maxIters, cq);

            ac.begin();
            int currIter = 0;

            while (currIter < maxIters - 1)
            {
                IterationContext it;
                while (cq.TryDequeue(out it) == false)
                {
                    ;
                }
                currIter = it.currIter;
                Console.WriteLine("" + it.currIter);
            }
            var path = string.Join("=>", ac.shortestPath);
            var dist = ac.shrotestDistance;

            Console.WriteLine($"Shortest path has length of {dist} and it is: {path}");
        }
コード例 #2
0
    public void startAlgorithm()
    {
        stoped = false;
        if (aco != null)
        {
            animationControler.reset();
        }

        iterations = new Queue <IterationContext>();
        aco        = new AntColony(getMatrix(), 0, antNumber_, alpha_, beta_,
                                   coefficient_, feremonAmount_, iterationCount_, iterations);

        aco.begin();
        Debug.Log("i started");
        StartCoroutine(waitForIterCtx());
    }