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

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

Related

Different delay time for different agents in Anylogic

I'd like to know a very simple function of the software Anylogic: I have to set different delay times for different agents in a model, but the software let me see only one boxe and there's no possibilities to specificate what kind of delay time I prefer for every agents. How could I do? Thank you
I tried with some code of Java script but I think that scripture could be available only for the section "Actions" in the different boxes
This is one of the most basic functionalities so check the tutorials as well, but here goes:
Add a parameter 'myParameter' in your agent type of type double.
Give the agents different values for that parameter (cab be dine in the source or where ever you instantiate your agents)
In the delay block code section, use 'agent.myParameter' to access and apply that agent-specific duration.

How to communicate variables between agent populations in AnyLogic?

I have two populations of agents (only one of which I want to control) and I want to program one agent's actions based on the distance to the agents in the other population. I can get the location of each agent in their own population by using getX() and getY(). However, once these values are stored in a variable, they are not able to be communicated to a different population. Also, using distanceTo (agent other) does not seem to work for agents in a different population. Another issue I am having is how to call up location information for a specific agent (i.e., agent 1 in a population of X agents). When I print the agent names during a model simulation run, I see the agents listed as root.agent[0], etc., however, this syntax does not seem to work for calling up that specific agent when trying to code specific actions based on that agent (i.e., when this agent is so close, do something).
I tried storing locations using getX() and getY() into separate variables. Then using those variables to perform distance calculations. However, these variables, when stored in agent1 agent type, they cannot be communicated to agent2 agent type for variable use. I tried this for distanceTo() as well and got similar errors. I also try calling root.agents[0], root.agent[0] and agent[0] to use for distance calculations (both in and out of that agent's agent type) and get errors for "variable root not recognized" and "variable agent not recognized."
I understand this may be a beginning level programming question, but I cannot find literature on how to solve this problem in AnyLogic help sites online, nor have I been able to find a specific tutorial that works with this type of issue. Thank you for the help.

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.

How to use "wait" in anylogic?

I have a stock agent which is created in the end of my production line. My products are characterized by their model. I'm trying to create a logic to take out the products from this stock agent when they are to be delivered to the client. This delivery is controlled by an excel sheet and I'm taking the information through a SQL code. However, I was not able to find the right code to take out the products which are to be delivered. My agent population is called ProdutoStock and it's located in my main screen.
I have tried: Main.remove_ProdutoStock() but i couldn't figure out the arguments that i need for this function, since i have to take out of the agent a specific number of agents and also of a specific model.
So, I decided to create a wait block and use the free function to free the specific agents i wanted main.waiting_delivery.free() but i also can't figure out the necessary arguments for this function.
Would someone have any idea how I can take out of my agent/line the products that I need to deliver for my client (considering quality and also model)? This code is not being typed into my main screen.
the argument of the free method is the agent itself.
So you have to do main.waiting_delivery.free(yourAgent);
If you want to free the last agent that entered the wait block:
if(main.waiting_delivery.size()>0)
main.waiting_delivery.free(main.waiting_delivery.get(0));
If you want to free agents following a certain condition
List <YourAgent> theAgents=findAll(main.yourAgentPopulation,a->a.condition==true);
for(YourAgent a : theAgents){
main.waiting_delivery.free(a);
}

AB modeling in anylogic (statechart)

I have a problem where the state of one agent depends on the states of its components. Like I have a machine which consists of 10 different components. each one has its own state chart( the states could be; Operating,failed, under manitenance...etc). So the machine will fail if at least one component fails and it will be up if all of them is operating. What I did is to create the 10 agents and create thier statecharts( please note that each component has different failure rate, repair time..etc that is why i seperate them) and i created one agent for the machine with its statechart(that is dependent on the 10 statecharts), I am stuck here, I could not find way to get the state of the machine based on its components' states.
It should be AB modeling
Thanks alot