Skip to content

exit

Syntax

exit()

Description

This action causes the current agent to exit. The agent is immediately removed from the population, including from all mixing groups and conditions, and no longer participates in the simulation.

This action cannot be called by the meta or group agents.

Examples

An agent with ID id1 can be selected to exit with the action rule:

if (id() == id1) {
    exit()
}

As a more interesting example, the following code shows how agents might behave in a Hospitalized state where 30% of agents do not recover (and exit) and the remaining agents recover.

state Hospitalized {
    wait(2 * 24)
    next_with_prob(NoRecovery, 0.3)
    default(Recovered)
}

state NoRecovery {
    exit()
    wait()
    default()
}

See Also