public ParticleSwarmSimulator(CostEvaluator evaluator, IParticleSwarm particleSwarm) { _evaluator = evaluator; _particleSwarm = particleSwarm; _random = new Random(); }
private static void RunAlgorithm(int runCount, CostEvaluator trainCostEvaluator, CostEvaluator testCostEvaluator, IParticleSwarm pso, int particleCount, ConsoleLogger logger, string outputFilePath) { Console.WriteLine($"Starting {runCount} runs..."); for (var i = 0; i < runCount; i++) { var simulator = new ParticleSwarmSimulator(trainCostEvaluator, pso); var weights = simulator.Simulate(particleCount); var cost = testCostEvaluator.Cost(weights); logger.LogRunResult(i, cost, weights); AppendToResultsFile(outputFilePath, cost, weights); } }