source: experiments/frams/evolve-speed-vs-gravity/data/scripts/evolve-speed-vs-gravity.script @ 118

Last change on this file since 118 was 118, checked in by Maciej Komosinski, 10 years ago

added a comment that explains the role of the multiple evaluation phase

File size: 1.6 KB
2name:Evolve for speed vs gravity
3help:Evolve for speed in different gravity settings
5function main(gravity,min_evaluations)
7        Math.randomize();
8        World.wrldg=gravity;
9        Populations[0].perfperiod=100000; //fitness: velocity serves as distance (because sampling period is longer than lifespan)
10        ExpParams.initialgen="XX[|,1:1][N,1:1,2:1][T][G]";
12        Simulator.init();
13        //Simulator.print(GenePools[0][0].genotype); //ensure the initialgen is in the gene pool
15        Simulator.start();
16        while (Simulator.running) Simulator.step(); //runs until the experiment stops by itself
17        var best=GenePools[0].best();
18        Simulator.print("%g (x%g) %s" % % best.popsiz % best.genotype);
20        // Now, since we have indeterminism (default.sim used: random initialization of neural states and random placement of creatures),
21        // we cannot trust fitness values that have not been confirmed (averaged) during multiple evaluations.
22        // So we start another phase where we wait until the best genotype is evaluated at least min_evaluations times.
23        // No new genotypes are introduced in this phase.
24        ExpParams.stagnation=0; //turn off stagnation detection mechanism
25        ExpParams.p_mut=0; //we don't want evolution and new genotypes anymore. We only want to evaluate existing genotypes multiple times
26        ExpParams.p_xov=0;
27        Simulator.start();
28        while (Simulator.running && best.popsiz<min_evaluations) //repeat until the best genotype will be evaluated at least min_evaluations times
29        {
30                Simulator.step();
31                best=GenePools[0].best();
32        }
33        Simulator.stop();
34        Simulator.print("%g (x%g) %s" % % best.popsiz % best.genotype);
Note: See TracBrowser for help on using the repository browser.