Usage of IF condition in anylogic - anylogic

I am trying to create model in which i want to collect the specific colored(RED) agents at a specific location (A). I am using a transfer table to divert the flow from one conveyor to other.
Can any body help me how to divert the flow based on the colors of agent.
attached snaps of discrete event diagram. Please let me know if you require more information.
discrete eve dia 1
image showing collection

A transfer table cannot actively steer where agents go. Instead, you have to manage where agents should be transfered in the "Convey" block as below. Put in a condition based on the agent color and send them to the respective end nodes or conveyors.
Hope this helps

Related

How to i make agents in AnyLogic avoid another moving agent?

I am trying to model an agent based model where a certain agent population of people avoid to get close to a single agent, a random moving VIP.
I have tried to useif (distanceTo(main.vip < restrictedArea)) ;moveTo(uniform(500),uniform(500))
The agent will, most of the time, move to its new random destination through the restricted area which i want to avoid
Either you use the Material-handling library (where the transporters have build-in collision avoidance).
Or you model it youself. For that, you need a cyclic event in your agent that constantly checks the distance to whatever other agent you are interested in. If below some threshold, you tell the agent to move elsewhere.
Note: the first option can be quite slow. The second is not trivial to implement. Less due to coding skills, more because having intelligent collision avoidance algorithms is not trivial

How can I create a finite calling population model?

I am trying to simulate a finite calling population model in AnyLogic. My population consists of 10 agents and I want them to come back to the Source node after they have been served.
I thought about making conditioning with the SelectOutput node but the Source node does not have any input. The best thing that I came up with is to just limit the number of customers arrivals to 10. However, in this case, the model stops running after 10 arrivals which is not an appropriate result.
What can I do to be able to simulate such a type of model in AnyLogic?
EDIT: I thought that making agents come back to the Source node could be a solution to building the finite calling population model. The main purpose of my question is to understand how can I build such type of model in AnyLogic. Here is the description of the concept of the model.
You cannot send them back to a Source element, as it only acts to create agents.
However, you can send them back to blocks that come after the source as below:
Here, all agents created by the Source block will infinitely loop through the Queue and Delay blocks.

System dynamics SEIR infectious curve for 3 waves of Covid

Using system dynamics on anylogic how can you model a simulation that will give an infectious curve of this nature(Below picture) using SEIR.
enter image description here
I have tried to simulate, however my graph goes up and down. It does not oscillate as per the attached picture.
I need to simulate something similar to the graph for my assingment.
There should be three types of events in your model.
First, lets call it "initial spread", is triggered on the start of your simulation.
Second, lets call it "winter season", is triggered annualy in November\December.
Third, lets call it "mass vaccination" - you can decide when to trigger it and for what selection of your agents.
So first two are kind of global events, and the third event is specific to some sub-population (this can make the third wave kind of "toothy" if you trigger it in slightly different moments for different populations).
That is pretty it.
Curios to see how your model will predict the fourth wave - second winter season of your simulation. So keep us updated :)
There are a number of ways to model this. One of the simplest ways is to simply use a time aspect for one of your infection rate parameters so that the infection rate increases or decreases with time.
See the example below.
I took the SIR model from the Cloud https://cloud.anylogic.com/model/d465d1f5-f1fc-464f-857a-d5517edc2355?mode=SETTINGS
And simply added an event to change the Infectivity rate using an event.
Changing the chart to only show infected people the result now looked something like this.
(See the 3 waves that were created)
You will obviously use a parameters optimization experiment to get the parameter settings as close to reality as possible

Generic modeling of an energy supply chain with Anylogic

I have been working with Anylogic for about 6 months now and my goal is to model a generic energy supply chain for an energy demand (e.g. storm and heat for a house). As a result I want to evaluate how suitable the components in the energy supply chain are to meet the energy demand.
My idea would be to model the components (Ex. PV->Battery Storage->House) as agents. I would have modeled the energy flow in the agents with SD and individual events of the components (e.g. charging and discharging at the battery) via state diagrams.
Currently I have two problems:
Which possibilities are there to create a variable interconnection of my components (agents). For example, if I do not want to evaluate the scenario PV->Battery Storage->House, but PV->Electrolysis->Tank->Fuel Cell->House. My current approach would be to visually connect the agents with ports and connectors and then pass input and output variables for DS calculation via set and get functions. Are there other possibilities, e.g. to realize such a connection via an input Excel? I have seen a similar solution in the video: "How to Build a True Digital Twin with Self-Configuring Models Using the Material Handling Library" by Benjamin Schumann, but I am not sure if this approach can be applied to SD.
To evaluate the energy supply chain, I would like to add information to the energy flow, for example the type (electricity, heat), generation price (depending on which components the energy flow went through) and others. Is there a way to add this information to a flow in SD? My current approach would be to model the energy flow as an agent population with appropriate parameters and variables. Then agents could die when energy is consumed or converted from electricity to heat type. However, I don't know if this fits with the SD modeling of the energy flow.
Maybe you can help me with my problems? I would basically be interested in the opinion of more experienced Anylogic users if my approaches would be feasible or if there are other or easier approaches. If you know of any tutorial videos or example models that address similar problems, I would also be happy to learn from them.
Best
Christoph
Sounds like what you need is a model that combine agent-based and system dynamics approaches with Agents populating the stocks (in your case energy that then gets converted into heat) depending on their connection. There is an example of AB-SD combination model in 'Example' models and I also found one on cloud.anylogic.com, although it is from a different domain.
Perhaps if you can put together a simple example and share then I'll be able to provide more help.

Anylogic - Measuring time through multiple layers of a model

I'm simulating a train system and want to measure the time a passenger spends from entering the system to boarding. Entering the system happens on a higher, boarding on a lower level of the model. The problem is that the TimeMeasureEnd block doesn't see the TimeMeasureStart blocks on a different level. Does anyone have experience with this problem or an idea for a solution?
Edit:
I call set_startObjects(TimeMeasureStart[]) in an event occuring once at the creation of the agent in the lower level and set either the start blocks of the one or the other parent, depending on what the parent is. The data is being collected in all child agents separately and displayed in separate histograms in each child agent. How can I accumulate all of them in one single histogram to display in main which is two layers above the child agent where the data is being collected?
you can always define the 'TimeMeasureStart' block dynamically in your 'TimeMeasureEnd' block. Just switch the entry mode for defining it to "static value" as below:
Now you can call on any 'TimeMeasureStart' object anywhere in the model, similar to below where it sits in 'Main':