This is the name of the class that needs to be created The code is as follows, please read the comments for more detailed description. In the example Main agent, the code is in the action property of the 'create directly' button. This is the least preferable method of the two. In this example there are 2 agents Main and ProgrammaticAgent. alp can be found here for the next 2 hrs. Please note that the drawback of both methods is that since the type of the resulting agent is not known in advance the code refers to the new entity as just Agent however it actually creates the agent of correct type, which can be checked using 'instanceof' or cast.īoth versions are provided below. There are two ways to achieve this: via Java Reflection and using. Every project will have different agents, variables, names, parameters, etc. My Issue here is, that I try to make my block as customizable as possible, meaning that I want to use this block in future projects again without changing the code at all (or at least too much). I know that normally I have to use something like ' new Agent()' to create new agents, but I can't find a link between the parameter-value and the agent-type. Obviously, putting just the name of the parameter in the new agent field didn't work (it does work, but only for the first agent - after that I get an error, since the same agent gets created). I want to create agents dynamically depending on the selected parameter (type Agent). Now I want to create the other agent with a source block and the inject function. So far, I was able to verify the incoming agent to make sure, that the right agent-type was selected in Main. What my block does is, it creates new agents depending on the agents, that enter the block (kinda like the batch-block). Two of them are of the type ' Agent' and in Main I selected the corresponding agents. To stay up to date with AnyLogic 9 and developments across all the AnyLogic platforms, subscribe to the AnyLogic Newsletter.I created my own Flowchart block with a few parameters. The section concluded with the announcement of an online AnyLogic 9 IDE prototype from December 2020 that will initially be available for limited community testing.
0 Comments
Leave a Reply. |