set_age()

Action to set the agent’s age in years.

Synopsis

set_age(agent-id, age-exprression)

Description

Set the agent’s age in years to the integer part of the expression’s value.

The agent is assigned a randomly selected birth date within the year.

Parameters

  • agent-id :

    An expression that must evaluate to a valid ordinary agent.

  • age-expression :

    An expression that must evaluates to a numberic value. to a valid ordinary agent.

Error

An error occurs of the first argument does not evaluate to a valid agent ID.

Examples

In the following, the new agent is assigned a birthdate between 40 and 41 years prior to the current simulation date.

new_agent_id = new_agent()
    set_age(new_agent_id, 40)

In the following, the new agent is ageless, meaning that its age will always be reported as -1.

new_agent_id = new_agent()
    set_age(new_agent_id, -1)

See Also

new_agent()