1
votes

I want to use the split block in a process model in a way such that it creates a copy of the incoming agent with the same parameters.

What I did: declare a function SetupCopy(agent, original) with input parameters agent (which is the copy) and original (which is the incoming agent). The function sets the relevant parameters to agent.someBooleanParameter = original.someBooleanParameter. The function is called in the split block in "On exit copy: SetupCopy(agent, original)".

Problem: after the outCopy port of the split block, I used a selectOutput block with the settings Select true output: if condition is true: agent.someBooleanParameter I want this parameter to be equal to the respective parameter of the original agent. However, the output block always evaluates the parameter to false.

I already tried to get an Output to the console of the parameter by setting On exit(false): System.out.println(agent.someBooleanParameter);

If the original agent's parameter is true, the output on the console is also true although the select block exits through the false port. Very confusing to me. What is my mistake?

Can anyone help me how to set the parameters of the copied instance of the agent and reference the parameter correctly?

Thanks

2
Any code samples or snippets you can provide in additional to your explanation would be helpful. Thank you!Mike Zavarello
What you've done looks correct. If that println statement is printing true and it's called from the outF port of the SelectOutput, then that should mean that your copy process worked correctly, and there should be no way the SelectOutput block has gone the false route.Stuart Rossiter

2 Answers

0
votes

it seems like the event of SelectOutput block is fired before you do the coplete copy of your agent.

to verify this, just add a queue between those block and check if the problem still occurs.

0
votes

It happens due to the condition specified in the SeletOutput block is checked before the agent-copy exits the Split block, and hence before it is initialized in the On exit copy code box. You need to specify the following Java code in the parameter New agent (copy) of the Split block to initialize a copy of the incoming agent ahead of the check:

new MyAgent(agent.someBooleanParameter, ...)