starling_sim.basemodel.input.dynamic_input

Module Contents

Classes

DynamicInput

This class manages the agent entering the simulation.

class starling_sim.basemodel.input.dynamic_input.DynamicInput(agent_type_dict)

Bases: starling_sim.basemodel.trace.trace.Traced

This class manages the agent entering the simulation.

It generates base agents at the beginning of the simulation, and dynamically adds agents in the environment during the simulation.

DUPLICATE_AGENT_ID_FORMAT = '{original_id}.{index}'
__str__()

Gives a string display to the dynamic input :return:

setup(simulation_model)

Set the simulation model attribute and generate the base agents.

Parameters:

simulation_model – SimulationModel

feature_schema_validation(feature)
play_dynamic_input_()

Add agents to the simulation over time.

Agents are created based on the dynamic input file, where the generation time is specified as ‘origin_time’.

new_agent_input(feature)

Create and initialise a new agent, and add it to the simulation environment.

Parameters:

feature – agent feature (GeoJSON Feature)

Returns:

created agent or list of agents in case of “duplicates”

add_agent_to_simulation(agent, populations)

Add the agent to the simulation environment.

Add the agent to its population, then trace an input event and start its simpy loop.

Parameters:
  • agent – Agent object

  • populations – population(s) where the agent belongs

feature_list_from_file(filename)

Get the list of input features from the given filename.

The file must be a geojson, following the FeatureCollection schema, and be stored in the input folder.

Parameters:

filename – name of the input file, stored in the input folder

Returns:

list of geojson Feature dicts

make_demand_static()
pre_process_position_coordinates(features)

Add a position to the features with coordinates inputs.

Group the features by modes and call localisations_nearest_nodes environment method, then update the features with the resulting positions.

Parameters:

features – features to pre process

get_position_coordinates_from_feature(feature, position_key)
resolve_type_modes_from_inputs(features)

Resolve the model modes from the inputs.

Browse the inputs and resolve the missing values of the modes dict. Raise an error if there are conflicting values for a same mode.

Parameters:

features – list of input features

Raises:

ValueError – if there are problem during the mode resolve

resolve_mode(obj, key, input_value, replace_types)

Resolve the object mode value with recursive calls.

Resolution is done depending on the nature of the mode value:

  • if the mode value is a topology, return it

  • if the mode value is an agent type, resolve the agent type first mode value

  • if the mode value is None, return the input value

Input values are only used for the first mode value of lists or the mode values of dicts.

Check the final result against the input value if provided.

Parameters:
  • obj – object containing the mode values

  • key – key of the resolved mode value

  • input_value – input value or None

  • replace_types – boolean indicating if agent type value should be replaced with the resolved mode.

Returns:

resolved mode or None if not resolved

pre_process_input_dict(input_dict)

Enhance the given input dict according to the agent type and the needs of the model.

Parameters:

input_dict – input dict to be completed

Returns:

add_key_position_from_stop_point(input_dict, key)
add_key_operator(input_dict)