Replace agent by 3 others after the process (cutting machine) - anylogic

i want to model a sawing machine. how can i represent that when agent 1 is processed then it is removed and agent a,b,c is output and when agent 2 is processed then agent x is output 3 times? What blocks do I need and how can I formulate this as code?
I'm a beginner in Anylogic
I tried this with a sink and source Block, but i dont know how i can output 3 agents from a source Block.

With a source block you can only generate 1 type of agent... and there are 1000 ways to do what you are asking, this is one
What you would need to do is to have enter blocks and generate the agents after the sawing process is done
YourAgent1 a=add_YourAgent1();
YourAgent2 b=add_YourAgent2();
YourAgent3 c=add_YourAgent3();
enterBlockA.take(a);
enterBlockB.take(b);
enterBlockC.take(c);
you will need to create a population of agents to have access to the function add_YourAgentTypeName() that will create a new agent in that population
Then an enter block will act as your source

Related

extract agents stored as a parameter inside one agent in anylogic

[extract agents from a parameter]
[1]: https://i.stack.imgur.com/sXoOk.jpg
I have an agent (shipment) with amount parameter. I want to make decisions according to every single shipment to decide where to go. the problem i've struggled with is how to transform my one agent per arrival to many agents equals to the parameter (amount) after he gets out of the queue, queue1 .I used unbatch block to illustrate what i am trying to do.
you can't unbatch things if you haven't batched them before..instead to achieve the same thing you can use a split block
With the split block you can define the number of copies based on that amount parameter and you can define the type of agent copied as well

Batching multiple agents based on location of agent

In my model I only want to batch agent which are at the same location. So my source block generates the agents according to a database to a specific node (which is sometimes different for agents), now I want the agents that occur at the same node to batch in sizes of 2 and the one that are left over need to be batched alone.
How can I model this, I know that I can use the selectoutput (which says for example if location=node1 use this output etc) option, but do I than have to add for example manually 100 outputs if I've 100 different locations where the agents start or is there a more simple solution for this problem?
Added later:
Or is there another way to model my idea:
So I'm simulating an hospital environment, where logistic employees (in this case the transporter) based on predefined times collects the thrash on certain areas for example the databaserow I show in the picture below:
At 9:50, the thrash at thrash collection point at LAB_Office_2_H_T_N can be collected by the logistic employee.
So in my model I create this 2 agents (which are 2 containers, last column) based on this time and seize a transporter to collect this thrash. Since a logistic employee is able to collect 2 thrash in one time I want to batch it and let the logistic employee collect 2 thrash containers at once.
After that he transports it to the thrash dump area and is released.
The colors changed after the added information. You can use pickup and dropoff blocks instead. You can define your node requirements in the condition cell. You can use local variables like container and agent to code whatever you want. Or use "Quantity (if available)" option. There you can programmatically define how many units will be picked up by using your own function.

Routing agents through specific resources in anylogic

I am solving a job shop scheduling problem resorting to anylogic. I have 20 jobs (agents) and 5 machines(resources) and each job as a specific order to visit the machines. My question is: how can I make sure that each job follows its order.
This is what I have done. One agent called 'jobs' and 5 agents, each one corresponding to a machine. One resource pool associated to each one of the service blocks. In the collection enterblocks I selected the 5 enter blocks.
In the agent 'jobs' I have this. The parameters associated to each job, read from the database file, and the collection 'enternames' where I selected the machine(1,2,3,4,5) parameters and the collection 'ptimes' where I put the processing times of the job (This two colletions is where I am not sure I have done it correctly)
My database file
I am not sure how to use the counter used here How to store routings in job shop production in Anylogic. In the previous link the getNextService function is used in the exit blocks but I am also not sure how to use it in my case due to the counter.
Firstly, to confirm that based on the Job agent and database view, the first line in the database will result in a Job agent with values such as:
machine1 = 1 and process1=23
machine2 = 0 and process2=82 and so on
If that is the intent, then a better way is to restructure the database, so there are two tables:
Table of jobs to machine sequence looking something like this:
job
op1
op2
op3
op4
op5
1
machine2
machine1
machine4
machine5
machine3
2
machine4
machine3
machine5
machine1
machine2
3
...
...
...
...
...
Table of jobs to processing time
Then, add a collection of type ArrayList of String to Job (let's call this collection col_machineSequence) and when the Job agents get created their on startup code should be:
for (String param : List.of("op1","op2","op3","op4","op5")) {
col_machineSequence.add(getParameter(param));
}
As a result, col_machineSequence will contain sequence of machines each job should visit in the order defined in the database.
NOTE: Please see help on getParameter() here.
Also:
Putting a Queue in front of the Service isn't necessary
Repeating Enter-Queue-Service-Exit isn't necessary, this can be simplified using this method
Follow-up clarifications:
Collections - these will be enclosed in each Job agent
Queue sorting - Service block has Priorities / preemption which governs the ordering on the queue
Create another agent for the second table (call the agent ProcessingTime and table processing_time) and add it to the Job agent and then load it from database filtering on p_jobid as shown in the picture

Anylogic, split an agent in multiple different agent types

I've a problem with a simulation in anylogic.
I have an item (agent) that must be processed by a resource, the result of this service block is the starting object and two different documents which are processed in two separate offices and which at the end of the flow will have to be linked to the article in question.
I can't find a way to do this division into 3 different agents, or in general, to model this flow.
Thanks in advice
You can use 2 split blocks to generate 2 independent documents and connect them through a variable or link to agents... maybe each original agent has an id and the copies in the split block will have something like agent.id=original.id;
Then after, when the documents are processed you can check for which ones have the same id to merge them into an article...
but if you want to get more complicated, there's also the following option:
create 2 enter blocks (enter1 and enter2), one for each document. I will assume your documents correspond to 2 different agent types called Document1 and Document2
On each one of the agent types, you will add a link to agents in order to be able to connect the documents to each other. Read more on link to agents on the help documentation if you don't know what that is.
At the end of the service block, on the on exit action, you can do the following:
Document1 doc1=add_Document1();
Document2 doc2=add_Document2();
doc1.linkToDoc2.connectTo(doc2);
enter1.take(doc1);
enter2.take(doc2);
I don't know if your original agent has to be connected, but you would follow the same principle to do that.
Later, you can just check if the connected docs are completed in order to join them in an article again.

Anylogic wearhouse - how to combine two agents to create one final agent

Good afternoon to everyone,
I have a problem with the software AnyLogic. I have to do a program that is able to combine two agents (two different semifinished) to create one final agent (final product). The problem is that the two semifinished have different production time, so I need a function that is able to accept one agent (the first semifinished), than to wait for the second agent and at the end to generate one final agent from the previous two agents (semifinished). How it's possible to do this? I have already tried with the function "Combine" without any success.
You need to use the "Assember" object from the process library. Speciy how many agents of type A and B you need (1 each in your case). The assember will create a new agent type (you need to specify it) from the 2 incoming agents once it has got 1 of each.
Also check the help on the Assembler, you can do lots of fine-tuning with it.
cheers