Search code examples
omnet++veins

Veins error using mt19937


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.


Solution

  • 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 : )!