简体   繁体   中英

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.

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".

My Java/AnyLogic skills are pretty basic, so any help is appreciated. 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:

  1. your variable must be of type "ResourcePool", see screen below
  2. you must set it correctly in the resource pool's "on seize" as
  3. in the Service "On seize unit" code box, you must access it properly. In my case it would look like 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.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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