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

  • 相关阅读:
    java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä'.. 问题解决方法
    Mysql存储引擎federated
    实习心语
    Linux版本CentOS、Ubuntu和Debian的异同
    Ubuntu忘记MySQL密码重设方法
    运行时异常和一般异常
    网络爬虫-正方教务系统登录
    大四心语
    缓存更新的套路
    (String)、toString、String.valueOf的区别
  • 原文地址:https://www.cnblogs.com/CUCmehp/p/1551472.html
Copyright © 2011-2022 走看看