zoukankan      html  css  js  c++  java
  • How to make omnetpp.ini variable randomized

    How to make omnetpp.ini variable randomized

    In simple modal file test.ned, I defined a variable as 

    double delay;

    In file omnetpp.ini, I initialized the variable, using

    **.delay = uniform(0,1)

    In cpp file, I read the variable as

    double delay=par("delay");

    Unfortrunicately, the delay I read out are always the same value.

    After read the "help file", I modifies it's defination as:

    volatile double delay;

    And the problem was solved!

    The keyword volatile ask the CPU to read the variable everytime, So, It can get the randomized value among each reading process. That's the same as that works in C++.

  • 相关阅读:
    UIWebView的高度不对问题
    SQL --分组【Group By】
    SQL--Order By
    SQL--空值处理
    SQ--模糊查询
    SQL 聚合函数
    SQL 语句的TOP,Distinct语句
    SQL约束
    1 翻译系列:什么是Code First(EF 6 Code First 系列)
    终极版:由简单工厂模式,升级到抽象工厂模式(用到反射)
  • 原文地址:https://www.cnblogs.com/CUCmehp/p/1551472.html
Copyright © 2011-2022 走看看