:py:mod:`starling_sim.basemodel.input.dynamic_input` ==================================================== .. py:module:: starling_sim.basemodel.input.dynamic_input Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: starling_sim.basemodel.input.dynamic_input.DynamicInput .. py:class:: DynamicInput(agent_type_dict) Bases: :py:obj:`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. .. py:attribute:: DUPLICATE_AGENT_ID_FORMAT :value: '{original_id}.{index}' .. py:method:: __str__() Gives a string display to the dynamic input :return: .. py:method:: setup(simulation_model) Set the simulation model attribute and generate the base agents. :param simulation_model: SimulationModel .. py:method:: feature_schema_validation(feature) .. py:method:: 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'. .. py:method:: new_agent_input(feature) Create and initialise a new agent, and add it to the simulation environment. :param feature: agent feature (GeoJSON Feature) :return: created agent or list of agents in case of "duplicates" .. py:method:: 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. :param agent: Agent object :param populations: population(s) where the agent belongs .. py:method:: 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. :param filename: name of the input file, stored in the input folder :return: list of geojson Feature dicts .. py:method:: make_demand_static() .. py:method:: 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. :param features: features to pre process .. py:method:: get_position_coordinates_from_feature(feature, position_key) .. py:method:: 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. :param features: list of input features :raises ValueError: if there are problem during the mode resolve .. py:method:: 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. :param obj: object containing the mode values :param key: key of the resolved mode value :param input_value: input value or None :param replace_types: boolean indicating if agent type value should be replaced with the resolved mode. :return: resolved mode or None if not resolved .. py:method:: pre_process_input_dict(input_dict) Enhance the given input dict according to the agent type and the needs of the model. :param input_dict: input dict to be completed :return: .. py:method:: add_key_position_from_stop_point(input_dict, key) .. py:method:: add_key_operator(input_dict)