/// <summary> /// genetic Average value /// </summary> /// <param name="gen">another genetic</param> private static Genetic[] Cross(int[,] Gen, int[,] gen) { int pos = rand.Next(0, Width) + rand.Next(0, Height) * Width; Genetic[] result = new Genetic[2] { new Genetic(), new Genetic() }; CrossType t = Global.CrossType; if (Global.CrossType == CrossType.Random) { if (rand.NextDouble() > 0.5) { t = CrossType.Vertical; } else { t = CrossType.Horizontal; } } for (int h = 0; h < Height; h++) { for (int w = 0; w < Width; w++) { int a = h, b = w; if (t == CrossType.Vertical) { a = w; b = h; } if (h * Width + w < pos) { result[0].Gen[a, b] = Gen[a, b]; result[1].Gen[a, b] = gen[a, b]; } else { result[1].Gen[a, b] = Gen[a, b]; result[0].Gen[a, b] = gen[a, b]; } } } return(result); }
public static long DistanceScore(Genetic Gen, Genetic gen) { return(DistanceScore(Gen.Gen, gen.Gen)); }
public Genetic(Genetic gen) { Gen = gen.Gen.Clone() as int[, ]; }
public static Genetic[] Cross(Genetic Gen, Genetic gen) { return(Cross(Gen.Gen, gen.Gen)); }