//public bool IsSolutionCompleted { get; private set; } = false; public Swarm(SwarmSetting setting) { Setting = setting; N = setting.CostMatrix.GetLength(0); for (int i = 0; i < setting.SwarmSize; i++) { var b = new Bat(0, N) { A = (double)BatProblem.Random.Next(700, 1000) / 1000.0, R = BatProblem.Random.NextDouble(), V = 1, }; Bats.Add(b); } BestPath = new Path(); BestPath.Cities.Add(0); }
public void Test() { Bats b = new Bats(); IOptiTestFunc f = new Weierstrass(); b.dimension = 10; b.searchSpace = f.SearchSpace; double[] res = b.Opti(f.Func); double val = f.Func(res); Assert.AreEqual(f.MinimumValue, val, 5); b = new Bats(); f = new SumSquares(); b.dimension = 10; b.searchSpace = f.SearchSpace; res = b.Opti(f.Func); val = f.Func(res); Assert.AreEqual(f.MinimumValue, val, 5); }