From: Tino M. <mo...@tc...> - 2007-10-23 11:09:35
|
Hi Valdemaras, > > Hi everyone, > > > > What interests me is how online simulations can be run on sumo. With > > online I mean that there are data about traffic coming almost > > real-time. Let's say every 10 seconds we get new sensors data, sensors > > cover entrances and exits from the small city. How an ongoing > > simulation can be adapted to conform to new data? > > Is there any way to feed data to an already ongoing simulation? Or > > there are other ways for running online simulation? What ideas and > > experience do you have regarding this problem? > > > Online simulations were actually a part of my MSc thesis. As it is not yet accepted / approved I cannot publish it at the moment but the examination board should be finished by the end of October. Once the thesis is approved it will be published on the college's website, I'll keep you posted. In general my approach to it was the following: I got vehicle counts from induction loops and wanted to feed them into SUMO. (What kind of data do you have?) Apart from the problem of getting information into SUMO, timing is vital for online simulation. Because I didn't want to change SUMO too much I decided to implement the timing component externally and trigger a timestep every second using the itm remote server component of SUMO (there is more information on this in the mailing list archive). While sending the trigger to simulate a new timestep I also transmitted the new vehicle count data to SUMO. I then wrote a trigger similar to the emitter which either emits or removes vehicles. Now for the bad news: the code is a) only a proof of concept, i.e. not coded or tested very well, and b) not yet committed to the SUMO project. I took an extended break after I handed in the thesis, but I hope to get going again next week and to clean up and commit my code. > > > > Another question: > > I'm trying to delete a vehicle in an ongoing simulation on a certain > > time step. Code more or less looks like that. > > > > if (net->getCurrentTimeStep() == 6) { > > > > MSVehicle* veh; > > for (map<string, MSVehicle*>::const_iterator iter = > > vehControl->loadedVehBegin(); iter != vehControl->loadedVehEnd(); > > ++iter) { > > veh = (*iter).second; > > } > > > > MSNet::getInstance()->getVehicleControl().scheduleVehicleRemoval(veh); > > } > > > > > > This code is invoked just before invoking simulationStep(start, > > myStep); and in this simulationStep segmentation fault occurs and sumo > > crashes. > > Is the way I am deleting the vehicle is correct, what could be the problem? > > > > > Here is the code I use to remove vehicles, I am not sure if all this is necessary but at least it worked for me: veh->leaveLaneAtLaneChange(); veh->onTripEnd(); MSNet::getInstance()->getMSPhoneNet()->removeVehicle(*veh, MSNet::getInstance()->getCurrentTimeStep()); myDestLane->removeVehicle(veh); MSNet::getInstance()->getVehicleControl().scheduleVehicleRemoval(veh); myDestLane is an instance of MSLane, the removeVehicle() method is one I have implemented (based on the removeFirstVehicle() method): MSVehicle * MSLane::removeVehicle(MSVehicle * remVeh) { for(MSLane::VehCont::iterator it = myVehicles.begin(); it < myVehicles.end(); it++) { if(remVeh->getID() == (*it)->getID()){ remVeh->leaveLaneAtLaneChange(); myVehicles.erase(it); myUseDefinition->noVehicles--; myUseDefinition->vehLenSum -= remVeh->getLength(); break; } } return remVeh; } Again, I am certain there are more elegant ways of implementing this, but at least this bit of code did remove the vehicles and this was all I needed. Hope that helped a bit, I'll keep you updated when I manage to check in my code / my thesis gets published. Regards, Tino > > Thanks!! > > Valdemaras Repšys > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > sumo-user mailing list > > sum...@li... > > https://lists.sourceforge.net/lists/listinfo/sumo-user > > > |