private void evaluatePopulation() { evaluator.NewGeneration(); for (int i = 0; i < workers.Length; i++) { workers[i].setGenomeList(genomeList); threads[i] = new Thread(new ThreadStart(workers[i].DoWork)); threads[i].Start(); } EvaluationWorker mainWorker = new EvaluationWorker(start, genomeList.Count, genomeList, evaluator); mainWorker.DoWork(); for (int i = 0; i < threads.Length; i++) { threads[i].Join(); } updateStats(); }
private void createPopulation() { genomeList = new List <QEAGenome>(); int layers = LEEAParams.DOMAIN.getHiddenLayers() + 1; // layers needs to be the number of layers of connections int[] layerNodes = new int[layers + 1]; layerNodes[0] = LEEAParams.DOMAIN.getInputs() + 1; // +1 for the bias! for (int i = 0; i < layers - 1; i++) { layerNodes[i + 1] = LEEAParams.DOMAIN.getHiddenLayerNeurons(i + 1); } layerNodes[layers] = LEEAParams.DOMAIN.getOutputs(); Parallel.For(0, LEEAParams.POPSIZE, po, i => { QEAGenome genome = new QEAGenome(layers, layerNodes, 1); lock (genomeList) { genomeList.Add(genome); } }); // set up our worker threads int end; for (int i = 0; i < workers.Length; i++) { end = start + genomeList.Count / LEEAParams.THREADS; workers[i] = new EvaluationWorker(start, end, genomeList, evaluator); start = end; } // speciate the newly created folks speciatePopulation(); }