1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| class Program
{
static void Main(string[] args)
{
int taillePop = 5;
particule[]Swarm = new particule[taillePop];
List<particule>[] tabPbest= new List< particule>[taillePop];
List<particule> pbest = new List<particule>();
List<particule> afficher = new List<particule>();
int[,] vit = new int[2, 2];
int[,] pos = new int[2, 2];
int[,] vit1 = new int[2, 2];
int[,] pos1 = new int[2, 2];
List<int[,]> l1 = new List<int[,]>();
List<int[,]> l2 = new List<int[,]>();
// INITIALISATION DE LA SWARW
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
vit[i, j] = 1;
pos[i, j] = 0;
}
l1.Add(vit);
l2.Add(pos);
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
vit1[i, j] = 1;
pos1[i, j] = 0;
}
l1.Add(vit);
l2.Add(pos);
// affichage de la population initiale
for (int i = 0; i < taillePop; i++)
Swarm[i] = new particule(l1, l2);
for (int i = 0; i < Swarm.Length; i++)
{
Console.WriteLine("la solution n°{0}", i);
Swarm[i].indentifier();
}
// Intialisation de Pbest
for (int i = 0; i < Swarm.Length; i++)
{
//tPbest[i] = Swarm[i].GetPosition(); // initialement le pbest de chaaque particule estla position de la particule
pbest.Add(Swarm[i]);
tabPbest[i] = pbest;
pbest.Remove(Swarm[i]);
}
for (int i = 0; i < tabPbest.Length; i++)
{
afficher = tabPbest[i];
Console.WriteLine("le pbest de la soltion {0}", i);
for (int j = 0; j < afficher.Count ; j++)
afficher[j].indentifier();
} |
Partager