예제 #1
0
        public Ant Execute(int antSize, float desirabilityInfluence, float pheromoneInfluence, float greedyInfluence)
        {
            _pheromoneGraph = new JobGraph(_allJobs.Count);

            for (int index = 0; index < _allJobs.Count; index++)
            {
                _allAnts.Add(new Ant(ref _allJobs, _allJobs[index], ref _pheromoneGraph));
            }

            // Assign an ant as best, as per the algorithm
            Ant   bestAnt            = _allAnts[0];
            float currentBestFitness = 0;

            while (!StopCondition())
            {
                _allAnts.ForEach(ant =>
                {
                    ant.TravelAllNodes();
                    float antFitness = CalculateTotalWeightedTardiness(ant);

                    if (antFitness > currentBestFitness)
                    {
                        currentBestFitness = antFitness;
                        bestAnt            = ant;
                    }

                    //Locally Update And Decay Pheromone
                    _pheromoneGraph.SetPheromoneBetweenTwoJobs();
                });
            }
        }
예제 #2
0
 public Ant(ref List <Job> allJobs, Job startingJob, ref JobGraph jobGraph)
 {
     _allJobs    = allJobs;
     _currentJob = startingJob;
     _jobGraph   = jobGraph;
 }