Eric
Eric

Reputation: 1

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.

Upvotes: 0

Views: 1138

Answers (1)

Benjamin
Benjamin

Reputation: 12660

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.

enter image description here

Upvotes: 1

Related Questions