I would like to know if it is possible to create a random distribution of pedestrians at a given area each time I begin my simulation?
enter image description here
Create a Collection named allLocations of type AreaNode that contains all of your possible initialisation areas:
Use a process flow like the following with a PedSource:
Set the Area property in the PedSource to the following:
allLocations.get(uniform_discr(0, allLocations.size()-1))
This code randomly assigns one of the areas in the list to each agent as a start. You can modify this to fit your needs, with other distributions for example.
You can now see how Agents pop up randomly at the different locations:
The example model can be run and downloaded here.
Related
I am running a pedestrian simulation in Anylogic and want greater granularity in the agent position information that I get at the end of my model. Currently, I have it set up to show a heat map of traffic density, but I would like to trace the actual position of each agent through its time in the model, like a line or trail.
model visualization at the end of a simulation
[1]: https://i.stack.imgur.com/RwCVo.png
Add a cyclic event into your Pedestrian agent type (you cannot use the default pedestrians but must create your own agent type).
Then, every second (or whatever resolution you need), write the pedestrian coordinates (getX and getY) into a dbase table along with its index.
Then, you can do any post-processing that you need.
PS: typically, this is not really necessary, so make sure you really need this ;)
I am working on an evacuation project for a floor and would like to create a distribution of pedestrians from the pedSource block. These pedestrians will already appear in an area when I run the simulation. I want to obtain a fixed number of pedestrians in one area while the rest is distributed to other areas.
I have made a collection of areas that pedestrians will appear using allLocations (area, area1, area2 and OfficeArea). The event is triggered by an event and using a delay block. The max amount of pedestrians at the given floor is 100
Image of block flowchart
Image of floor layout plan
This is the code I tried where pedestrians would appear in the areas:
allLocations.get(uniform_discr(0, allLocations.size()-1))
I expect a fixed 10 number of pedestrians in the office area and positioned where I set the attractors, but the actual result shows more than 10 number of pedestrians and do not appear at the set attractor.
Image of actual result
Setting an attractor as a target for pedestrians is according to the documentation only working for the blocks pedWait and pedGoTo (I could actually only get it to work with pedWait, not with pedGoTo). Therefore you cannot initialize agents directly onto attractors using the initial location or the jumpTo() function.
You have several options as a workaround:
Extract the x,y coordinates of the attractor, and use the type point(x,y) to define the initial location or the location for the jumpTo()
Instead of using (graphical) attractors consider just defining points by code directly
Use very small individual areas instead of one large area with attractors
Use a pedWait block in your process flow and let your pedestrians 'walk' to their initial positions. Give the model a short time until everybody is on the desired location before starting your evacuation. You can also run the model in super fast mode during this initial phase, so that it will barely be visible.
I am quite new with Anylogic.
I am trying to model a simple conveyor system.
I would like my conveyor to accumulate until the conveyed objects touch each other.
I have set the "gap" parameter of the conveyor to zero, but the objects accumulate with a pitch of (apparently) one meter ?
Am I missing something ?
Please have a look to the model:
https://cloud.anylogic.com/model/3af9fc14-8677-4171-9191-52614703bef6?mode=SETTINGS
If you have a custom agent, you can set it to type Material Item (1). You can then set the dimensions at the class level (2), and AnyLogic gives you this nice visual aid to see how big your item is (3). This visual is nice, because then you can draw your shapes for animation purposes to match the size.
This approach would be for components that do not change in size, like pallets or consistent parts in a manufacturing environment. For material items that have varying sizes, like boxes in a DC, I would probably use the source solution Ben suggested.
You can set the size of your agents in several places. Best one for you is likely in the Sourceblock when you create your object agents. Tick the "change dimension" tickbox as below:
In your conveyor, you can override/adjust the length again if you like:
So in this model I have several hospital-agents that are placed randomly in an area. These hospitals contains a process flow and at some point in this process flow a new agent 'Bones' is generated, using a split block. The location of these Bones-agents is correctly specified by setting it equal to the (x,y) coordinates of the hospital.
Now I want to make the model more realistic by placing the hospitals in actual location in a GIS map. I did this with success. However, now I need to re-specify the location of the Bones-agents. At the moment of generating the first Bones-agent, I get the follow error:
root.Hospital1.splitblock:
Error when trying to initialize new agent
Caused by: root.Hospital2:
This agent is already defined as agent living in space 'Continuous, based on
GIS map' and can't have behaviour for space 'Continuous'This agent is already
defined as agent living in space 'Continuous, based on GIS map' and can't
have behaviour for space 'Continuous'
What do I need to do to make this work? I have tried setting the location of the Bones-agent equal to the longitude and latitude of the hospital agent with a function:
double longitude = getLongitude();
return longitude;
I did the same for het latitude. I then inputted these functions in the 'latitude' fields of the split block.
When you develop a model, you have to choose what kind of space you will use. Remember that all the canvas in which you put agents, and the map and stuff is based on a scale, so you can't mix a map with elements that are created with the space markup (with space markup i mean nodes, paths, rectangular nodes etc).
So the bones agents should also be placed in the map... It seems that you are not doing that, and you are probably placing the bones agent using the space markup.
But it's possible to do this of course, but you have to do it in another agent. Create a new agent called continuousSpace for instance, and place your bones agents there.
After that you will have to create a navigation button using viewAreas (from the presentation palette) to move from one agent to the other (meaning from the gis space to the markup space).
Otherwise, you can also place the bonesagents in the gis space (in the map) and it will also work.
Good luck :)
I am using SUMO to simulate the LuST scenario from https://github.com/lcodeca/LuSTScenario. However, since the scenario is rather large, I would like to start with a simulation constrained to region of interest. Is there a straight forward way to select such a region and have vehicles only simulated in that part of the map?
You can crop the network either using netedit by selecting the region of interest (change to select mode and then draw a rectangle holding the shift key), then inverting the selection (invert button) and deleting the rest. Or if you already know the boundaries or the edges you want to keep you can use for instance with netconvert --keep-edges.in-boundary minX,minY,maxX,maxY -s large.net.xml -o small.net.xml. See here for more netconvert options.
The next step is cutting the routes, which usually means a call like this:
$SUMO_HOME/tools/route/cutRoutes.py small.net.xml large.rou.xml --routes-output small.rou.xml --orig-net large.net.xml
This will not only remove the edges but also try to adapt departure times.