0
votes

I have a fairly straightforward process:

batch-seize-delay process

Order agent types are batched into a Batch agent type, then a third agent type is seized as a Resource for that Batch. On seize, a message is sent to the Resource agent's statechart for some actions to be taken. However, if a certain condition is met upon receipt of the message, then the Batch agent needs to release the Resource agent and seize a different one so the process can be completed. I've written code in the Resource agent that adds the rejected Batch agent into the collection shown above when it's rejected (rejectionsCollection.add(Batch)). Then, the Batch agent is reinserted at the second source block using an injection call and I've coded the 'New agent' option with rejectionsCollection.get(0). But, I have to also call remove() in the seize and delay blocks otherwise I get flowchart errors (same agent in two blocks at the same time).

When I use seize.remove(batch) as an action to take if the condition is met, but the problem is that the resource agent doesn't get released. I've also set the seize advanced option 'Canceled units' equal to 'go to release' and set 'Release for canceled units' as my release block, but this doesn't work. The third agent remains seized and eventually I run out of Resource agents (which shouldn't happen).

I've also tried copying it into a NewBatch agent Batch newBatch = batch; but it still gives a flowchart error. I've also tried using clone() but I haven't figured out the right syntax (I'm not the most experienced java programmer). I get error messages that say 'cannot convert from Object to Batch'. Not sure if it's relevant but the Batch agent has two collections within it as well.

My next thought was that I could manually release the Resource agent but the help file says that even though a seized resource is publicly accessible, users shouldn't do it. What else could I try?

Sorry for the wall of text but any ideas are appreciated!

1

1 Answers

0
votes

You do not manually release resources. The setup is agent-centric, so you must tell the agent to let go of the resource. This is done by making the agent "move" to the release block.

In your case, you could make the delay duration conditional: if the agent has met your condition, the delay time should be 0, else the normal delay time.

Use this notation: agent.condition == true ? 0. : normalDelayTime

You could also use a "Split" element after "Seize" and bypass the "delay" object altogether for your special agents.

Many options, but remember to thing agent-centric :)