With a model consisting of several blocks, I can select a few of them and (using the right-click menu) "create a custom flowchart block", which is a new agent type, which I've descriptively called "Process". I can use several instances of this Process agent in my model.
What I'd like to do now is extend the Process agent, i.e. make a subclass with some specialised behavior.
To do this, I can create a new agent from scratch called "RateControlledProcess". Then in the Advanced properties, in the Extends Other Agent dropdown, I choose Process. I see a greyed-out version of the Process components appear as expected.
At this point, given that I haven't added any new behaviors to the RateControlledProcess, I would expect that I should be able to drag an instance onto my Main model and use it in the same way that I can use Process. But it doesn't work: There is an icon rectangle, but there are no ports that allow me to connect any process (or fluid, in my case) to the new instance. It seems that the subclass is missing key behavior of the parent class, breaking the concept of inheritance.
Is there a way to make a subclass of an agent that has been created as custom flowchart block?
In general, agent inheritance is designed for reusing basic Java features like parameters, variables, and functions. However, it does not support ports or editing inherited process flowcharts. As a result, the inheritance may not be the best approach when creating custom blocks or libraries.
As an alternative, consider adding an instance of the "Process" agent type into the "RateControlledProcess" agent type. This is also how AnyLogic library blocks are developed — when a block from the Process Modeling Library or another library is needed while creating a new one, it is typically embedded and reused within the new block. In other words, we relay on a composition approach rather than inheritance (https://www.digitalocean.com/community/tutorials/composition-vs-inheritance)