运行并行模拟(使用命令行) [英] Running parallel simulations (using the Command Line)

查看:63
本文介绍了运行并行模拟(使用命令行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用不同的配置运行模拟?我正在使用omnet ++版本4.6.

我的omnetpp.ini文件如下所示:

[General]

[Config Dcn2]

network = Dcn2

# leaf switch
#**.down_port = 2
**.up_port = 16 #12   # 4

# spine switch
**.port =  28 # 20 #2048

# crossconnect
**.cross_down_port = 28 # 20 #2048
**.cross_up_port = 28 # 20 #2048

# to set destination of packet
**.number_leaf_switch = 28 # 20 #2048

# link speed
#**.switch_switch_link_speed = 40 Mbps


**.interArrivalTime = ${exponential(.0001),exponential(0.0002),exponential(0.0003)}   

**.batch_length = 10
**.buffer_length = 10

sim-time-limit = 1000s

我想用不同的interArrivalTime值运行代码.但是我既不能使用不同的配置(一个接一个)运行,也不能在单独的内核上并行运行单个运行.

我尝试在运行配置中使用cmdev选项,但是除了第一个以外,其他运行没有显示.当我尝试提及进程数量超过一个时,那么也只会模拟第一次运行.我真的找不到原因.

解决方案

配置考试

根据您的情况,您可以执行配置检查. OMNeT ++为此提供了不同的选项.在OMNeT ++手册的参数研究部分中对此进行了解释. >

因此,您可以尝试以下选项之一来检查您的配置以及配置文件:

  • ./run –a-将显示omnet.ini
  • 中的所有配置
  • ./run -x <config_name>-将提供有关特定配置的更多信息
  • ./run -x <config_name> -g-查看所有配置组合

首先,您必须导航到示例文件夹,然后在其中执行上述命令之一.


我执行了./run -x Dcn2 -g并获得了以下结果

OMNeT++ Discrete Event Simulation  (C) 1992-2014 Andras Varga, OpenSim Ltd.
Version: 4.6, build: 141202-f785492, edition: Academic Public License -- NOT FOR COMMERCIAL USE
See the license for distribution terms and warranty disclaimer
Setting up Tkenv...

Config: Dcn2
Number of runs: 3
Run 0: $0=exponential(.0001), $repetition=0
Run 1: $0=exponential(0.0002), $repetition=0
Run 2: $0=exponential(0.0003), $repetition=0

End.

这确实确认您要尝试修改的模拟参数有3次不同的运行.但是,默认情况下,用于interArrivalTime参数的变量名会分配给$0,因为您没有指定它.

如果您在配置中更改以下行:

**.interArrivalTime = ${exponential(.0001),exponential(0.0002),exponential(0.0003)}

**.interArrivalTime = ${interArrivalTime = exponential(0.0001),exponential(0.0002),exponential(0.0003)}

对于./run -x Dcn2 -g,您将获得更具描述性的输出


运行配置的不同运行:

下一步,您将为您的配置运行不同的运行.您可以通过导航到示例目录并执行以下操作来完成此操作:

./run -c <config-name> -r <run-number> -u Cmdenv

请注意,<config-name>对您而言将是Dcn2,而-r指定您要执行以上给出的运行.

换句话说,您可以打开三个终端窗口并导航到示例目录并执行以下操作:

  1. ./run -c Dcn2 -r 0 -u Cmdenv-对于interArrivalTime =指数(0.0001)
  2. ./run -c Dcn2 -r 1 -u Cmdenv-对于interArrivalTime =指数(0.0002)
  3. ./run -c Dcn2 -r 2 -u Cmdenv-对于interArrivalTime =指数(0.0003)


区分不同的运行结果

要区分给定配置的不同运行的输出结果文件,可以修改输出文件的默认名称.

操作方法"在OMNeT ++手册的 12.2.3结果文件名部分中给出.

output-vector-file = "${resultdir}/${configname}-${runnumber}.vec"
output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca"

如您所见,默认情况下,您的输出文件将由${runnumber}变量区分.您可以通过在输出文件名中添加interArrivalTime来进一步改进它.

示例:

output-scalar-file = "${resultdir}/${configname}-${runnumber}-IAtime=${interArrivalTime}.sca/vec"

我尚未测试最终方法.因此,您可能会在使用过程中遇到一些错误.

How can I run the simulation with different configurations? I am using omnet++ version 4.6.

My omnetpp.ini file looks as below :

[General]

[Config Dcn2]

network = Dcn2

# leaf switch
#**.down_port = 2
**.up_port = 16 #12   # 4

# spine switch
**.port =  28 # 20 #2048

# crossconnect
**.cross_down_port = 28 # 20 #2048
**.cross_up_port = 28 # 20 #2048

# to set destination of packet
**.number_leaf_switch = 28 # 20 #2048

# link speed
#**.switch_switch_link_speed = 40 Mbps


**.interArrivalTime = ${exponential(.0001),exponential(0.0002),exponential(0.0003)}   

**.batch_length = 10
**.buffer_length = 10

sim-time-limit = 1000s

I want to run the code with different values of interArrivalTime. But I can neither run with different configs (one after another), nor can I run individual runs in parallel on separate cores.

I have tried with cmdev option in run configurations but the different runs doesn't show up apart from the 1st one. When I try mentioning the number of processes to be more than one then also only the first run gets simulated. I really cannot find out the reason.

解决方案

Config Examinataion

In your case you can perform config examination. OMNeT++ offers different options for that. They are explained under the Parameter Studies section of the OMNeT++ manual.

So you can try one of the following options to examine your configs and thus config file:

  • ./run –a - will show all the configurations in the omnet.ini
  • ./run -x <config_name> - will give more info about a specific config
  • ./run -x <config_name> -g - see all the combinations of configs

First you will have to navigate to your example folder, and there execute one of the aforementioned commands.


I executed: ./run -x Dcn2 -g and got the following resuls

OMNeT++ Discrete Event Simulation  (C) 1992-2014 Andras Varga, OpenSim Ltd.
Version: 4.6, build: 141202-f785492, edition: Academic Public License -- NOT FOR COMMERCIAL USE
See the license for distribution terms and warranty disclaimer
Setting up Tkenv...

Config: Dcn2
Number of runs: 3
Run 0: $0=exponential(.0001), $repetition=0
Run 1: $0=exponential(0.0002), $repetition=0
Run 2: $0=exponential(0.0003), $repetition=0

End.

This confirms indeed that you have 3 different runs for the simulation parameter you are trying to modify. However, variable name you are using for the interArrivalTime parameter is assigned to $0 by default because you have not specified it.

If you change the following line in your config:

**.interArrivalTime = ${exponential(.0001),exponential(0.0002),exponential(0.0003)}

to

**.interArrivalTime = ${interArrivalTime = exponential(0.0001),exponential(0.0002),exponential(0.0003)}

you will get a more descriptive output for ./run -x Dcn2 -g


Running different runs of a config:

Next step for you would be to run the different runs for your config. You can do that by navigating to your example directory and execute:

./run -c <config-name> -r <run-number> -u Cmdenv

Note that the <config-name> would be Dcn2 for you, and the -r specifies which of the runs given above you would like to execute.

In other words you can open three terminal windows and navigate to your example directory and do:

  1. ./run -c Dcn2 -r 0 -u Cmdenv - for interArrivalTime = exponential(0.0001)
  2. ./run -c Dcn2 -r 1 -u Cmdenv - for interArrivalTime = exponential(0.0002)
  3. ./run -c Dcn2 -r 2 -u Cmdenv - for interArrivalTime = exponential(0.0003)


Distinguishing Different run results

To be able to distinguish between the output result files of the different runs for your given config you can modify the default name of the output file.

The "how-to" is given in the 12.2.3 Result File Names section of the OMNeT++ manual.

output-vector-file = "${resultdir}/${configname}-${runnumber}.vec"
output-scalar-file = "${resultdir}/${configname}-${runnumber}.sca"

As you can see by default your output files will be distinguished by the ${runnumber} variable. You can further improve it by adding the interArrivalTime to the output file name.

Example:

output-scalar-file = "${resultdir}/${configname}-${runnumber}-IAtime=${interArrivalTime}.sca/vec"

I have not tested the final approach. So you might get some error along the path.

这篇关于运行并行模拟(使用命令行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆