Best Way to Determine if Address is in NY Tri State Area - geo

I'm working on a coding problem where I potentially need to flag any locations in user entered addresses that are in the NY Tri-State area.
Unfortunately I'm not that familiar with the US addressing system, so I'm not sure of the best way to start.
Other than using a geoshape and checking if the lat/longs of the locations fall within the shape, is there a simpler/more efficient way of checking if a US address is in that area?

Related

First Fit Decreasing Algorithm on CVRP in Optaplanner

I am using the FFD Algorithm in Optaplanner as a construction heuristic for my CVRP problem. I thought I understood the FFD-Alg from bin picking, but I don't understand the logic behind it when applied in OP on CVRP. So my thought was, it focuses on the demands (Sort cities in decreasing order, starting with the highest demand). To proof my assumption, I fixed the city coordinates to only one location, so the distance to the depot of all cities is the same. Then I changed the demands from big to small. But it doesn't take the cities in decrasing order in the result file.
The Input is: City 1: Demand 16, City 2: Demand 12, City 3: Demand 8, City 4: Demand 4,
City 5: Demand 2.
3 Vehicles with a capacity of 40 per vehicle.
What I thougt: V1<-[C1,C2,C3,C4], V2<-[C5]
What happened: V1<-[C5,C4,C3,C2], V2<-[C1]
Could anyone please explain me the theory of this? Also, I would like to know what happens the other way around, same capacities, but different locations per customer. I tried this too, but it also doesn't sort the cities beginning with the farthest one.
Thank you!
(braindump)
Unlike with non-VRP problems, the choice of "difficulty comparison" to determine the "Decreasing Difficulty" of "First Fit Decreasing", isn't always clear. I've done experiments with several forms - such as based on distance to depot, angle to depot, latitude, etc. You can find all those forms of difficulty comperators in the examples, usually TSP.
One common pitfall is to tweak the comperator before enabling Nearby Selection: tweak Nearby Selection first. If you're dealing with large datasets, an "angle to depo" comparator will behave much better, just because Nearby Selection and/or Paritioned Search aren't active yet. In any case, as always: you need to be using optaplanner-benchmark for this sort of work.
This being said, on a pure TSP use case, the First Fit Decreasing algorithm has worse results than the Nearest Neighbor algorithm (which is another construction heuristics for which we have limited support atm). Both require Local Search to improve further, of course. However, translating the Nearest Neighbor algorithm to VRP is difficult/ambiguous (to say the least): I was/am working on such a translation and I am calling it the Bouy algorithm (look for a class in the vrp example that starts with Bouy). It works, but it doesn't combine well with Nearby Selection yet IIRC.
Oh, and there's also the Clarke and Wright savings algorithm, which is great on small pure CVRP cases. But suffers from BigO (= scaling) problems on bigger datasets and it too becomes difficult/ambiguous when other constraints are added (such as time windows, skill req, lunch breaks, ...).
Long story short: the jury's still out on what's the best construction heuristic for real-world, advanced VRP cases. optaplanner-benchmark will help us there. This despite all the academic papers talking about their perfect CH for a simple form of VRP on small datasets...

Minimax and alpha beta use on board

I have a problem understading how does minimax actually work on board.
Let's suppose it's white turn. To get the best move possible do i need to apply minimax on every legal move generated by my move generator and then take the best score ?
Let's suppose now that i applied minimax on a single legal move of my pawn. As far as my understanding goes, minimax is a reccursive algorithm and now it will be applied to search the best move possible for the black side. At this point will it be applied on all the possible legal moves of the black side ?
If my understanding is wrong, would you please correct me using an exemple ?
Thank you
Let's suppose you are maximizer and your opponent is minimizer. I have painted some pictures below to explain how minimax works.
And now, suppose it is your turn, see the picture below.
From current state on the game board. You are trying to find the best move to get the best score for you, but it is depend on your opponent's choices so you have to assume that your opponent is going to the optimal moves to decrease your score as small as possible so that you can make your decision. So, at your opponent's turn, the opponent will chose the move that make your score as small as possible, so the graph will be as below:
Now, depend on the best moves that your opponent have generated, you can see that 2 is the best score which you can get (if your opponent is very optimal and intelligence). So you will chose the middle move.

Using GPS, How can i detect if user on road or inside a building

I am currently developing technique to help users find a spot to park.
But i face a little problem:
if a user indicates that he is parking right now in a free spot but he is lying and he is at home right now.
How can i detect from GPS if he is inside a building or along side the road?
Thanks
You'll need map data (OpenStreetMap is free), and figure out whether the user is somewhere on that map or not. You do that by comparing GPS data to the map data.
What I do in such situations is measure the distance between the lat/lon and each road, and compare the GPS angle to that of each line. The more context information you use the more accurate you can get your results:
If the speed is 60km/h, you're probably not in a building. You're probably not on a 30km/h road either.
If you're standing still for more than 2 minutes, you're probably not in a car.
If you know the buildings, and there are only a few of them, you could check if you see a certain wifi router or not.
Basically you'll calculate a score for each road, and then pick the road with the highest score to know where you are.
Score = DistScore*DistWeight + AngleScore+AngleWeight etc.
Also, from iOS and Android you get an accuracy in meters. You can also calculate that yourself if you can access raw GPS data. Using that, you set the area that you need to scan. For example, for a high accuracy (3m), you probably don't have many roads to scan. If the accuracy is 50m, you should probably match roads that are farther away.
If accuracy is important, you should look at series of GPS data, and test if the followed route is a logical path or not.

Hill Climbing and Tabu Search in OptaPlanner

I'm using OptaPlanner to solve some plannig problems. I read the documentation and I'm not quite sure how does exactly Hill Climbing and Tabu Search algorithms work. What I'm unsure of is:
does hill climbing pick only moves with THE BEST score that is BETTER than current one or does it allow to pick moves with THE BEST score that is NOT WORSE than the current one?
does tabu search allow picking moves that have WORSE score than the current one if there is no move leading to a solution with better or equal score to the current one?
For Hill Climbing, see HillClimbingAcceptor#isAccepted(...). It accepts any move that has a score that is better or equal to the lastest step score. And looking at the default forager config for hill climing (in LocalSearchPhaseConfig, which says foragerConfig.setAcceptedCountLimit(1);), as soon as 1 move is accepted, it is the winning move.
For Tabu Search, it will select moves that have a worse score, if:
in the number of moves it selects per step (usually acceptedCountLimit is configured to 1000 or so), no better move is seen
OR all the moves that do lead to a better score are in the tabu list (they are "taboo to use"). For solutionTabu, this means that there's a guarantee that they won't lead to a new best solution (but solutionTabu is useless). For entityTabu there is no such 100% guarantee, but you will get a better results in about 99.999999999999999999999999999999999999999999999999999999999999999% of the cases if you have more than let's say 50+ variables (and more if you have a 1000+ variables).
PS: Hill Climbing sucks. There's never a good reason to not use Late Acceptance or Tabu Search instead.
PPS: Use the Benchmarker, do let HC, LA, TS, ... fight against each other. It will give you a lot of insight.

Creating a program that takes GPS data and displays the current location on a geo-referenced image

My name is John and I am a grad student at the University of Florida. As part of my research one of my tasks is to create a piece of software that is to display a map of the surrounding area, which shows the current location (from a GPS), and to implement a shapefile (as a boundary outline). I am not able to really get enough information to get on the right track on how to do this, and would appreciate any assistance!
The project involves a large-scale robot that will be operated by tele-communication in rough terrain. So this mapping and gps software will need to be entirely offline, but the location in use will be known. It is very preferred to find a cost effective means to doing this process (maybe even a simple API that could do the simple task, dll libraries, or active x.
My initial guess is to use a geo-referenced image (that I would get the lat and long of and know the boundaries of that image). Then from a GPS I then would treat the image as an XY plot somehow and that would provide the current position. Obviously even this step can be a challenge depending on what kind of image, map, kml file, etc that I can find and use.
So I would appreciate any advice, suggestions, or comments.
Suggest you online reference source code, and then modify their own, this project is currently on the Internet, you can through search engines to find. Good luck!