AnyLogic蒙特卡洛贝叶斯实验中incidence1无法解析问题求助
解决AnyLogic中"incidence1 cannot be resolved"编译错误
修正拼写错误:你代码中写的是
incidences1.put(...),但你定义的TreeMap集合名称是incidence1(末尾多了一个s),这是导致编译错误的直接原因,先把变量名统一为incidence1。确认变量作用域与访问方式:
- 若
incidence1是蒙特卡洛贝叶斯实验的全局变量:确保变量已在实验的「Variables」面板中正确定义(类型为TreeMap<Double, Double>),且在实验的On startup动作中完成初始化:
之后在incidence1 = new TreeMap<Double, Double>();After Simulation Run中直接调用:incidence1.put(getCurrentIteration(), root.Incidence_Plot); - 若
incidence1是主agent(root)中的变量:需要通过root对象引用访问,同时确保变量可见性设置为public,修正后的代码为:root.incidence1.put(getCurrentIteration(), root.Incidence_Plot);
- 若
内容的提问来源于stack exchange,提问作者Jahidul Hasan Razib
相关产品推荐
相关产品推荐

