代理不能解析为函数体中的变量,但可以在其他块中工作



我目前有一个函数,每隔一段时间检查一次。我希望hold在满足函数体中的条件时解除阻塞。然而,agent永远不能解析为一个变量,即使这种引用代理的约定在其他进程块中也有效。存在于(((Patient)agent)中的agent是不能解析为变量的代理。Patient是一个代理类型,其变量isMorning在模型的上游被设置为true或false。下面是函数块中的代码,参数设置为Just action(不返回任何值)。(((Patient)agent)将在hold之前处于队列块中。

if (((Patient)agent).isMorning == true && SurgeonMorning.idle() > 0){
hold.unblock();}
else if (((Patient)agent).isMorning == false && SurgeonAfternoon.idle()  == 0){
hold.unblock();}

如果这是函数中的代码,则需要提供函数参数并使用该参数而不是agent

在参数下的函数属性中,添加条目myPatient并指定类型为Patient(从下拉菜单右侧)。

然后,您可以使用代码

if (myPatient.isMorning == true && SurgeonMorning.idle() > 0){
hold.unblock();}
else if (myPatient.isMorning == false && SurgeonAfternoon.idle()  == 0){
hold.unblock();}

查看帮助以了解更多函数。本文将帮助您了解何时(何时不)可以使用agent: https://www.benjamin-schumann.com/blog/2016/2/4/the-magic-lightbulb-and-how-it-can-help-your-anylogic-modelling

等关键字。

相关内容

最新更新