简体   繁体   English

Anylogic - 从占用的资源获取资源池

[英]Anylogic - Getting Resource Pool from a seized Resource

I have a Service block which can seize a resource from one of two Resource Pools. 我有一个服务块,可以从两个资源池中的一个获取资源。 At the "On seize unit" section of Actions in that block I'd like to determine which Resource Pool the agent came from. 在该块中的Actions的“On seize unit”部分,我想确定代理来自哪个资源池。

I tried to create a bespoke agent type for the Resource Pools that could have a variable attached which I could then read via something like "unit.MySpecies" but get the "MySpecies cannot be resolved or is not a field". 我试图为资源池创建一个定制的代理类型,它可以附加一个变量,然后我可以通过类似“unit.MySpecies”的内容读取,但得到“MySpecies无法解析或不是字段”。

My Java/AnyLogic skills are pretty basic, so any help is appreciated. 我的Java / AnyLogic技能非常基础,所以任何帮助都表示赞赏。 I saw the answer for getting individual resources utilisation, but I'm hoping this question is an order of magnitude simpler and is just a case of the right words and grammar. 我看到了获得个人资源利用的答案,但我希望这个问题比一个数量级更简单,只是一个正确的单词和语法的例子。

You must use Java properly, the error suggests some wrong format: 您必须正确使用Java,错误表明格式错误:

  1. your variable must be of type "ResourcePool", see screen below 您的变量必须是“ResourcePool”类型,请参见下面的屏幕
  2. you must set it correctly in the resource pool's "on seize" as 你必须在资源池的“on seize”中正确设置它
  3. in the Service "On seize unit" code box, you must access it properly. 在服务“On seize unit”代码框中,您必须正确访问它。 In my case it would look like unit.myPool . 在我的情况下,它看起来像unit.myPool

Maybe you are also writing your code wrong in the on seize. 也许你在抓住时也写错了代码。 If you want to check where the resource comes from, make sure it looks like: 如果要检查资源的来源,请确保它看起来像:

if (unit.myPool.equals(myResourcePool)...

Where "myResourcePool" is the actual name of the resource pool. 其中“myResourcePool”是资源池的实际名称。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM