Skip to content

current_place

Syntax

current_place()

Returns

The place ID of the agent.

Description

Returns the place ID of the calling agent at the current time step.

Examples

The following prints the place IDs of the first agent encountered with an age of 10 or an age evenly divisible by 30 every hour.

simulation {
    start_date = 2020-Jan-01
    end_date = 2020-Jan-06
    locations = Jefferson_County_PA
}

condition DEMO {
    start_state = Start

    variables {
        shared numeric place_id
        shared list age_used
        shared numeric first
    }

    state Start {
        age_used[200] = 1
        # select the first agent of each age
        if (age_used[age()] == 0) then {
            first = 1
            age_used[age()] = 1
        }
        else {
            first = 0
        }
        wait(0)
        if (first == 1 & age() == 10) then next(Report)
        if (first == 1 & age() % 30 == 0) then next(Report)
        default(Excluded)
    }

    state Report {
        place_id = current_place()
        if (place_id > 0) then print_event(" age = ", age(), " place = ", place_id, " size = ", size(place_id))
        wait(1)
        next(Report)
    }

}

See Also