Menu

Standard Evaluator

Giovanni Squillero

Writing a compliant evaluator

One of the main advantages of µGP is the ability to use an external program to obtain the fitness value of the individuals. The program can be of any kind (executable, Python script, Perl script, Bash script, Matlab script, ...) provided that it satisfies a few constraints.

Command-line input

µGP will write each individual to a text file before calling the evaluator. The evaluator must be able to accept as many individual input files as specified in the Population's Settings XML configuration file (minimum one). µGP will call the evaluator with the equivalent of a system function, listing all individuals to be evaluated after the name of the executable, as specified in the Population's Settings.

For example, if the Population's Settings are specified as follows:

 <evaluation>
     <concurrentEvaluations value="5" />
     <removeTempFiles value="true" />
     <evaluatorPathName value="perl onemax.fitness-script.pl" />
     <evaluatorInputPathName value="ind%s.in" />
     <evaluatorOutputPathName value="fitness.out" />
 </evaluation>

µGP could call the evaluator program with a command-line like:

 perl onemax.fitness-script.pl indA.in indX.in indZ.in indK2.in indGS.in

Note that µGP can call the evaluator with less individuals than the maximum specified for concurrentEvaluations, for example if it's evaluating the last bunch of offspring in the current generation.

µGP formatted output

At the end of the execution, the evaluator must return a text file containing the fitness values for the individual(s) that µGP passed as command-line arguments. The text file must have the name specified in the tag evaluatorOutputPathName.

Taking the example above, the name of the text file is "fitness.out": such a file must contain one line for each individual evaluated, in the order the individuals appeared in the command line. On each line, several numbers may appear: µGP supports multiple fitness values for each individual, that will be considered hierarchically. The number of fitness values to read for each individual is specified in Population's Settings. Everything appearing after the last number, up to the following "space" will be considered a comment; µGP is able to store a comment for each individual.

An example of fitness file for the five individuals above, considering
two fitness values each:

 0.1 0.9 #this_is_a_comment_for_fitness_of_individualA
 0.233 0.82 #this_is_a_comment_for_fitness_of_individualX
 0.323 0.73 #this_is_a_comment_for_fitness_of_individualZ
 0.423 0.6 #this_is_a_comment_for_fitness_of_individualK2
 0.711 0.9222 #this_is_a_comment_for_fitness_of_individualGS #this_will_not_be_read!

µGP accepts fitness values with the precision of C++ floating point variables.


Related

Wiki: Home