从 excel 文件访问自定义参数值时出现错误代码

Error code while accessing custom parameter values from excel file

我正在尝试构建一个基于离散代理的模型。 我有一组带有自定义参数的代理,这些参数是通过 excel 文件加载的(这部分有效,我可以查看代理)。所有代理都在模型启动时立即创建。

现在我希望代理根据这些参数在系统中移动。 我已经构建了一个带有 selectOutputIn 和两个 SelectOutputOut 块以及一个 function 的虚拟模型。 如果字符串参数具有特定值,我希望代理移动到 selectOutputOutBasic

功能码为:

if (agent.variation == "Basic")
    return selectOutputOutBasic;
else return selectOutputOut;    

Anylogic 构建了模型,但是当我尝试 运行 它时,我得到以下错误代码:

Exception during discrete event execution:
class com.anylogic.engine.Agent cannot be cast to class test.Order (com.anylogic.engine.Agent and test.Order are in unnamed module of loader 'app')
java.lang.ClassCastException: class com.anylogic.engine.Agent cannot be cast to class test.Order (com.anylogic.engine.Agent and test.Order are in unnamed module of loader 'app')
    at test.Main.choice(Main.java:1)
    at com.anylogic.libraries.processmodeling.SelectOutputIn.b(Unknown Source)
    at com.anylogic.libraries.processmodeling.SelectOutputIn.b(Unknown Source)
    at com.anylogic.libraries.processmodeling.SelectOutputIn.outputBlock(Unknown Source)
    at com.anylogic.libraries.processmodeling.InputBlock.a(Unknown Source)
    at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
    at com.anylogic.libraries.processmodeling.OutPort.b(Unknown Source)
    at com.anylogic.libraries.processmodeling.OutPort.a(Unknown Source)
    at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
    at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
    at com.anylogic.libraries.processmodeling.OutputBlock.a(Unknown Source)
    at com.anylogic.libraries.processmodeling.OutputBlock.action(Unknown Source)
    at com.anylogic.libraries.processmodeling.AsynchronousExecutor_xjal$a.execute(Unknown Source)
    at com.anylogic.engine.LibraryEventHandler$b.execute(Unknown Source)
    at com.anylogic.engine.Engine.m(Unknown Source)
    at com.anylogic.engine.Engine.jj(Unknown Source)
    at com.anylogic.engine.Engine.c(Unknown Source)
    at com.anylogic.engine.Engine$b.run(Unknown Source)

原来会读书的人有优势...

我在 中找到了问题的解决方案,谢谢 @Dat Boi!

Try going to the service properties. Under the "Advanced" tab, is Agent Type selected as "MyAgent" or as "Agent"? Similarly, go to the source properties and check the tab Agent and make sure "MyAgent" is selected.