无法在 omnetpp 中生成随机数

cant generate random number in omnetpp

我在我的 NED 文件中以这种方式定义了主机流量发送间隔,我希望在每次执行时收到不同的数字:

    volatile double sendInterval @unit("s") = default(exponential(1s));

但是每次执行都得到相同的结果,问题出在哪里?

这里没有任何问题。这是一个特点。 OMNeT++ 中的任何 random 数实际上是一个 pseudo-random 数。 而且它们确实需要确定性,所以每个实验都可以准确重现

参见手册部分:https://omnetpp.org/doc/omnetpp/manual/#sec:sim-lib:random-number-generators

上面写着:

Starting from the same seed, RNGs always produce the same sequence of random numbers. This is a useful property and of great importance, because it makes simulation runs repeatable.

要获得不同的值,请尝试在 .ini 文件中为您的配置设置不同的 seed-set,或者通过调整 repeat 选项来 运行 多次重复 - 每个重复会自动为 PRNG 设置不同的种子。

另见:https://omnetpp.org/doc/omnetpp/manual/#sec:config-sim:repeating-runs-with-different-seeds