OR-Tools: Difference between Path Cheapest Arc and Global Cheapest Arc - or-tools

The OR-Tools documentation (https://developers.google.com/optimization/routing/routing_options) for the VRP routing options describes the two first solution strategies the following way:
PATH_CHEAPEST_ARC: Starting from a route "start" node, connect it to the node which produces the cheapest route segment, then extend the route by iterating on the last node added to the route.
GLOBAL_CHEAPEST_ARC: Iteratively connect two nodes which produce the cheapest route segment.
Can someone explain me what the difference between the two heuristics is? Unfortunately I haven't found any other information on the internet or the documentation.

The first one grows a route by extending it.
The second one connect the closest nodes together until it creates routes.

Related

Can I call the HERE CalculateMatrix API with interim waypoints?

i am currently testing outh the HERE CalculateMatrix API. My goal is to get all possible routes and find out the shortest one. Now im asking myself the following question:
Is it possible to define interim waypoints that an Route has to pass?
And is it possible that the order that these waypoints are passed is not defined?
So that i have for example the starting point: A, interim points: B and C an the destination: D,
and the Matrix should then calculate the following possible Routes:
A-B-C-D,
A-C-B-D
so im not using different destinations but different waypoints in between
As Raymond already mentioned in comments, it is not possible to use Calculate Matrix API for a use case of "sortable" way-points. The Fleet Telematics API does provide something close, although it would only provide the most optimal route and not all possible routes. In the API, some way-points can be marked as "sort" which means their order is not fixed and the API would then find the most optimal route.
From API reference (https://developer.here.com/documentation/fleet-telematics/dev_guide/topics/waypoint-sort-pickup-opening-times.html)
Sorting Waypoints (Travelling Salesman Problem) Routing can find the
optimal sequence order for the waypoints. Activate this feature by
following waypoint parameters:
&waypoint1=...;sort
All sections of waypoints flagged with "sort" can be rearranged by the
router for cost optimization. For example, in the waypoint list of
WP0, WP1;sort, WP2;sort, WP3;sort, WP4, WP5;sort, WP6;sort, WP7 the
router can change the sequence order among WP1, WP2 and WP3, and it
can change the sequence order among WP5 and WP6. If the last waypoint
is "sort"able then the route may end at any of the sortable waypoints.
Use this if the driver does his overnight stay simply at/after the
last waypoint he visited throughout the day.
&waypoint1=...;before:3,5
Enforces that the route meets waypoint 1 before the waypoints 3 and 5.
Use it in combination with either "sort" or "optional".
&waypoint1=...;implies:4,8
Enforces that if waypoint 1 is part of the route then also waypoints 4
and 8 must be part of the route. Use it in combination with "optional"
waypoints.

How to find nodes within ways in Overpass QL?

I have a query which returns a number of ways. I want to find nodes matching certain criteria which appear within those ways. Note that the nodes I'm interested in do not form part of the way itself, but do appear within the bounds of the way. Also, the ways do not all have corresponding areas, so using the area search doesn't work in all cases.
I've got a minimal example which finds way 95677318, and I want to be able to find node 1552949334:
(
way({{bbox}})["man_made"="lighthouse"];
)->.searchArea;
/*doesn't work:*/
/*node(area.searchArea)["seamark:name"];*/
/*recur down and find node directly, just for the purpose of this question*/
(
.searchArea;>;
node({{bbox}})["seamark:name"];
);
out;
(Try it on https://overpass-turbo.eu/s/EpV)
This feature is not yet available as of release 0.7.55. In case there's no corresponding area available on the Overpass server, this kind of query is simply not feasible.
See https://github.com/drolbr/Overpass-API/issues/77 for details.

Apache Spark - Implementing a distributed QuadTree

I am really, really, new to Apache Spark.
I am working on implementing Approximate LOCI (or ALOCI), an anomaly detection algorithm, on a distributed way over Spark. This algorithm is based on storing points in a QuadTree that is used to find a point's number of neighbors.
I know exactly how QuadTrees work. In fact, I have implemented such a structure in Java recently. But I am completely lost as far as it concerns the way that such a structure can work in a distributed way over Spark.
Something similar to what I need can be found in Geospark.
https://github.com/DataSystemsLab/GeoSpark/tree/b2b6f1d7f0015d5c9d663a7b28d5e1bb1043c413/core/src/main/java/org/datasyslab/geospark/spatialPartitioning/quadtree
GeoSpark uses in many cases a PointRDD class, that extends a SpatialRDD class which I can see that uses the QuadTree that can be found in the link above to partition the Spatial objects. That is what I understood, at least, in theory.
In practice, I still cannot figure this out. Let's say for example that I have millions of records in a csv and I want to read and load them in a QuadTree.
I could read a csv to an RDD, but then what? How does this RDD logically connects to the QuadTree I am trying to build?
Of course, I don't expect a working solution here. I just need the logic here to fill the gap in my mind. How do I implement a distributed QuadTree and how do I use it?
Ok, sadly there are no answers to this, but here I am two weeks later with a working solution. Not 100% sure if it is the right approach here, though.
I created a class named Element and turned each line of my csv to an RDD[Element]. I then created a serializable class named QuadNode which has a List[Elements] and an Array[String] of size 4. On adding elements to a node, these elements are added in the node's List. If the list get more than X elements (20 in my case), the node breaks into 4 children and the elements are sent to the children. Finally, I created a class QuadTree which has an RDD[QuadNodes] among its rest properties. Every time a node breaks to children then these children-nodes are added in the tree's RDD.
In a non-functional language, each node would have 4 pointers, one for each child. Since, we are in a distributed environment this approach could not work. So, I gave each node a unique Id. Root node has an id = "0". Root's nodes have ids "00", "01", "02" and "03". Node-"00" children have ids "000","001","002","003". In this way if we want to find all the descendants of a node, we filter our tree's RDD[QuadNode] by checking if nodes' ids startWith out node id. Reversing this logic helps us to find a node's parent node.
This is how I implemented my QuadTree, at least for now. If someone knows a better way of implementing this I would love to hear his/her opinion.

Identify crossroad nodes in openstreetmap data (.pbf)

does anybody know if there is a way I can seperate only the crossroad nodes which are included in a .pbf file? Is this clue (if a node is crossroad or not) included in this file's format?
Another option to solve your issue would be to use the new Atlas project.
As part of loading .osm.pbf files into in-memory Atlas files, it takes care of doing way sectioning on roads:
Load your pbf file into an Atlas. You will then have an Atlas object that you could save to a file and re-use.
Use the Atlas APIs to access all the intersections
In the end, each Atlas Node which is connected to more than 4 Edges on a two-way road or 2 Edges on a one way road would be a candidate if I understand your question correctly.
I'm not aware of a ready-made solution for this task, but it should still be relatively easy to do.
For parsing the .pbf file, I recommend using an existing library like Osmosis or Osmium. That way, you only need to implement the actual semantics of your use case.
The nodes themselves don't have any special attributes that mark them as crossroads. So instead, you will have to look at the ways containing the nodes.
Some considerations when implementing this:
You need to check the way's tags to find out whether it's a road. The most relevant key for that is highway. The details depend on your specific use case – for example, you need to decide whether footways, forestry tracks, driveways, ... should count.
What matters is the number of connecting way segments at a node, not the number of ways. For example, a node that is part of two ways may be a crossroads (if at least one of the ways continues beyond that node), or may not (if both ways start/end at that node).

Is it possible to connect two separate nodes by two links?

I am wondering if it is possible to do this as I am trying to build a traffic simulation model and may need to utilise this feature , should it exist, in my model.
There two, and only two, conditions under which a pair of turtles may be connected by more than one link:
If the links are directed, you can have two links, going in opposite directions.
If the links are different breeds.
You might consider alternatives like having a single link but adding a links-own variable to the links containing a weight, count, or other information.