# Configuration file description¶

The configuration file is in the format described in the Python configparser documentation as “a basic configuration file parser language which provides a structure similar to what you would find on Microsoft Windows INI files.”

Most settings must be explicitly enumerated in the configuration file. (This makes it less likely that library code changes will result in your project silently using different NEAT settings. There are some defaults, as noted below, and insofar as possible new configuration parameters will default to the existing behavior.)

Note

TODO: Work on ways to make the existing defaults more integrated with the configuration code. This may involve a third, optional (defaulting to None) parameter for ConfigParameter, giving a default. Such a mechanism will be needed to convert the configuration in DefaultReproduction and DefaultStagnation to match that in other classes/modules. It would also be needed to add, for instance, an alternative uniform-distribution initialization for various parameters such as weight and bias, without requiring all configuration files to be changed to specify the gaussian distribution currently in use. Another example would be for a configuration file variable for whether more than one addition/connection mutation can take place at a time, as mentioned in genome.py.

The above is done in the config_work branch.

Note that the Config constructor also requires you to explicitly specify the types that will be used for the NEAT simulation. This, again, is to help avoid silent changes in behavior.

The configuration file is in several sections, of which at least one is required. However, there are no requirements for ordering within these sections, or for ordering of the sections themselves.

## [NEAT] section¶

The NEAT section specifies parameters particular to the generic NEAT algorithm or the experiment itself. This section is always required, and is handled by the Config class itself.

• fitness_criterion
The function used to compute the termination criterion from the set of genome fitnesses. Allowable values are: min, max, and mean
• fitness_threshold
When the fitness computed by fitness_criterion meets or exceeds this threshold, the evolution process will terminate, with a call to any registered reporting class’ found_solution method.

Note

The found_solution method is not called if the maximum number of generations is reached without the above threshold being passed. TODO: Add a new configuration parameter to ignore the above, provided a maximum number of generations is passed to population.Population.run(), and if so call found_solution upon termination by a maximum number of generations. (This is mostly done in the config_work branch.)

• pop_size
The number of individuals in each generation.
• reset_on_extinction
If this evaluates to True, when all species simultaneously become extinct due to stagnation, a new random population will be created. If False, a CompleteExtinctionException will be thrown.

## [DefaultStagnation] section¶

The DefaultStagnation section specifies parameters for the builtin DefaultStagnation class. This section is only necessary if you specify this class as the stagnation implementation when creating the Config instance; otherwise you need to include whatever configuration (if any) is required for your particular implementation.

• species_fitness_func
The function used to compute species fitness. This defaults to mean. Allowed values are: max, min, mean, and median

Note

This is not used for calculating species fitness for apportioning reproduction (which always uses mean).

• max_stagnation
Species that have not shown improvement in more than this number of generations will be considered stagnant and removed. This defaults to 15.
• species_elitism
The number of species that will be protected from stagnation; mainly intended to prevent total extinctions caused by all species becoming stagnant before new species arise. For example, a species_elitism setting of 3 will prevent the 3 species with the highest species fitness from being removed for stagnation regardless of the amount of time they have not shown improvement. This defaults to 0.

Note

TODO: DefaultStagnation.write_config uses a default of 15 for species_elitism, but the default by DefaultStagnation.parse_config is 0, which will override.

The above is handled in the config_work branch.

## [DefaultReproduction] section¶

The DefaultReproduction section specifies parameters for the builtin DefaultReproduction class. This section is only necessary if you specify this class as the reproduction implementation when creating the Config instance; otherwise you need to include whatever configuration (if any) is required for your particular implementation.

• elitism
The number of most-fit individuals in each species that will be preserved as-is from one generation to the next. This defaults to 0.
• survival_threshold
The fraction for each species allowed to reproduce each generation. This defaults to 0.2.

Note

TODO: There is also a min_species_size configuration parameter, defaulting to 2, although it is not written out by DefaultReproduction.write_config.

The above is handled in the config_work branch, although documentation is needed.

## [DefaultGenome] section¶

The DefaultGenome section specifies parameters for the builtin DefaultGenome class. This section is only necessary if you specify this class as the genome implementation when creating the Config instance; otherwise you need to include whatever configuration (if any) is required for your particular implementation.

• bias_init_mean
The mean of the normal/gaussian distribution used to select bias attribute values for new nodes.
• bias_init_stdev
The standard deviation of the normal/gaussian distribution used to select bias values for new nodes.
• bias_max_value
The maximum allowed bias value. Biases above this value will be clamped to this value.
• bias_min_value
The minimum allowed bias value. Biases below this value will be clamped to this value.
• bias_mutate_power
The standard deviation of the zero-centered normal/gaussian distribution from which a bias value mutation is drawn.
• bias_mutate_rate
The probability that mutation will change the bias of a node by adding a random value.
• bias_replace_rate
The probability that mutation will replace the bias of a node with a newly chosen random value (as if it were a new node).
• compatibility_threshold
Individuals whose genomic distance is less than this threshold are considered to be in the same species.

Note

It is currently possible for two homologous nodes or connections to have a higher contribution to the genomic distance than a disjoint or excess node or connection, depending on their attributes and the settings of the above parameters.

The probability that mutation will add a connection between existing nodes. Valid values are in [0.0, 1.0].
• conn_delete_prob
The probability that mutation will delete an existing connection. Valid values are in [0.0, 1.0].
• enabled_default
The default enabled attribute of newly created connections. Valid values are True and False.

Note

“Newly created connections” include ones in newly-created genomes, if those have initial connections (from the setting of the initial_connection variable).

• enabled_mutate_rate
The probability that mutation will replace (50/50 chance of True or False) the enabled status of a connection. Valid values are in [0.0, 1.0].
• feed_forward
If this evaluates to True, generated networks will not be allowed to have recurrent connections (they will be feedforward). Otherwise they may be (but are not forced to be) recurrent.
• initial_connection
Specifies the initial connectivity of newly-created genomes. (Note the effects on settings other than unconnected of the enabled_default parameter.) There are seven allowed values:
• unconnected - No connections are initially present. This is the default.
• fs_neat_nohidden - One randomly-chosen input node has one connection to each output node. (This is one version of the FS-NEAT scheme.)
• fs_neat_hidden - One randomly-chosen input node has one connection to each hidden and output node. (This is another version of the FS-NEAT scheme. If there are no hidden nodes, it is the same as fs_neat_nohidden.)
• full_nodirect - Each input node is connected to all hidden nodes, if there are any, and each hidden node is connected to all output nodes; otherwise, each input node is connected to all output nodes. Genomes with feed_forward set to False will also have recurrent (loopback, in this case) connections from each hidden or output node to itself.
• full_direct - Each input node is connected to all hidden and output nodes, and each hidden node is connected to all output nodes. Genomes with feed_forward set to False will also have recurrent (loopback, in this case) connections from each hidden or output node to itself.
• partial_nodirect # - As for full_nodirect, but each connection has a probability of being present determined by the number (valid values are in [0.0, 1.0]).
• partial_direct # - as for full_direct, but each connection has a probability of being present determined by the number (valid values are in [0.0, 1.0]).

Changed in version 0.91-github: fs_neat split into fs_neat_nohidden and fs_neat_hidden; full, partial split into full_nodirect, full_direct, partial_nodirect, partial_direct

The probability that mutation will add a new node (essentially replacing an existing connection, the enabled status of which will be set to False). Valid values are in [0.0, 1.0].
• node_delete_prob
The probability that mutation will delete an existing node (and all connections to it). Valid values are in [0.0, 1.0].
• num_hidden
The number of hidden nodes to add to each genome in the initial population.
• num_inputs
The number of input nodes, through which the network receives inputs.
• num_outputs
The number of output nodes, to which the network delivers outputs.
• response_init_mean
The mean of the normal/gaussian distribution used to select response multiplier attribute values for new nodes.
• response_init_stdev
The standard deviation of the normal/gaussian distribution used to select response multipliers for new nodes.
• response_max_value
The maximum allowed response multiplier. Response multipliers above this value will be clamped to this value.
• response_min_value
The minimum allowed response multiplier. Response multipliers below this value will be clamped to this value.
• response_mutate_power
The standard deviation of the zero-centered normal/gaussian distribution from which a response multiplier mutation is drawn.
• response_mutate_rate
The probability that mutation will change the response multiplier of a node by adding a random value.
• response_replace_rate
The probability that mutation will replace the response multiplier of a node with a newly chosen random value (as if it were a new node).
• weight_init_mean
The mean of the normal/gaussian distribution used to select weight attribute values for new connections.
• weight_init_stdev
The standard deviation of the normal/gaussian distribution used to select weight values for new connections.
• weight_max_value
The maximum allowed weight value. Weights above this value will be clamped to this value.
• weight_min_value
The minimum allowed weight value. Weights below this value will be clamped to this value.
• weight_mutate_power
The standard deviation of the zero-centered normal/gaussian distribution from which a weight value mutation is drawn.
• weight_mutate_rate
The probability that mutation will change the weight of a connection by adding a random value.
• weight_replace_rate
The probability that mutation will replace the weight of a connection with a newly chosen random value (as if it were a new connection).