public void StartSimulations(PSOInput Params)
        {
            AllowSymulation();

            List <Pooint> MiejscaBomb = LISTChangeFromPunktGrid(Bombs);

            PSOBuilder.SetParams(Params);

            PSO.SetBombs(MiejscaBomb);
            PSO.setIterations(Params.Iteracje);

            Pooint          Spawn    = new Pooint();
            List <Particle> newSwarm = new List <Particle>();

            foreach (var oneSpawn in spawnPoints)
            {
                Spawn    = ChangeGridToPunkt(oneSpawn);
                newSwarm = PSOBuilder.CreateSwarm(Spawn);
                PSO newPso = new PSO(newSwarm);
                newPso.Start();
                FullSimulation.Add(newPso.Swarm);
            }
            //animation
            AnimateSwarm();
        }
 public Car(Pooint position) : base(position)
 {
     base.ZdjecieParticle = new Image();
     base.startX          = position.X;
     base.startY          = position.Y;
     base.timeAnimation   = 0.07;
     GetImage();
 }
 public Particle(Pooint position)
 {
     fitness         = 0;
     Current         = position;
     HistoryPositons = new List <Pooint>();
     HistoryBest     = position;
     Velocity        = new Pooint(GetRandomNum.GetIntNumber(0, 50), GetRandomNum.GetIntNumber(0, 50));
 }
        public static List <Particle> CreateSwarm(Pooint SpawnOne)
        {
            List <Particle> Combained = new List <Particle>();

            Combained.AddRange(MakeLudziki(SpawnOne, true));
            Combained.AddRange(MakeLudziki(SpawnOne, false));

            return(Combained);
        }
Пример #5
0
        double CalcFunction(Pooint single)
        {
            double fitness      = 0;
            int    minusForBomb = -10;
            double stat         = 0.00000000001;

            for (int j = 0; j < BombaPSO.Count; j++)
            {
                //funkcja fitness
                double dulX = ((1000) / ((Math.Abs(single.X - BombaPSO[j].X)) + stat)) + minusForBomb;
                double dulY = ((1000) / ((Math.Abs(single.Y - BombaPSO[j].Y)) + stat)) + minusForBomb;


                fitness += (dulX + dulY);
            }
            fitness = fitness / BombaPSO.Count;
            return(fitness);
        }
        private static List <Particle> MakeLudziki(Pooint SpawnOne, bool Choice)
        {
            List <Particle> Czastki    = new List <Particle>();
            int             jakiRodzaj = Choice ? iloscAut : iloscLudzikow;

            for (int i = 0; i < jakiRodzaj; i++)
            {
                int x = GetRandomNum.GetIntNumber(SpawnOne.X - 10, SpawnOne.X + 10);
                int y = GetRandomNum.GetIntNumber(SpawnOne.Y - 10, SpawnOne.Y + 10);
                if (Choice)
                {
                    Czastki.Add(new Car(new Pooint(x, y)));
                }
                else
                {
                    Czastki.Add(new Scout(new Pooint(x, y)));
                }
            }
            return(Czastki);
        }