0
votes

Question has been asked and answered before, see Anylogic - dynamic specification of resources to seize. But the multiple trolls on stackoverflow requested me to ask same question again, regardless.. - as asking it there is seen as an "answer" and not a "question".

Anylogic 8.7.2.
I create a Resource Pool myworkers.
Of agent type workers.
Open the workers agent and add a variable offloadBay (or parameter, does not matter), INT, default value 0. In main I use a seize block to seize 4 resources from this pool, but they need to meet the condition offloadBay == 0. In the seize block I select Customise resource choice == true ; Recource choice condition = (unit.offloadBay == 0). On running the project, I get the error - "offloadBay cannot be resolved or is not a field".

It seems reference to the keyword unit does not actually reference the resource unit - none of the unit's parameters, variables, functions, etc. are available to be called when referencing unit.

Please advice on what am I doing wrong? Alternatively, how do I select a resource from the ResourcePool based on a certain condition or property of the resource? (demo project can be provided on request, please advice where to send to)

1

1 Answers

0
votes

Try enforcing the resource type. This happens because you are in the seize block and when you use "unit" you may be referring to different resource agent types. Not all of them may have the "offloadBay" variable. So, use:

((Worker)unit).offloadBay == 0