I've a question about the "split" component of AnyLogic PMI library. To better explain the case I will post a picture of a part of the scenario I'm building. .
In the picture above the source element on the left generates objects of type "Requirement" (it is a custom class that inherit from the Agent class). This class represents a matrix with the requirements for every products "Pi" for every customer "Ci" (an example of matrix is given):
This matrix can be viewed as a collection of agents because every rows is an agent to which a first other of my circuit block is concerned (logically it contains information about the quantity of product Pi to be ordered from the product supplier) and every columns is an agent to which a second other of my circuit block is concerned (logically it contains the forecast of sale for customer Ci).
It is possibile, in the "on at enter" event of the split block, build a script that iterates first the rows and emits each one on the "out" split's port and then iterates the columns and emits each one on the "out-copy" split's port. I will post a pseudo-code of the script that I'm thinking to place in the "on at enter" event:
matrix = (Requirement)agent;
Iterator<Object> reqIter = matrix.getRequirements(); //iterate the rows
while (reqIter.hasNext())
{
Object current = reqIter.next();
//PUSH current in the out port of the split
}
Iterator<Object> sellIter = matrix.getRequirements(); //iterate the columns
while (sellIter.hasNext())
{
Object current = sellIter.next();
//PUSH current in the out-copy port of the split
}
I would put
Sink
orExit
block afternuove matrici
. UseSink
in case if initial agent-matrix can be destroyed after generation of agents, orExit
if initial agent should saved and reused somehow later.Split
block can be removed. Instead of the block, put twoEnter
blocks connected to the respective following queues.Inside
On Enter
action ofSink\Exit
execute the code. The generated agent can be injected into the respective queue withenterBlockName.take(new MyAgent(args...));
E.g., considering that code generates instance of
Agent
type it will be: