AnyLogic Error Handling: How to say if there's an error, move to the next block - simulation

I have a rail yard simulation in AnyLogic, and I create different car types based on a schedule. Then, I use TrainCouple to create one train with a dynamic, specific number of each car. However, if the number for a certain car type is 0, I run into a problem because the train is trying to couple with nothing. I was thinking I could resolve this problem by doing an error handler where every time there's an error, it would force move to the next flowchart block. Does anyone know how to do this, or have any other ideas for how to deal with this problem?

Related

How can I generate multiple references in simulink?

I am creating a simulink model for a mobile robot. The idea is to this robot goes to diferent coordinates (X, Y). I already have my controller (PI controller) and the full system simulated (motor model, dynamic model and kinematic model) and everything is working good; However, the reference I am given is based on time, this means that e.i every 100 seconds the reference is going to be change no matter if the robot reach or not the goal (the current reference in X and Y).
What I want to do is, insted of giving a centain amount of time, when the robot reach the goal (reference in X and Y), the next reference is given automatically (the referece can have a tolerance of .05 for example, so the simuluted robot does not have to reach 100% the goal).
I was thinking for doing it with a stateflow block with a feedback of the error to say something like: if the error is less than 0.05 you can send the next reference, but I am not sure how to translate it to the simulation (what to put inside the stateflow).
Of course if someone has a better idea I would like to read it.
if someone has experience with this I really appreciate your help. I attache some photos with the blocks that maybe they can better clarify it.
Current simulation block
My idea

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

Is there a way to record when (and how often) Transporters get within a certain distance of each other?

I have an AnyLogic simulation model using trucks and forklifts as agents (Transporter type), and among other things would like to identify each time one of them becomes within a certain distance of another one (example within 5 meters). I will record this count as a variable within the main space of the model. I am using path-guided navigation.
I have seen a method "agentsInRange" which will probably be able to do the trick, but am not sure where to call this from. I assume I should be able to use the AL functionality of "Min distance to obstacle" (TransporterFleet) and "Collision detection timeout" (TransporterControl)?
Thanks in advance!
Since there don't seem to be pre-built functions for this, afaik, the easiest way is to:
add an int variable to your transporter agent type counter
add an event to your transporter type checkCollision that triggers every second or so
in the event, loop across the entire population of transporters and count the number that are closer than X meters (use distanceTo(otherTransporter) and write your own custom code)
add that number to counter
Note that this might be very inefficient computationally as it is quite brute-force. But might be good enough :)

Pedestrian Position/coordination in anylogic in certain time period

I have a simple pedestrian model where 7000 pedestrians are going from an entry line to target line. I want to know the position of the pedestrians after certain time period for predicting how much time they need for going from one point to another. In anylogic help i saw getX,getY function but where to use these and how?
Pedestrian Model and Simulation
Create a dynamic event called GetCoordinates with 1 argument called ped of type Pedestrian
in the pedGoTo block when an agent enters the block you will use this code:
create_GetCoordinates(1,SECOND,ped);
In the GetCoordinates dynamic event you can now use ped.getX() and ped.getY() to collect the information you need after 1 second.