AnyLogic - determination of lane in road traffic - anylogic

In my model, car-agents sort in the correct lanes just a few car-length before the crossing when the traffic light is green. That way, the intersection gets unrealistically inefficient. What I can not find in the APIs is a way to determine the lane choice x meter before the intersection.
Is there a parameter, if not any idea, to set the lane choice of car-agents in front of a crossing?
Thankful for any thoughts.

I have found intermediate stop lines, which only cover certain lanes, can be used to give you more precise control. You can send a car to the intermediate stop line, and then send on to the final destination of choice.

the lane can only be chosen in the beginning when the car is created or through the enter/exit blocks... otherwise you have to just accept the randomness of the internal model and you have no control over it.
Edit: but amy in her answer is right that you can redirect cars to strategic intermediary stop lines in order to choose the lane or group of lanes the cars will choose whenever it's going to a certain destination.

Related

Anylogic: Is it possible to move Transporters based on travel time, rather than distance and speed?

I would like to use transporters in my model in various places (tugboats, forklifts, reach stackers, trucks, etc.). However, my model paths and animation can't be drawn to scale, detailed explanation in brackets below.
Is there a way I can move the transporter from one node to another based on travel time (similar to what a movable resource can do), rather than speed and distance?
The "Move By Transporter" block does not seem to allow this and I have not been able to find a solution online. Thank you for your help.
(Explanation on why I can't draw to scale: firstly, some destination locations (storage areas, etc.) are not known yet and will just be represented by a travel delay to get there, secondly, different areas of the model will be drawn to different scales, i.e. some network paths will represent a multiple kilometers and some network paths will only represent a few hundred meters, etc.)
You can draw the paths to suit your animation and then simply set the speed of the transporter that gets seized to a speed so that the duration of the movement matches what you need it to be, and when the transporter gets released set the speed back to normal

Looking for a way to analyse transporter traffic on shopfloor (Density Map) in AnyLogic

I built up a shopfloor where material flow is realized by Transporters (AGV / AMR) with free space navigation. I am looking for a possibility to observe traffic at certain spots (e.g. work stations, storage areas) or even on the whole shopfloor so I can compare different scenarios of the material flow and supply strategy of the working station with a view on the traffic. I tried out the Density Map but since it observes the whole layout which is quite big the values get too low for the scale quite fast so it isn't performing the way I want it to. Is there a way so set up like a "area density map" so I can just observe a defined rectangle or another functionality which could help me here?
Happy about all ideas! :-)
You can use normal Rectangular Node elements and trigger "on enter" code to count drive-throughs or similar, as below.
Just make sure to set the capacity to infinity so normal traffic flow is not interrupted :)

How to simulate a pickup process happening in the parking lot in AnyLogic?

I am modeling a warehouse yard where trucks arrive, get loaded/offloaded and leave the site. The complexity arises when modeling the drop trailers. Those vehicles consist of two parts: tractor and trailer. Tractor and trailer enter the yard as one entity and move to the parking lot. There, the tractor drops the trailer (turquoise colored rectangles in the picture below) and then then leaves the yard. After some time another tractor (pink colored in the picture below) comes to pick up one of those trailers. When there is no free space in the parking lot, model throws an error, because I use carMoveTo block to send it to the parkingLot. Therefore it requires additional space to move the tractor. How can I avoid this issue? In fact, I do not want that pink tractor to seize a free parking lot, but to pick up one of those trailers. I tried suppressing the error by using "on the way not found" option in the carMoveTo block, but I need to get a close-to-reality animation of the yard.
I would not advise mixing the road traffic library blocks with the Process Modelling Library (PML) Blocks, unless you really need to.
You can get near-perfect animation by making use of a network-type model and just the PML blocks. You will start by replacing your Car Move To block with just a MoveTo block
You can check the WholeSale Warehouse example in AnyLogic.
There they make use of a network diagram and PML blocks to simulation all the relative parking movements of trucks and trailers.
You can do something similar by creating the correct network and node points that indicate how a truck must move when it is parking a trailer and when it is picking up a trailer.
If this solution is not scalable and you cant draw lines, you can always simply just specify the X,Y, Z coordinates.
You might then need multiple MoveTo blocks for the entire movement or you can create some sort of loop where you give a truck a list of locations to move to, the truck will go through the loop and simply execute moving to the next location in the list, until it is done and then continue with the flow chart

Using process modelling library for vessel sailing behavior in Anylogic

I want to use 'process modelling library' to mimic vessel movement from one point to another (because 'road traffic library' cannot realistically reflect the ship movement).
However, I am stuck at defining a way for speed control and keeping a safe distance between two vessels. What I want to achieve is the speed of each vessel (agent) should be restricted in a threshold [MaxSpeed,MinSpeed], and all the vessels should keep a safe distance/time with the vessels in front or behind. For example, if a vessel with speed 15 knots catches the vessel with speed 10 knots, it will change the speed to 10 knots before reaching the required safe distance/time.
Currently, what I am thinking is to set the agent speed at 'Source' block or 'MoveTo' block, and create a function to avoid collision. Does anybody know how the function will look like? I am very appreciate if any idea or comments, thanks!
Even though depending on your model there may be smart ways of doing this, I will show you a generic inefficient way of doing this in a very simplified way without deceleration or any fancy stuff.
It's a good idea to first set up a node in front of your boat as a safety distance:
I also added an event that will check if other boats are getting too close to the boat itself... so in the event you can have code like this that runs every minute for example:
for(Boat c : main.boats){
if(unsafeDistance.contains(c.getX()-getX(),c.getY()-getY())){
setSpeed(c.getSpeed());
break;
}
}
This code checks if there is any boat inside the safety node, and if there is one, the boat will instantaneously change its speed to the speed of the boat in front of it.
This code is ugly and inefficient, but if you want something better, you need to think about it yourself using the characteristics of your situation in order to make it better... but this solution should work using moveTo blocks from the Process modeling library.

Class Design: Car and Road

I'm trying to figure out the best way to design Car and Road objects for a game design I'm working on.
The idea is for AI Cars (as well as the Player controlled car) to recognize when they traverse dotted lines or straight lines on the Roads.
I'd like to be able to build a Variable Lane Road for Unity3D with the appropriate flags and sub objects so that the Cars recognize where they are and when and how they traverse or take turns etc' etc'
For example, a Road can have a single direction or be in both directions.
For each direction there can be a number of lanes. Lanes allow cars to overtake each other (meaning a dotted line between the lanes).
If it's a bi directional road, then there's a line between the two lanes - optionally and ideally, if there's more than one lane on any of the directions, then the line that separates the directional lanes is straight.
By default, there should be a flag that draws the line according to an isOvertakingAllowed boolean flag.
The most important part is that the Car objects need to know what lane they are on or if they are on a lane separating line, and what type this separation is (overtaking allowed or not).
That's the hard part, to me.
Any help is appreciated.
I would recommend you implement a Lane, which have a direction of travel. Then implement a Road which has a collection of points, a path defining it's shape, and distance, and a collection of Lane objects that follow that path. Whether the road is one-way or two-way becomes a matter of which, and how many lanes they have.
In this case, a Car travels on a Road in a given direction, following the lane that it's in. It can only switch to other lanes that have compatible directions of travel (i.e. that are heading in the same direction as the car), unless the car turns around.
You might also have a special point in a Road called an Intersection which is a connection point for multiple Lanes, and somehow specify which Lanes a Car can transition to and from when it's at the Intersection.
That's a rough outline, but I think those are the basic relationships between the objects that you present, and should get you started.
There is an article on gamasutra with description of the model that was used for opencity, and how the different agents (standard car, racing car, pedestrian...) could use it. It may gives you some pointers or ideas.