OR-Tools: Ensure group of nodes is visited by vehicles from the same depot - or-tools

I would like to use OR-Tools to solve a CVRP where each node has a label, and all the nodes that have the same label have to be visited by vehicles that originate from the same starting location. It does not matter which this starting location is, the only requirement is that it is the same for all the nodes with the same label. Is there a way to model this using the routing library?

I suggest the use of "SetAllowedVehiclesForIndex" method.

Related

How can I take the closest resources to specific stations from ResourcePool?

I'm simulating a manufacturing process. The stations need a variable number of ResourcePool "workers". Let's say there are 5 workers for 4 stations, and I want to simulate that those workers can work indifferently in any of the stations.
The problem is that they are not working in the closest station. Oppositely, even when a worker is next to the station, maybe the furthest worker goes until this station which needs the resource, and then the process starts. Obviously, this is inefficient and doesn't represent the reality.
I already have the workers defined, their shifts, their timetables, etc. I have tried to use the function getNeartestAgent() in 'Customize request choice', but it doesn't work. I also tried to calculate the distance of each agent with getDistance(), but I don't know how to manage it and I'm sure it must be a simpler solution even when I'm not working on GIS.
[31/08/22]
Recently I tried to develop a similar model, and I still have the same problem. The model consists of 3 stations which need 1 unit of ResourcePool. In this pool, there are 2 units. This units are agent type Operario. So, I need to choose the closest unit to the station. I tried several things, the following are just some...:
Service blocks -> Resource selection -> "Nearest to the agent". The agent is the material item, so the unit should go to the closest agent being treated in the station. However, it didn't work (units where to any station indeferently).
Service blocks -> Resource selection -> "Unit with top rating". The Unit rating field was 1/distanceTo(node1.getXYZ()). It didn't work either.
Stations (instead of Service blocks) -> Customize resource choice -> Resource choice condition. I can't stablish a boolean variable related to the unit position, as I can't compare among them.
Function. I can't compare units from ResourcePool, as they are detected as Agent and not as Operario.
ResourcePool. I tried to stablish the priority based on the distance to a certain node. But then I can't call these agents (Operario) from the station. It seems here I can only refer to material items, eventhough I write "unit.(...)".
Does anyone know how can I choose the closest resource to the station in which the task is performed? Should be through Customize resource choice -> Resource choice condition, but I don't know how!
when you use a service or seize block, in the advanced properties, there's an option called "Resource Selection"
You have to choose "Nearest to the agent"
If this doesn't work, it might mean that a resource that is close by and not selected, might be actually busy with something else... you have debug your model in order to be sure that it is not the case.

How to dynamically change the capacity of a Static Resource in AnyLogic

I’m working with a AnyLogic simulation on emergency department. The departments leader want to test the benefits of adding, nurses, treatments room etc. It was easy to make it so that they can dynamically change the number of nurses through the GUI, as this is a "Moving" resource type. However, how can I dynamically change a Static resource type like ED-rooms which is tied to specific Network Nodes?
It's not that I want the resource pools to be dynamically created. But it's that I want to control how big of a portion of the existing resource pool that will be used. The current capacity is 13 rooms, and I want this to be varied from 13 to 28
Using get_Capacity(n) works for non-static resources such as Nurses etc. but when I use .set_Capacity(n) for a Static Resource I get the following error:
"(ECRoom is here referring to rooms in the emergency department): java.lang.RuntimeException: root.ECRoom: Capacity definition type should be 'Direct' to support this operation"
The easiest way is to just pre-define several ResourcePool elements with static ED rooms linked to whatever node they would be using.
Then, set their normal capacity to zero and only change it to some non-zero value if the user wants it.
If you simply need to change the capacity at runtime, myResourcePool.set_Capacity(someNumber) is your friend :)
(Dynamically creating resource pools, home nodes, etc. is all possible but a whole different ball-game)

Avoiding collisions with other objects while moving an Agent to a specific destination

I have in my model some free-moving agents, which travel to specific nodes. I use the function...
moveTo(node)
...to specify the node an agent should visit. Using this function, the agent travels the shortest path to the node. However, the model layout contains areas (i.e. image files), which the agent should not pass. Right now, the agents may travel through these areas to reach their destination. Now I'm wondering, whether there is an easy way to permit an agent to enter specific areas in the model, when traveling to a node.
I already took a look at the example model "Wandering Elephants" where the elephants are permitted to walk through areas with water. The solution there is, that if an elephant meets water in the direction it's currently heading, it randomly searches for another direction, until it finds one without water. However, this approach doesn't really fit to my problem, as the elephants in the model wander around without any specific destination. I'm searching for a method, which works for an agent that travels to a specific point. In the best case, the agent would search the shortest path around the obstacle to reach its destination.
Edit 1: The following figure shows my problem in a nutshell. On the left side is my model structure, while on the right side the state chart of my custom agent. What is happening in the model: The 3 sources are producing agents, which will be delayed for an uncertain time (delay stops with stopDelay()). Everytime an agent enters a delay, the delay is added to the collection request. My customagent check requests in a loop until the collection contains at least one request. Then, the customagent randomly selects a request (i.e. delay object) to serve. Each delay is associated with a node (the collection processNodes maps delays to nodes). Now, I want to cast my customagent to a Transporter and move it to the corresponding node. The agent should avoid collisions with the stripped walls in the model. I want to avoid any seizing and releasing of resources. I just want to adapt the behaviour of the Transport agent from the material handling library to my agent.
Edit 2:
In my current testbed, my custom agent does not consider node 1 or node 2. For testing, the agent should only try to reach node without any collisions.
I found a sufficient work-around. Not exactly what I wanted, but it works. Against my initial intention, I use now seize and release for transports. However, I added a hold-block in front of each seized-block and only a resource, which decides to serve the process, is able to unblock the corresponding hold. The on-enter control of the unblocked hold ensures that the hold is directly blocked again as soon as a single agent flows through. For the case that other users are also interested in the solution, I attached the flow-chart of the process and the state-chart of the Transporter-Agent. The system structure is quite the same as in my initial question.
There is no build-in way unless you use transporters from the Material handling library (or pedestrians). These can do what you need.
So easiest might be to convert you agents to transporters temporarily.
Otherwise, you will have to code something yourself...

How to watch for creation of nodes two levels down using Apache Curator?

My goal is, given a CuratorFramework that is decorated with a path to a root node, and a String, to watch for events two levels down any path to that String.
More specifically, I would like to watch for events on any path ROOT/<anything here>/INPUT_STRING. I also need to watch for nodes being added in the middle layer, but I am not interested in the contents of those middle nodes (only that they appeared, so I can watch for a child to be created for the INPUT_STRING).
My idea was to create a NodeCache for each path to ROOT/<added middle node>/INPUT_STRING whenever a middle node is added. I thought I could then watch for middle nodes being added using a PathChildrenCache, but that seems like overkill since I'm not interested in the contents of the middle nodes.
Is there some better way to create a NodeCache for the INPUT_STRING two levels down? Or should I be using a PathChildrenCache, even though I don't care about the contents of the middle nodes?
You can use TreeCache to cache/watch/listen to a tree of ZNodes. I believe that will do what you need. http://curator.apache.org/curator-recipes/tree-cache.html

Change osm bonus pack input file

I am using osmbonuspack library in my project to find the route between a departure and a destination node and I want to save information related to the traversal time of the edges. So I keep a file which contains the nodes and edges of a specific city (OSM data). My problem is that for a specific route, osmbonuspack returns a road that doesn't agree with my file. I mean that when I search for two nodes of the route in my file, they exist, but there isn't an edge between them, while osmbonuspack has found an edge between them.
I know that this may is happening because I keep information only for a city, so this edge in my file is probably split into more nodes and edges.
But is there any way that I can change an input file or url in osmbonuspack so that it searches for a route in my .osm file?
No way: OSMBonusPack only provides access to online route services.
For offline routing using local map files, you can try GraphHopper Android.