Optimizong billboard placement - optimization

I have a table of a 18,000 billboards with an ID, latitude, longitude, Impacts(the amount of people that see the billboard in a month).
ID
Latitude
Longitude
Impacts
1
107.45
92.45
200,000
2
102.67
96.67
180,000
3
105.12
94.23
160,000
4
106.42
91.87
220,000
5
109.89
93.56
240,000
The idea is I want to build a model that optimizes for a maximum amount of impacts, keeping a minimum distance between each billboard, for an amount of billboards chosen by the user.
I can build a matrix with the linear distances of each billboard to all the others, so basically I have the value that I want to maximize which are the impacts, a distance matrix which has linear distances between each billboard which is a constraint and the amount of billboards to select which is another constraint.
does anyone know a sort of linear programming model that I could implement for this specific case?

Related

How to find Lagrange Multiplier word problem constraint and objective function?

What would the objective and constraint be in this word problem?
A company manufactures x units of one item and y units of another. The total cost in dollars, C, of producing these two items is approximated by the function C=6x^2+3xy+7y^2+900.
If the production quota for the total number of items (both types combined) is 220, find the minimum production cost.

Postgres/postgis. Find all points so that no two points are within X units of each other

I have a sql table containing approx 46,000 rows of Zipcode and its center lat/lng for cities in the US.
I am wanting to run a query where the resulting set contains a table of points however, all points are at least X units away. Basically am able to map an area where no two circles (a lat/lng with a radius of X units) intersect.

Accuracy for points within distance of 5km

What are the precision characteristics of Google S2 for let’s say two indexed points which are within a radius of 5km? What kind of precision can I expect in mm for a query for these points?
It depends on the S2 level on which you've indexed these points. Not all cells on a given level are the same size, but on average they'll all be close.
For example, a level 30 cell (smallest level) is on average 74 mm^2, so it's very precise.
You can see a reference here.

Fair Allocation to Buckets with Constraints

I have a vector with n prices(p1,p2,...,pn).
I want to allocate these into 3 buckets A,B,C such that the average of all the prices in each bucket is as close as possible. The constraint will be that each basket has a different number of prices put into it.
Using R I've tried to MIN the squared difference between the prices in each bucket, but I'm not getting the correct results.
Am I approaching this correctly?
So the way I approached it was I had a vector:
x<-c(50,50,50,10,20,40,50,20,4,40,20)
And I want to Minimise
A<-|(0x[0]+1x[1]+0x[2]+0x[3]....) - allocation * average price |^2
B<-|(0x[0]+1x[1]+0x[2]+0x[3]....) - allocation * average price |^2
C<-|(0x[0]+1x[1]+0x[2]+0x[3]....) - allocation * average price |^2
To get the square differences from the average
Such that each bucket is either allocated or not allocated that specific price.
The constraints would be the allocations of A, B, C would be say 10 to A 5 to B and 12 to C.

Oracle SQL query or function to cluster geographic data

I have a table containing geographic data and I want to group rows on the proximity of the X and Y coordinates. So, given an offset, n, and a table with columns X and Y, I want to group rows where ABS(row1.X - row2.X) < n, with a count of the number of rows in the group. Is this possible with SQL or do I need a function?
How big is your spatial range ? How big is your data set ? How accurate do you need ?
This is relevant because, if they are close, you don't have to worry about the curvature of the Earth.
Degrees of latitude are parallel so the distance between each degree remains almost constant but since degrees of longitude are farthest apart at the equator and converge at the poles, their distance varies greatly.
Each degree of latitude is approximately 69 miles (111 kilometers) apart. The range varies (due to the earth's slightly ellipsoid shape) from 68.703 miles (110.567 km) at the equator to 69.407 (111.699 km) at the poles. This is convenient because each minute (1/60th of a degree) is approximately one mile.
A degree of longitude is widest at the equator at 69.172 miles (111.321) and gradually shrinks to zero at the poles. At 40° north or south the distance between a degree of longitude is 53 miles (85 km).
The other aspect is, if Fred is 4 miles from Bill and Bill is 4 miles from Tom, the distance between Fred and Tom might be 8 miles. If your proximity threshold is 5 miles, Bill and Fred are in the same group, Bill and Tom are in the same group, but Fred and Tom aren't.
The following query might give you a useful start though:
select abs(abs(a.lat) - abs(b.lat)),abs(abs(a.lon) - abs(b.lon)),
sdo_geom.sdo_distance(a.geom, b.geom, 0.005,'unit=kilometer') dist_km
from
(select sdo_geometry(2001,8314,sdo_point_type(33,151, null), null,null) geom, 33 lat, 151 lon from dual) a,
(select sdo_geometry(2001,8314,sdo_point_type(34,151, null), null,null) geom, 34 lat, 151 lon from dual) b
Do you have oracle spatial? If so there are a number of built in functions to handle this for you. If not - you'll need a function to determine catographic distances (and then group off of that). I recall seing a SO question on how to write such a function last week. (There are actually a few along these lines)
How to limit a MySQL Distance Query
Best bet. Use the spatial extensions. They'll perform much better.