如何使用“定制分配”构造函数中的构造函数

发布于 2025-02-07 08:34:49 字数 574 浏览 1 评论 0 原文

我对Anylogic来说是相当陌生的,我正在尝试弄清楚如何使用“定制分配optoftions”构造函数来手动创建“选项列表”中定义的项目的随机分发。我的目标是根据用户输入动态定义选项列表 - 项目的自定义分发。在网上研究如何动态定义自定义分发的解决方案之后,我遇到了此解决方案:中。在这篇文章中,用户使用构造函数来创建自定义分发,这也是我想要做的。但是,每次我尝试在“主要”代理中初始化构造函数作为启动行动,我都会得到一个 error 指出该方法对MAIM类型不确定。

我不明白为什么此错误不断弹出,因为文档指出我可以将函数“ customDistributionOftions()”用作构造函数。请让我知道我不了解和/或缺少什么。

I am fairly new to Anylogic and I am trying to figure out how to use the "CustomDistributionOfOptions" constructor to manually create a random distribution of items defined in an "Options list". My goal is to dynamically define the custom distribution of the options-list-items based on a user input. After researching solutions online on how to dynamically define a custom distribution, I came upon this solution: Dynamically Changing Distribution in AnyLogic. In this post, the user uses a constructor to create a custom distribution, which is what I want to do as well. However, every single time I try and initialize the constructor in my "Main" agent as an action on startup, I keep getting an
error that states that that method is undefined for the type Main.

I do not understand why this error keeps popping up, as the documentation states that I can just use the function "CustomDistributionOfOptions()" as a constructor. Please let me know what I am not understanding and/or missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分开我的手 2025-02-14 08:34:49

这是从我的一个模型中初始化自定义分发的一个示例:

CustomDistributionOfOptions<VaccineAttitude> customDistributionVaccineAttitude = 
new CustomDistributionOfOptions(
    VaccineAttitude.values(),
    new double[]{
        weight_vacc_acceptor,
        weight_vacc_hesitator,
        weight_vacc_rejector
    },
    this
);

它正在做的是宣布类型 cuteandistibutionOftions&lt; vaccineattitude&gt; 的新变量,其中 vaccineatitude 是选项。列出列出发行的选项。该变量的名称是 customDistributionVaccineattute 。根据任何logic vaccineattitude.values(),类型 double 的权重数组以及拥有变量的代理。在此示例中,代码位于MAIN中,因此是指main。

您可以按以下方式查询分布:

VaccineAttitude result = customDistributionVaccineAttitude.get();

结果将从选项列表中包含随机值 vaccineattute 根据构造函数中指定的权重从分布中绘制的。

Here is an example of initializing a Custom Distribution from one of my models:

CustomDistributionOfOptions<VaccineAttitude> customDistributionVaccineAttitude = 
new CustomDistributionOfOptions(
    VaccineAttitude.values(),
    new double[]{
        weight_vacc_acceptor,
        weight_vacc_hesitator,
        weight_vacc_rejector
    },
    this
);

What it is doing is declaring a new variable of type CustomDistributionOfOptions<VaccineAttitude>, where VaccineAttitude is the Option List that lists the options for the distribution. The name of the variable is customDistributionVaccineAttitude. As per the AnyLogic documentation, the constructor takes the values of the Option List, VaccineAttitude.values(), an array of weights of type double, and the agent that owns the variable. In this example, the code is located in Main, so this refers to Main.

You may query the distribution as follows:

VaccineAttitude result = customDistributionVaccineAttitude.get();

result will contain random value from the Option List VaccineAttitude drawn from the distribution according to the weights specified in the constructor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文