コード例 #1
0
 //Ha alguma garantia de que essas particulas aleatorias sejam circuitos hamiltonianos?
 public static TSPParticle RandomGenerate(TSPParticleSwarm containingSwarm, TravellingSalesmanMap Map)
 {
     TSPParticle newParticle = new TSPParticle(containingSwarm, Map);
     newParticle.Velocity = TSPVelocity.RandomGenerate(Map);
     newParticle.Position = new TSPPosition(Aleatoriety.GetRandomIntegerSequencePermutation(1, Map.CityCount).ToList());
     newParticle.EvaluateSelf();
     return newParticle;
 }
コード例 #2
0
        //Ha alguma garantia de que essas particulas aleatorias sejam circuitos hamiltonianos?

        public static TSPParticle RandomGenerate(TSPParticleSwarm containingSwarm, TravellingSalesmanMap Map)
        {
            TSPParticle newParticle = new TSPParticle(containingSwarm, Map);

            newParticle.Velocity = TSPVelocity.RandomGenerate(Map);
            newParticle.Position = new TSPPosition(Aleatoriety.GetRandomIntegerSequencePermutation(1, Map.CityCount).ToList());
            newParticle.EvaluateSelf();
            return(newParticle);
        }
コード例 #3
0
 public override object Clone()
 {
     TSPParticle p = new TSPParticle(this.Swarm, Map) {
         Velocity = (TSPVelocity)this.Velocity.Clone(),
         Position = (TSPPosition)this.Position.Clone(),
         Fitness = this.Fitness
     };
     p.pBest = p;
     return p;
 }
コード例 #4
0
        public override object Clone()
        {
            TSPParticle p = new TSPParticle(this.Swarm, Map)
            {
                Velocity = (TSPVelocity)this.Velocity.Clone(),
                Position = (TSPPosition)this.Position.Clone(),
                Fitness  = this.Fitness
            };

            p.pBest = p;
            return(p);
        }
コード例 #5
0
        public void InitializeParticles()
        {
            Particles.Clear();

            TSPParticle firstParticle = TSPParticle.RandomGenerate(this, Map);

            Particles.Add(firstParticle);
            gBest = (TSPParticle)firstParticle.Clone();

            // Inicializar cada Partícula
            for (int pCount = 1; pCount < ParticleCount; ++pCount)
            {
                TSPParticle newParticle = TSPParticle.RandomGenerate(this, Map);
                Particles.Add(newParticle);
                if (newParticle.Fitness < gBest.Fitness)
                {
                    gBest = (TSPParticle)newParticle.Clone();
                }
            }
        }
コード例 #6
0
 TSPSolution SolutionFromParticle(TSPParticle particle)
 {
     return(new TSPSolution(((TSPPosition)particle.Position).Route, TSP));
 }
コード例 #7
0
 TSPSolution SolutionFromParticle(TSPParticle particle)
 {
     return new TSPSolution(((TSPPosition)particle.Position).Route, TSP);
 }