如何根据 AnyLogic 中的概率将(来源)3 种不同类型的代理注入模型
How to inject (source) 3 different types of agents into model based on probability in AnyLogic
我目前有 3 种扩展代理的代理类型 Patient
。我如何根据概率将这些类型注入到模型中,即 type1: 60% type2: 30% type3: 10% 或可能使用拆分块(我已经探索过但无法解决我的问题)将 Patient
分成我的不同类型?
在您的源属性中,在 Agent 字段中,写入以下内容:
randomTrue(0.6) ? new Type1() : randomTrue(0.75) ? new Type2() : new Type3()
将 Type1
、Type2
和 Type3
替换为您拥有的代理类型名称。
此外,请确保在高级下,您将 Agent 作为代理类型,否则会出错。
如果您对为什么我将第二个条件的概率设为 0.75 感到困惑,那是因为如果第一个条件为假,则 30% 代表剩余 40% 的 75%。
我目前有 3 种扩展代理的代理类型 Patient
。我如何根据概率将这些类型注入到模型中,即 type1: 60% type2: 30% type3: 10% 或可能使用拆分块(我已经探索过但无法解决我的问题)将 Patient
分成我的不同类型?
在您的源属性中,在 Agent 字段中,写入以下内容:
randomTrue(0.6) ? new Type1() : randomTrue(0.75) ? new Type2() : new Type3()
将 Type1
、Type2
和 Type3
替换为您拥有的代理类型名称。
此外,请确保在高级下,您将 Agent 作为代理类型,否则会出错。
如果您对为什么我将第二个条件的概率设为 0.75 感到困惑,那是因为如果第一个条件为假,则 30% 代表剩余 40% 的 75%。