ensemble.handler.vissim package

Submodules

ensemble.handler.vissim.configurator module

This module contains a Configurator object for Vissim. The configurator is an object that stores parameters that can be relevant to make the evolution of a simulation.

class ensemble.handler.vissim.configurator.VissimConfigurator(**kwargs)[source]

Bases: ensemble.tools.connector_configurator.ConnectorConfigurator

Configurator class for containing specific simulator parameters for Vissim

Example

To use the Simulator declare in a string the path to the simulator

>>> path = "path/to/simluator.so"
>>> simulator = VissimConfigurator(library_path = path)
Parameters

library_path (str) – Absolute path towards the simulator library

Returns

Configurator object with simulation parameters

Return type

configurator (Configurator)

library_path: str = 'libSymuFlow.so'

ensemble.handler.vissim.connector module

This module contains objects for modeling a simplified connector to handle vissim

class ensemble.handler.vissim.connector.VissimConnector(**kwargs)[source]

Bases: ensemble.metaclass.connector.AbsConnector, ensemble.handler.vissim.configurator.VissimConfigurator

This models a connector and interactions from the API with the Vissim library.

Raises

EnsembleAPILoadLibraryError – Raises error when library cannot be loaded

property do_next: bool

Returns true if the simulation shold continue

get_simulation_steps() range[source]

Gets the list of simulation steps starting from 0 to end of simulation in step of simulation resolution

property get_vehicle_data

Returns the query received from the simulator

Returns

Request from the simulator

Return type

dict

load_scenario(scenario)[source]

checks existance and load scenario . Also get simulation parameters

load_simulator() None[source]

load Vissim COM interface

performConnect() None[source]

Perform simulation connection

performInitialize(scenario: ensemble.handler.vissim.scenario.VissimScenario) None[source]

Perform simulation initialization

performPreRoutine() None[source]

Perform simulator preroutine

performQuery() None[source]

Perform simulator Query

push_data()[source]

Pushes data back to the simulator

query_data() int[source]

Run simulation step by step

Returns

iteration step

Return type

int To test query, you can use click.echo(self.get_vehicle_data()) after request_answer()

register_simulation(scenarioPath: str) None[source]

Register simulation file within the simulator

Parameters

scenarioPath (str) – Path to scenario

request_answer()[source]

Request simulator answer and maps the data locally

run_single_step()[source]

Run simulation next step

Returns

None

Return type

None

property scenariofilename

Scenario filenamme

Returns

Absolute path towards the XML input for SymuVia

Return type

filname (str)

property simulation_step

Current simulation iteration

property simulationstep: float

Current simulation step

ensemble.handler.vissim.scenario module

Scenario Module

This module contains descriptions that establish a traffic scenario. A traffic scenario for Vissim is regularly described by a an network files(.inpx) and a layoutfile(.layx).

class ensemble.handler.vissim.scenario.VissimScenario(*args)[source]

Bases: ensemble.input.scenario.Scenario

Scenario class for Vissim

classmethod create_input(*args)[source]

Looks for indicated vissim scenario paths and performs validation create the scenario

property filename

Vissim property shortcut

property filename_layx

Vissim property shortcut

ensemble.handler.vissim.stream module

Vissim Stream

This module is able to receive the stream of data comming from the Vissim platform and define a parser for a specific vehicle data suitable to perform platooning activities.

class ensemble.handler.vissim.stream.SimulatorRequest(**kwargs)[source]

Bases: ensemble.metaclass.stream.DataQuery

create_vehicle_registry()[source]

Creates a vehicle registry for all vehicles in simulation

property current_nbveh: int

Number of vehicles in the network

property current_time: float

Current simulation second

get_vehicle_data() list[source]

Extracts vehicles information from simulators response

Parameters

response (list) – List of list with parameters

Returns

List of dictionaries

Return type

listdict (list)

is_vehicle_driven(vehid: int) bool[source]

Returns true if the vehicle state is exposed to a driven state

Parameters

vehid (str) – vehicle id

Returns

True if veh is driven

Return type

driven (bool)

property query

String response from the simulator

static transform(veh_data: dict)[source]

Transform vehicle data from string format to coherent format

Parameters

veh_data (dict) – vehicle data as received from simulator

Returns

vehicle data with correct formatting

Return type

t_veh_data (dict)

Example

As an example, for an input of the following style:

>>> v = {"CoordFrontX":421.31564190349957

“Acceleration”:-0.0 “Pos”:16.25355208592856 “No”:1, “CoordFrontY”:-979.2497097242955 “LaneLinkNo”:6, “VehType”:’630’, “Speed”:83.93049031871615, “LaneIndex”:1,

}

>>> tv = SimulatorRequest.transform(v)
>>> # Transforms into
>>> tv == {
>>>     "abscissa": 421.31564190349957,
>>>     "acceleration": -0.0,
>>>     "distance": 16.25355208592856,
>>>     "driven": False,
>>>     "elevation": 0.0,
>>>     "lane": 1,
>>>     "link": "6",
>>>     "ordinate": -979.2497097242955,
>>>     "speed": 23.314025088532265,
>>>     "vehid": 0,
>>>     "vehtype": "630",
>>> },
update_vehicle_registry()[source]

Updates vehicle registry in case it exists

Module contents