Reference 〉Function

Agent.reproduce( list[str|tuple] inherit = [], dict mutate = {}, list[Agent] partners = [] )

Spawns a new agent, inheriting specified properties from the parent agent. The parent agent is stored in the child’s agent.parent, and the child agent is added to the parent agent’s agent.children list. Properties not specified in either the inherit or mutate arguments will be instantiated according to the agent.__init__() function.

NOTE. This function accounts for parents and children by creating a directed network titled 'lineage'.

Parameters

  • inherit list[str|tuple], optional

    A list of strings or tuples referring to properties that should be copied from the parent agent to the child agent. Any properties not listed in inherit will take their initial value at the instantiation of the primitive object. If a string, the child property will be a mean of the property values of the parents, or the property value of the first parent for non-numeric property values.

    If a tuple, the first element is a string referring to the property value to inherit. The second value is a string referring to a statistic determining how the properties of the parent agents should be inherited, or a function that takes a list of properties and returns a value. Possible statistic values are:

    • 'mean' – averages the values of the parents' properties.
    • 'gmean' – Calculates the geometric mean of the parents' properties.
    • 'sum' – Totals the values of the parents' properties.
    • 'max' – chooses the maximum value of the parents' properties.
    • 'min' – chooses the minimum value of the parents' properties.
    • 'first' – passes the value to the child of the agent on whom the reproduce() function was called.
    • 'last' – Passes the value of the last parent in the parents argument.
    • 'rand' – chooses a random parent whose property value to pass to the child.

    Default value: []

  • mutate dict, optional

    Properties to be mutated, either from the inherited value if specified in inherit, or the initial value otherwise. The keys of the dict indicate properties to be mutated. The values can be either:

    1. a number, in which case the value is drawn from a normal distribution with a mean of the old value and a standard devation of the number,
    2. a tuple, the first item of which is a numeric standard deviation, and the second of which is either 'log' or 'linear' (this allows the mutated value to be drawn from a log-normal distribution), or
    3. a function that takes a value and returns a value, useful for more complex mutations.

    Default value: {}

  • partners list[Agent], optional

    A list of other agents (not including the self) whose attributes should be used in parentage.

    Default value: []

Return Value Agent

The new agent object.

Notes and Examples

  1. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.