Veins & manager.numVehicles

474 views
Skip to first unread message

Andreas Prs

unread,
May 10, 2017, 9:50:14 AM5/10/17
to OMNeT++ Users
I want to keep a constant number of cars in my (long) simulation  (OMNeT+Veins). I do not care about mobility that much so i could probably use the Veins in-built function *.manager.numVehicles = 100. The thing is that if i do not specify any(enough) vehicle flows (from SUMO) my simulation terminates instantly (because of no events). So i create some flows (that exit the simulation sooner) and Veins fills up for the cars as they dissappear. 

Is there a more elegant way to do this? I'd prefer to just use the numVehicles function since it's easier and the cars move minimally so they remain in the simulation for long.
I need steady-state vehicular density. 

Thanks,
Andreas

David Eckhoff

unread,
May 11, 2017, 11:49:07 PM5/11/17
to omn...@googlegroups.com, andreas...@gmail.com
Hi,

the proper way to do it is not to create any cars using SUMO but just
create routes/flows. Veins will create vehicles as soon as the
simulation starts if you use the numVehicles feature. I cannot really
reproduce your problem, maybe I didn't fully get it, but to avoid
simulation ending because of no more vehicles, just set
manager.autoShutdown to false.

- david

On 10/5/2017 9:50 PM, Andreas Prs wrote:
> I want to keep a constant number of cars in my (long) simulation
> (OMNeT+Veins). I do not care about mobility that much so i could
> probably use the Veins in-built function **.manager.numVehicles = 100.
> *The thing is that if i do not specify any(enough) vehicle flows (from
> SUMO) my simulation terminates instantly (because of no events). So i
> create some flows (that exit the simulation sooner) and Veins fills up
> for the cars as they dissappear.
> *
> *
> Is there a more elegant way to do this? I'd prefer to just use the
> numVehicles function since it's easier and the cars move minimally so
> they remain in the simulation for long.
> I need steady-state vehicular density.
>
> Thanks,
> Andreas
>
> --
> You received this message because you are subscribed to the Google
> Groups "OMNeT++ Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to omnetpp+u...@googlegroups.com
> <mailto:omnetpp+u...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/omnetpp.
> For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted

pgar...@goumh.umh.es

unread,
May 12, 2017, 9:12:27 AM5/12/17
to OMNeT++ Users
Hi,

The problem with the -max-num-vehicles parameter is that you need to be sure that you write enough number of routes in the routes file for all the simulation time. Furthermore, this also depends on the length of the routes, which is a problem if the routes are generated randomly.

Another solution, that can be used alone or as a complement of the previous solution is to restart each vehicle that finish its route, with the same parameters: name, type and route. When a vehicle finish its route, the finish() method is invoked, and then, you can create the vehicle with TraCI. If you use Veins, it would be something like the following code.

Regards

class XXX : public BaseWaveApplLayer {
...
private:
   cModule *host;
   Veins::TraCICommandInterface* traciCmd;
   Veins::TraCICommandInterface::Vehicle* traciCmdVehicle;
   std::string typeID;
   std::string routeID;
};

void initialize() {
...
host = findHost();
traci = TraCIMobilityAccess().get(getParentModule());
traciCmd = traci->getCommandInterface();
traciCmdVehicle = traci->getVehicleCommandInterface();
typeID = traciCmdVehicle->getTypeId(); // Vehicle type ID
routeID = traciCmdVehicle->getRouteId(); // Route ID
}

void XXX::finish() {
BaseWaveApplLayer::finish();
...
if (traciCmd!=NULL) {
   bool ok = traciCmd->addVehicle(host->getName(), typeID, routeID);
}
}

Andreas Prs

unread,
May 14, 2017, 1:39:03 PM5/14/17
to omn...@googlegroups.com
Thanks a lot!

So to get this straight, for 100 vehicles I would need 100 distinct routes? my area is 500x500m. Also, the way I setup my rou.xml file, cars are created even without using numVehicles!
 
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
    <vehicle id="0" depart="0.00">
        <route edges="0/2to0/1 0/1to1/1 1/1to1/0 1/0to2/0"/>
    </vehicle>
    <vehicle id="1" depart="1.00">
        <route edges="4/0to3/0 3/0to2/0 2/0to2/1 2/1to2/2 2/2to2/3 2/3to2/4 2/4to1/4"/>
    </vehicle>

etc..

pgar...@goumh.umh.es

unread,
May 14, 2017, 2:48:11 PM5/14/17
to OMNeT++ Users
Hi Andreas,

Yes, with this technique is not necessary to use the numVehicles parameter. Perhaps the problem could be to record statistics, as the "cloned" vehicles are other vehicles.

As I can see from your routes file, you use a grid network. If you need to create 100 distinct routes, you can use this tool: GatcomSUMO.
It can be downloaded from:

Best regards
Pablo

Andreas Prs

unread,
May 14, 2017, 4:08:55 PM5/14/17
to OMNeT++ Users
This tool is great! Ideally I would like to set the number of vehicles ONLY from num.Vehicles because I think it is easier. I also believe I do not fully understand the difference of flows, routes and trips. So I do not mind about which cars enter/exit as long as their number remains constant for a simulation run in the Grid map.

is there a way I could make this using your app? a simple grid map, in which different (pre-set) number of vehicles (25,50,75,100,+) could go around and exchange packets. the number of vehicles preferable could be set with num.Vehicles.

Thanks a lot.
Andreas

Pablo Garrido

unread,
May 15, 2017, 4:26:07 AM5/15/17
to OMNeT++ Users
Hi,

With GatcomSUMO you can generate the grid network (obstacles if you need them too) from the "Network" tab, and 400 routes (for example) from the "Traffic Demand > Trips" tab. You can also create 400 vehicles (or flows), one for each one of the creates routes. From the "Traffic Demand > Routes" tab you can create some route by hand, one-by-one.
By using the tools included in SUMO it is possible to do this too (netgenerate, randomTrips.py, ...), but if the routes are going to be used from OMNeT++ it is easier with GatcomSUMO; you can avoid some runtime errors.

Flow = A number of vehicles following the same route.
Route = A list of edges that a vehicle or flow can follow.
Trip = Allows to generate routes by specifying only the source and destination, and the shortest path will be found (duarouter).

Then, with the numVehicles parameter you can set the maximum of vehicles, and repeat the simulations by setting its value from the omnetpp.ini configuration file:

*.manager.numVehicles = ${nv=25,50,75,100,200,400}

When a vehicle finish its route, the next vehicle will be taken from the routes file. If you try to create another one to "clone" a vehicle, I think that this will be ignored, because the desired number of vehicles have been reached (I'm not sure). When all the routes in the routes file have been used, then the "clone" mechanism should work.

Regards

Reply all
Reply to author
Forward
Message has been deleted
0 new messages