//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; }
//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); }
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; }
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); }
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(); } } }
TSPSolution SolutionFromParticle(TSPParticle particle) { return(new TSPSolution(((TSPPosition)particle.Position).Route, TSP)); }
TSPSolution SolutionFromParticle(TSPParticle particle) { return new TSPSolution(((TSPPosition)particle.Position).Route, TSP); }