【问题标题】:Sending array as message in omnet++在 omnet++ 中将数组作为消息发送
【发布时间】:2023-03-08 01:34:01
【问题描述】:

我完全是 OMNeT++ 的初学者。我想将数组设置为消息并通过我的模块发送。这些数组是神经网络中的权重和偏差。他们会在每个模块中更新。我已经在 c++ 中为此编写了代码,包括 <array> 并使用它,但我不知道如何使用 <array> 并在 OMNeT++ 的 .msg 文件中定义我的消息。 请帮我解决这个问题。

提前致谢

【问题讨论】:

    标签: c++ arrays message omnet++


    【解决方案1】:

    没有必要使用<array>。要在消息中声明 10 个元素的数组,应编写如下内容:

    message MyMessage {
       double weights[10];
       double bias[10];
    }
    

    另外,如果事先不知道数组的大小,可以声明变长数组:

    message MyMessage {
       double weights[];
       double bias[];
    }
    

    在消息定义中处理数组在OMNeT++ Simulation Manual中描述。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-10
      • 1970-01-01
      • 1970-01-01
      • 2020-09-20
      • 2012-04-10
      • 1970-01-01
      • 2022-11-13
      • 1970-01-01
      相关资源
      最近更新 更多