0

I'm trying to use mt19937 to generate (good) random numbers on Veins to my node/vehicle class. When I use one mt19937 for each car, he woks, but when I set to be static (one mt19937 to all car) he doesn't work

static mt19937 mt;

Occurs one error when mt is used:

uniform_int_distribution <int> unif_dist(1, 100);
...
return unif_dist(mt);

Error:

Error in module (cModule) vehDist_rsu (id=48) during network setup: Class "Veins::ObstacleControl" not found -- perhaps its code was not linked in, or the class wasn't registered with Register_Class(), or in the case of modules and channels, with Define_Module()/Define_Channel().

Error during network cleanup: Model error: ASSERT: condition vect[i]==NULL false in function deleteNetwork, csimulation.cc line 437.

I tried solve with 1 and 2, but didn't work.

ADH - THE TECHIE GUY
  • 4,125
  • 3
  • 31
  • 54
  • This doesn't answer your question, but you will probably want to use the PRNGs managed by OMNeT++ instead of your own. This becomes especially useful when you start more than one replication of your experiment – Christoph Sommer Apr 29 '16 at 10:54
  • Hello Christoph, thank's for your comment. I'm using the OMNeT++ PRNGs (`seed-set = ${repetition}`), but I need of more random numbers (another sources), so I create one mt19937 to be used on the first car (car[0]) and one srand to be used for all cars. It is not the best option, but it woks. I use the mt19937 to select which car will generate the message(s) (data) and the srand to select for the which car (based on some variables) will send each message. – João Batista Apr 30 '16 at 14:38
  • OMNeT++ can set up and manage multiple independently seeded RNGs (of various types, the mersenne twister being among them). The user manual documents the intricacies of how to set up and manage them nicely: https://omnetpp.org/doc/omnetpp/manual/#sec:sim-lib:global-and-component-local-rngs – Christoph Sommer May 02 '16 at 11:58
  • Hello Christoph, thank's again. There is a way to get/use, for example, a random number from RNG index 1 in OMNet 4.6? I am using this version and don't have a lot of function cited in this manual. I want use RNG index 0 to one part and the RNG index 1 to another. Or is best to upgrade to OMNeT 5? https://omnetpp.org/doc/omnetpp/api/APIChanges.html – João Batista May 07 '16 at 14:36
  • Yes, this is perfectly possible. It is strange that you are missing things documented in the manual. There might be something wrong with your installation – Christoph Sommer May 09 '16 at 07:07

1 Answers1

0

I update my Veins to Veins 4.4, set mt19937 as static in BaseWaveApplLayer.h:

static mt19937 mt;

Define him in my vehicle class:

mt19937 BaseWaveApplLayer::mt_veh;

And use him in the class BaseWaveApplLayer:

uniform_int_distribution <int> dist(0, 100);
int valueSelected = dist(mt_veh);

Thank for all help : )!