Warm tip: This article is reproduced from stackoverflow.com, please click
anylogic

Anylogic: Declare parameter of type ArrayList

发布于 2020-06-24 17:08:29

I'm building a class (sorry - Agent) that will work with a set of Tank objects (Fluid Library) - doing things like monitoring individual levels or total level of all tanks, reporting on levels and initiating actions based on levels - things of that nature. For argument's sake let's call it a "TankMonitor" agent.
Ideally I'd like to be able to define a Parameter in my "TankMonitor" agent that allows me to define the tanks of interest when I place a TankMonitor in main. I have tried to define the type of the parameter as Other - ArrayList<Tank> however I don't know how to set up the next step to allow me to populate the ArrayList of Tanks when I put an instance of this agent in main. My preference would be to have a list type control to populate the ArrayList - much like the way the AnyLogic Seize block allows you to specify multiple resource pools to choose from.

Has anyone attempted this before and been successful?

Questioner
CrustyNoodle
Viewed
26
Benjamin 2020-04-06 19:48

This is possible as follows:

  1. Change the type to "Other" and then 'Tank[]' , i.e. an Array of Tanks
  2. Change the control type to "one-dimensional array"

Example below. Now you have the same UI to pre-define tanks at design time for your agent instance.

enter image description here