Path finding in real world maps with custom valuation function - algorithm

Description:
Our customer interested in logistics wants automated path finding for his business. The issue is that each city, harbor, state, and country has different legal system with different politics for various goods. For example, some goods are forbidden to be transported through the country or fee applies on others, etc.
Intention:
For a given transport of particular goods I need to find the best possible route with a respect to the known politics. If no such route exists, I have to find several the less problematic alternatives.
Questions:
I believe that custom weights of nodes and edges in the graph disqualifies the public maps APIs. The quick search I made showed that no well-known API accepts custom valuation function. Am I right?
I thought that the path finding over custom graph is quite simple even with the custom valuation function. On the other hand, the real world maps are such a giant graph that only thinking about application of conventional algorithms seems silly. Should I think about this solution or is that too complicated and I should look at some other options?
The only thing I can think of to be possible is something like OSPF algorithm - divide the world into regions with their politics and then find the routes only through the possible regions. For these routes for each region find routes through states, etc. That means dynamically change granularity based on the supported geographical objects (countries, states, cities, ...) and slowly converge to the highest granularity, i.e., streets. The bad side of this approach is that it requires a lot of programming as well as lot of computation. Furthermore, I am not sure if maps with such granularity exist and are publicly available. Is this wrong way of thinking or is this too complicated?
What are other options? I could not figure out anything else.

Related

Exponential Random Graphs: nodematch() and nodefactor() in R

I have been reading on the web about the Exponential Random Graph modelling for network analysis and I am confused about one aspect. Do I need to add in the model the corresponding nodefactor() for each nodematch() term? Some people would say that: "Nodematch and absdiff are homophily terms – how similar are the two nodes – so in a sense it’s an interaction, say, of both the sender and the receiver being female. You therefore also want the overall effect of, say, being female, so your homophily term isn’t just picking up that women tend to send and receive more ties overall". Is this correct?
The thing is, I have seen many people running ERGM models without including both nodefactor() and nodematch() for the same term. I am just interested in understanding if it is ALWAYS NECESSARY to have both nodefactor() and nodematch() in the model. Or, in contrast, if I run a model containing only the nodematch() term (and this is statistically significant), are the results reliable (can I be sure that the results are not just picking up that certain categories tend to send and receive more ties overall?)?
Looking forward to receiving your answers.
Thank you!

Dividing the world in a thousand or so locations

Background: I want to create a weather service, and since most available APIs limit the number of daily calls, I want to divide the planet in a thousand or so areas.
Obviously, internet users are not uniformly distributed, so the sampling should be finer around densely populated regions.
How should I go about implementing this?
Where can I find data regarding geographical internet user density?
The algorithm will probably be something similar to k-means. However, implementing it on a sphere with oceans may be a bit tricky. Any insight?
Finally, maybe there is a way I can avoid doing all of this?
Very similar to k-mean is the centroidal Voronoi diagram (it is the continuous version of k-means). However, this would produce a uniform tesselation of your sphere that does not account for user density as you wish.
So a similar solution is the same technique but used with a Power Diagram : a Power Diagram is a Voronoi Diagram that accounts for a density (by assigning a weight to each Voronoi seed). Such diagram can be computed using an embedding in a 3D space (instead of 2D) that consists of the first two (x,y) coordinates plus a third one which is the square root of [any large positive constant minus the weight for the given point].
Using that, you can obtain a tesselation of your domain accounting for a user density.
You don't care about internet user density in general. You care about the density of users using your service - and you don't care where those users are, you care where they ask about. So once your site has been going for more than a day you can use the locations people ask about the previous day to work out what the areas should be for the next day.
Dynamic programming on a tree is easy. What I would do for an algorithm is to build a tree of successively more finely divided cells. More cells mean a smaller error, because people get predictions for points closer to them, and you can work out the error, or at least the relative error between more cells and fewer cells. Starting from the bottom up work out the smallest possible total error contributed by each subtree, allowing it to be divided in up to 1,2,3,..N. ways. You can work out the best possible division and smallest possible error for each k=1..N for a node by looking at the smallest possible error you have already calculated for each of its descendants, and working out how best to share out the available k divisions between them.
I would try to avoid doing this by thinking of a different idea. Depending on the way you look at life, there are at least two disadvantages of this:
1) You don't seem to be adding anything to the party. It looks like you are interposing yourself between organizations that actually make weather forecasts and their clients. Organizations lose direct contact with their clients, which might for instance lose them advertising revenue. Customers get a poorer weather forecast.
2) Most sites have legal terms of service, which must clients can ignore without worrying. My guess is that you would be breaking those terms of service, and if your service gets popular enough to be noticed they will be enforced against you.

Tools/recommendations to create and check if address falls within a specified boundary on a map?

Abstract problem: Define some (non-rectangular, non-circular) topologically closed area on a map. Find out way to query that map such that it returns true if longitude/latitude within the boundary.
Applied problem:
Let's say we're dealing with newspaper boy coverage. A coverage area is defined for each newspaper boy, and I query each house address to find who services what address.
I am looking for suggestions/hints/tips on how best to do this (real world, so helpful APIs and tools would be much appreciated).
So, first defining a boundary, then allowing for an address to query for membership within a specific boundary.
We have a mapping software at work where we implemented this exact problem (obviously in a different domain than paperboy coverage). We could not find an out of the box solution, so we implemented our own.
We solved this problem by defining the geographical areas as set of points (given in latitude and longitude) and used the ray-casting point in polygon method.
http://en.wikipedia.org/wiki/Point_in_polygon
The math is not too complex, but there is a fair bit of setup work involved.
A quick google search brought up this sample code for implementation:
http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html#The%20C%20Code
Good luck! I would be happy to clarify anything if needed.

Routing algorithm for multiple vehicles with multiple drops

I'm looking to find/create a routing algorithm that can be used to manage multiple vans performing deliveries as well as the loads of each of those vans.
Here's a rough specification of what I'm looking for..
The routes should be calculated in a fast and efficient manner
100+ vans / 1000+ packages / 1000+ dropoff points could be processed in one go
Each van could be a different size and have different weight restrictions
Each package could be a different size and weight
The packages should be organised onto the vans in a fair and economical manner, taking into account the routes, weight and size restrictions
The routes the vans should take should be economical and as short as possible (or a configurable balance between the two)
Vans could be limited to certain roads (low bridges, width, height and weight restrictions)
Some packages may be given timeslots for delivery
Has anyone seen this sort of thing before, and if so, any ideas as to what algorithm could be used to do this, or an example of how it could be done? I've seen a few university papers but they're quite old (probably fairly inefficient now) and don't handle the package management - they just presume all the vans and packages are the same size.
Any thoughts would be appreciated!
Rich
My impression is that this kind of problem routinely comes up in Operations Research, and the standard approach is to use a mixed integer programming solver. Here's an example of encoding a cargo shipping scheduling problem using MIP
Apparently 15 years of recent research in MIP made modern solvers 30,000 times faster than original ones.
If you want to make a solution from scratch, you could start by figuring out what your objective and constraints are, and then use some ideas from integer programming, like approximate branch-and-bound search.
pgRouting has a new function implementing a genetic algorithm for the Dial-a-Ride Problem: http://www.pgrouting.org/docs/1.x/darp.html
It's an extension of PostgreSQL/PostGIS and you can build an application with this. It also has functions for shortest path search, etc.
Any algorithm this specific is going to be proprietary and you will probably need to buy something. However, this sounds suspiciously like a problem that could be solved with a genetic algorithm implimentation. Here is some research I found:
http://www.ijimt.org/papers/38-M415.pdf
http://www.springerlink.com/content/w3165x33n24v8610/ (A book that looks like its focused on your problem)
http://www.computer.org/portal/web/csdl/doi/10.1109/ICCIT.2008.407
Just because an algorithm is old, doesn't mean its not efficient.

What type of technology do airlines use for booking tickets?

I have always been fascinated by the algorithm airlines use when we book the tickets. I am an undergraduate CS student and I am really interested in knowing how this works. For example, how does it figure out connecting flights? How does the fare allocation work?
Is it all handled by a single company or each airlines uses its own system?
If you can point me to some links to read, it would be wonderful.
I don't have any specific literature to point to, but to help get you thinking about the various problems, here are a few thoughts.
You can think of the airline network as a huge graph, with cities at the nodes and flights as edges. There's an edge between two cities if there is a connecting flight. Now, you can ascribe various weights to these edges, such as the time of flight, the minimal ticket cost, the number of remaining seats, etc. and use graph algorithms like Dijkstra's or A* to optimize on your metric of choice. Since there are likely to be multiple flights connecting the same cities at different times/prices/etc., you'll likely have to iterate these algorithms to find compatible itineraries (e.g. layovers not too short/long) etc. But fundamentally, these are graph algorithms.
Pricing is a highly complex endeavour and whole branches of Operations Research are devoted to it. Unlike routing, pricing is essentially a game--the service provider (airline) is trying to maximize revenue globally (not just for single flights), and so they have to balance passenger loading vs. ticket costs. Airlines have incredibly complex pricing structure, where the cost for a given seat varies dramatically with time, and may be wildly different than the cost for the seat right next to it, particularly depending on if is sold to a business or pleasure traveler.
The big name in airline reservation systems used to be SABRE. I don't know if that's still true, but they do seem to still be a major player.
Good luck & happy reading.
This is regulated via IATA
http://www.iata.org/Pages/default.aspx
http://en.wikipedia.org/wiki/International_Air_Transport_Association
Scheduling standards are maintained by this org too
http://www.iata.org/whatwedo/passenger/scheduling/Pages/index.aspx
Almost all travel sites use ITA software, who provide a service that does flight planning and search. They have an excellent annotated presentation on the 'Computational Complexity of Air Travel Planning', which describes the challenges involved, and how they deal with them.
I am not so familiar with the domain but I know airline booking is a fairly complex process with multiple parties involved. I did some quick search and found this useful presentation.

Resources