LARGE_INITIALIZE#
- invertedai.large.large_initialize(location: str, regions: List[Region], agent_properties: Optional[List[AgentProperties]] = None, agent_states: Optional[List[AgentState]] = None, traffic_light_state_history: Optional[List[Dict[int, TrafficLightState]]] = None, get_infractions: bool = False, random_seed: Optional[int] = None, api_model_version: Optional[str] = None, display_progress_bar: bool = True, return_exact_agents: bool = False) InitializeResponse [source]#
A utility function to initialize an area larger than 100x100m. This function takes in a list of Region objects on each of which
initialize()
is run and each initialize response is combined into a single response which is returned. While looping over all regions, if there are agents in other regions that are near enough to the region of interest, they will be passed as conditional toinitialize()
.initialize()
will not be called if no agents are specified in the region. A boolean flag can be used to control failure behaviour ifinitialize()
is unable to produce viable vehicle placements, specifically whether the initialization should continue initializing other regions or raise an exception.As well, predefined agents may be passed to this function in 2 different ways. If the index of the predefined agents must be preserved, pass these agents’ data into the agent_properties and agent_states parameters. Each agent for which its states is defined MUST have its respective agent properties defined as well but an agent is permitted to be defined by its properties only and
initialize()
will fill in the state information. If the index of the predefined agents does not matter, they may be placed directly into the region objects or passed into the parameters mentioned previously, but make sure to avoid adding these agents more than once.- Parameters:
location – Please refer to the documentation of
initialize()
for information on this parameter.regions – List of regions that contains information about the center, size, agent states and agent properties formatted to align with
initialize()
. Please refer to the documentation forinitialize()
for more details.agent_properties – The properties of the agents that will have their indexes preserved within the response output. Please refer to the documentation of
initialize()
for information on this parameter.agent_states – One timestep worth of agent states that will have their indexes preserved within the response output. Please refer to the documentation of
initialize()
for more information on this parameter.traffic_light_state_history – Please refer to the documentation of
initialize()
for information on this parameter.get_infractions – Please refer to the documentation of
initialize()
for information on this parameter.random_seed – Please refer to the documentation of
initialize()
for information on this parameter.api_model_version – Please refer to the documentation of
initialize()
for information on this parameter.display_progress_bar – If True, a bar is displayed showing the progress of all relevant processes.
return_exact_agents – If set to True, this function will raise an InvertedAIError exception if it cannot fit the requested number of agents in any single region. If set to False, a region that fails to return the number of requested agents will be skipped and only its predefined agents (if any) will be returned with respective RecurrentState’s.
See also
initialize()
- invertedai.large.get_regions_default(location: str, total_num_agents: Optional[int] = None, agent_count_dict: Optional[Dict[AgentType, int]] = None, area_shape: Optional[Tuple[float, float]] = None, map_center: Optional[Tuple[float, float]] = (0.0, 0.0), random_seed: Optional[int] = None, display_progress_bar: Optional[bool] = False) List[Region] [source]#
A utility function to create a set of Regions to be passed into
large_initialize()
in a single convenient entry point.- Parameters:
location – Location name in IAI format.
total_num_agents – Deprecated. The total number of agents to initialize across all regions.
agent_count_dict – The number of agents to place within the regions per specified agent type.
area_shape – Contains the [width, height] to either side of the center of the rectangular area to be broken into smaller regions (i.e. half of full width and height of the region). If this argument is not provided, a bounding box around the location polygon from
location_info()
will be used.map_center – The coordinates of the center of the rectangular area to be broken into smaller regions. If this argument is not provided, default coordinates of (0,0) are used.
random_seed – Controls the stochastic aspects of assigning agents to regions for reproducibility. If this argument is not provided, a random seed is chosen.
display_progress_bar – A flag to control whether a command line progress bar is displayed for convenience.
- invertedai.large.get_regions_in_grid(width: float, height: float, map_center: Optional[Tuple[float, float]] = (0.0, 0.0), stride: Optional[float] = 50.0) List[Region] [source]#
A utility function to help initialize an area larger than 100x100m. This function breaks up an area into a grid of 100x100m regions, each of which can be initialized directly. Each of these regions will only have its shaped specified and no agent information.
- Parameters:
width – Half of the horizontal size of the area which will be broken into smaller regions.
height – Half of the vertical size of the area which will be broken into smaller regions.
map_center – The coordinates of the center of the rectangular area to be broken into smaller regions. If this argument is not provided, default coordinates of (0,0) are used.
stride – How far apart the centers of the 100x100m regions should be. Some overlap is recommended for best results and if no argument is provided, a value of 50 is used.
- invertedai.large.get_number_of_agents_per_region_by_drivable_area(location: str, regions: List[Region], total_num_agents: Optional[int] = None, agent_count_dict: Optional[Dict[AgentType, int]] = None, random_seed: Optional[int] = None, display_progress_bar: Optional[bool] = True) List[Region] [source]#
Takes a list of regions, calculates the driveable area for each of them using output from
location_info()
, then creates a new Region object with copied location and shape data and inserts a number of car agents to be sampled into it proportional to its drivable surface area relative to the other regions. Regions with no or a relatively small amount of drivable surface will be removed.- Parameters:
location – Location name in IAI format.
regions – A list of Regions which may or may not contain pre-existing agents.
total_num_agents – Deprecated. The total number of agents to initialize across all regions.
agent_count_dict – The number of agents to place within the regions per specified agent type.
random_seed – Controls the stochastic aspects of assigning agents to regions for reproducibility. If this argument is not provided, a random seed is chosen.
display_progress_bar – A flag to control whether a command line progress bar is displayed for convenience.