How to declare a matrix in .ned file

ⅰ亾dé卋堺 提交于 2021-02-11 14:41:10

问题


In OmNet++ 5.5.1, I want to initialize a matrix in .ned file.

In each run, some element values of the matrix will be updated and the updated matrix needs to be used in the following run. For example:

in .ned file,

matrix table={ {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }; 

in mac.cc file,

table[m][n] = table[m][n] + inc_rate; 

If m , n = 1, and inc_rate = 1, after the first run, the updated matrix will be

matrix table={ {1, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }

For the next run, the above value will be the initial value of the matrix and so on.

Would anyone please suggest me how I can do that?

Thank you.


回答1:


Runs are independent of each other and cannot modify the parameters of an other run. This is by design, because they can be run parallel where there is no particular order between them. You can hack around this, by creating a very simple INI file fragment that contains only the single line that defines the matrix and include that line in your omnetpp.ini file. Then, at the end of each run, you delete that file and write out a new file with the updated matrix.

How you create that matrix, is up to you. I would probably create a bash or python script that handles the matrix generation and then starts the simulation.



来源:https://stackoverflow.com/questions/65703125/how-to-declare-a-matrix-in-ned-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!