invertedai.api.initialize(location: str, agent_attributes: Optional[List[AgentAttributes]] = None, states_history: Optional[List[List[AgentState]]] = None, traffic_light_state_history: Optional[List[Dict[int, TrafficLightState]]] = None, get_birdview: bool = False, get_infractions: bool = False, agent_count: Optional[int] = None, random_seed: Optional[int] = None) InitializeResponse[source]#

Initializes a simulation in a given location. Either agent_count or both agent_attributes and states_history need to be provided. In the latter case, the simulation is initialized with the specific history, and if traffic lights are present then traffic_light_state_history should also be provided. If only agent_count is specified, a new initial state is generated with the requested total number of agents. Every simulation needs to start with a call to this function in order to obtain correct recurrent states for drive().

  • location – Location name in IAI format.

  • agent_attributes – Static attributes for all agents.

  • states_history – History of agent states - the outer list is over agents and the inner over time, in chronological order. For best results, provide at least 10 historical states for each agent.

  • traffic_light_state_history – History of traffic light states - the list is over time, in chronological order. Traffic light states should be provided for all time steps where agent states are specified.

  • agent_count – If states_history is not specified, this needs to be provided and dictates how many agents will be spawned.

  • random_seed – Controls the stochastic aspects of initialization for reproducibility.

class invertedai.api.InitializeResponse(*, recurrent_states: List[RecurrentState], agent_states: List[AgentState], agent_attributes: List[AgentAttributes], birdview: Optional[Image] = None, infractions: Optional[List[InfractionIndicators]] = None)[source]#

Response returned from an API call to iai.initialize().

agent_attributes: List[AgentAttributes]#

Static attributes of all initialized agents.

agent_states: List[AgentState]#

Initial states of all initialized agents.

birdview: Optional[Image]#

If get_birdview was set, this contains the resulting image.

infractions: Optional[List[InfractionIndicators]]#

If get_infractions was set, they are returned here.

recurrent_states: List[RecurrentState]#

To pass to at the first time step.