static void RunTrial(int offset) { RESULTS_FILE = EXPERIMENTS_DIR + RESULTS_FILE_BASE + offset + ".csv"; _random = new FastRandom(); _experiment = new SocialExperiment(); XmlDocument xmlConfig = new XmlDocument(); xmlConfig.Load(CONFIG_FILE); _experiment.Initialize("SimpleEvolution", xmlConfig.DocumentElement); _experiment.NeatGenomeParameters.AddConnectionMutationProbability = 0; _experiment.NeatGenomeParameters.AddNodeMutationProbability = 0; _experiment.NeatGenomeParameters.DeleteConnectionMutationProbability = 0; SocialExperiment.CreateNetwork(FEED_FORWARD_NETWORK_FILE, _experiment.InputCount, _experiment.OutputCount); // Record the changes at each step _experiment.World.Stepped += new social_learning.World.StepEventHandler(World_Stepped); // Read in the seed genome from file. This is the prototype for our other population of networks. var seed = _experiment.LoadPopulation(XmlReader.Create(FEED_FORWARD_NETWORK_FILE))[0]; // Create a genome factory with our neat genome parameters object and the appropriate number of input and output neuron genes. IGenomeFactory <NeatGenome> genomeFactory = _experiment.CreateGenomeFactory(); // Create an initial population of randomly generated genomes. List <NeatGenome> genomeList = genomeFactory.CreateGenomeList(_experiment.DefaultPopulationSize, 0, seed); // Randomize the genomes RandomizeGenomes(genomeList); // Create genome decoder. IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = _experiment.CreateGenomeDecoder(); // Create the evaluator that will handle the simulation _evaluator = new ForagingEvaluator <NeatGenome>(genomeDecoder, _experiment.World, AgentTypes.Social) { MaxTimeSteps = 200000UL, BackpropEpochsPerExample = 1 }; using (TextWriter writer = new StreamWriter(RESULTS_FILE)) writer.WriteLine("Step,Best,Average"); // Start the simulation _evaluator.Evaluate(genomeList); }
static void Main(string[] args) { _random = new FastRandom(); _experiment = new SocialExperiment(); XmlDocument xmlConfig = new XmlDocument(); xmlConfig.Load(CONFIG_FILE); _experiment.Initialize("SimpleEvolution", xmlConfig.DocumentElement); _experiment.NeatGenomeParameters.AddConnectionMutationProbability = 0; _experiment.NeatGenomeParameters.AddNodeMutationProbability = 0; _experiment.NeatGenomeParameters.DeleteConnectionMutationProbability = 0; SocialExperiment.CreateNetwork(FEED_FORWARD_NETWORK_FILE, _experiment.InputCount, 20, _experiment.OutputCount); // Record the changes at each step _experiment.World.Stepped += new social_learning.World.StepEventHandler(World_Stepped); // Read in the teacher genome from file. var agentGenome = _experiment.LoadPopulation(XmlReader.Create(FEED_FORWARD_NETWORK_FILE)); // Create genome decoder. IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = _experiment.CreateGenomeDecoder(); // Create the evaluator that will handle the simulation _evaluator = new ForagingEvaluator <NeatGenome>(genomeDecoder, _experiment.World, AgentTypes.QLearning) { MaxTimeSteps = 50000000UL, BackpropEpochsPerExample = 1 }; using (TextWriter writer = new StreamWriter(RESULTS_FILE)) writer.WriteLine("Step,Score"); // Start the simulation _evaluator.Evaluate(agentGenome); }
private void startQLearning() { SocialExperiment.CreateNetwork(QLEARNING_FEED_FORWARD_NETWORK_FILE, _experiment.InputCount, 20, _experiment.OutputCount); // Read in the teacher genome from file. var agentGenome = _experiment.LoadPopulation(XmlReader.Create(QLEARNING_FEED_FORWARD_NETWORK_FILE)); // Create genome decoder. IGenomeDecoder <NeatGenome, IBlackBox> genomeDecoder = _experiment.CreateGenomeDecoder(); // Create the evaluator that will handle the simulation _experiment.Evaluator = new ForagingEvaluator <NeatGenome>(genomeDecoder, _experiment.World, AgentTypes.QLearning) { MaxTimeSteps = 50000000UL, BackpropEpochsPerExample = 1, LogDiversity = false }; // Add the world reset _experiment.World.Stepped += new World.StepEventHandler(World_Stepped); // Start the simulation _experiment.Evaluator.Evaluate(agentGenome); }