Hello, As I wrote before it is already possible to run multiple simulations from the same script. I updated the documentation to make this more obvious in the future: http://sumo.dlr.de/wiki/TraCI/Interfacing_TraCI_from_Python#Controlling_parallel_simulations_from_the_same_TraCI_script regards, Jakob
2016-01-05 2:16 GMT+01:00 Matěj Kubička < [email protected]>: > Hi Jakob (et al.), > I needed the same - to run multiple sumo instances in parallel. > Unfortunately Python bindings for Traci do not support that since the traci > package is written as a state machine. > > I've worked on it a bit and adapted the traci to support multiple > coexistent connections. The changes are extensive, but trivial. I have > wrapped the IO-related stuff in a class TraciAdapter, whose constructor is > now derived from what originally was traci.init(). Then I wrapped > functionality of vehicle and route modules in classes Vehicle and Route and > I instantiate them in TraciAdapter's constructor. > > Except that now you have to access traci objects through instances of > TraciAdapter, the interface remains the same otherwise. > > My experiments are limited to adding a vehicle and to collecting data > about it. I worked only on concerned parts of the package. I am sending you > the code as mere proof of concept, in case you are interested in such a > functionality. > > Matej. > > PS: I tried to send you full package, but our mailserver blacklists zipped > attachements, so I am sending you the three afffected files only. > > PS2: simplified example that controls 2 sumo instances, adds a vehicle to > each and dumps their speeds as they progress in time > > import traci > > tad=traci.TraciAdapter(port) > tad.route.add('probe_route', edges) > tad.vehicle.add('probe', 'probe_route') > > tad1=traci.TraciAdapter(port+1) > tad1.route.add('probe_route', edges) > tad1.vehicle.add('probe', 'probe_route') > > while(True): > tad.simulationStep() > tad1.simulationStep() > print tad.vehicle.getSpeed('probe'), tad1.vehicle.getSpeed('probe') > > > > > > > On 17.12.2015 15:54, Jakob Erdmann wrote: > >> Yes. You can run multiple instances of sumo at the same time. It is even >> possible to control multiple instances from the same TraCI script as longs >> as you are careful with the port numbers. >> regards, >> Jakob >> >> 2015-12-17 14:39 GMT+01:00 Phuong Nguyen <[email protected]>: >> >> Hi, >>> >>> I'm trying to optimize a traffic scenario using optimization algorithm >>> and >>> sumo. In the optimization process, I need to call sumo to run the >>> scenario >>> simulation so many time. Can a number of the simulations run parallel? >>> >>> Thanks so much. >>> -- >>> Ms. Nguyen Thi Mai Phuong >>> Division of Science Management and International Relations, >>> Department of Network and Communications, >>> Thai Nguyen University of Information and Communication Technology, >>> Thai Nguyen city, Thai Nguyen province, Vietnam. >>> Email:[email protected] >>> Tel: 0985 18 38 48 >>> >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> sumo-user mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/sumo-user >>> >>> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> sumo-user mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/sumo-user >> > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > sumo-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/sumo-user > > ------------------------------------------------------------------------------ _______________________________________________ sumo-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sumo-user
