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++.

  • 相关阅读:
    6-2 对象克隆
    5-2 equal getClass or instanceOf
    6-2 回调
    6-1 接口的默认方法
    认识ExtJS(05)--
    认识ExtJS(04)--常见Web框架的ExtJS改造
    MyEclipse快捷键全
    ExtJS4.1自带API打不开的问题解决
    浅析十三种常用的数据挖掘的技术&五个免费开源的数据挖掘软件
    C++ 多态
  • 原文地址:https://www.cnblogs.com/CUCmehp/p/1551472.html
Copyright © 2011-2022 走看看