Metal Extractor Placement
Posted: 10 Jan 2006, 07:33
Krogothe provided a decent, clean class for metal extractor placement, but I got to thinking it wasn't the optimal solution. I'm not sure where I'm going to go with this, but I'll begin by explaining why I think Krogothe's solution (while a decent approximation) is non-optimal.
Krogothe uses a greedy algorithm finding the spot on the map with the highest metal area concentration (add each metal-pixel in extractor radius to find metal area concentration). It marks the point as the first 'best metal spot' then reduces all nearby metal concentrations as if a metal extractor was placed there before repeating the process until no spots remain or N such spots have been found. In summar, the algorithm picks out the largest spot, then the next largest, then the next, and so on.
This works - to a degree. For one, it fails to handle metal maps very well. Dealing with them isn't too hard however - the mathematical solution to 'circle packing' (2 dimensional spheres, actually) provides the optimal solution for stuffing the maximum number of constant-sized circles in a given size square (ie, our map).
What the greedy algorithm fails to account for are situations where it is NOT best to gobble up the best concentration, but rather split that concentration up over 2 or more metal extractors. For example, suppose we're playing a map with an oval section of metal that grows denser towards the center (ie, sparse outside, dense inside). Krogothe's algorithm will take the middle of this concentration (which is the most short-term efficient). This deplets the metal from the edges and now they may not be half as good as they would have been had one placed two metal extractors at the 1/3 and 2/3 points in circle width (long-term efficient).
What we're looking for here seems to fall under the mathematical 'covering problems'. I found some PhD-level resources on covering all the dots with a minimal circle and a rad looking Optimal location of a mining facility, but I'm not $40 worth of interested in this problem (also, I'm aware it is taking about factors other than what we're discussing). Wikipedia has some interesting information as well, but nothing concretely describing how to solve this type of problem. Fundamentally, we can think of the problem as, 'what is the maximum economic value for covering a set of weighted points using n-radius circles (circle has a cost, each point has a value).' This allows us to view the income rates as either short-term (30 seconds), medium-length (10 minutes), or long-term (3 days). In the first case, a greedy algorithm will probably be quite effective (though, perhaps, non-optimal). In the second, we're looking at maximizing economic value for the cost of each metal extractor. In the last case, we're looking to cover every single point of metal.
Given that Krogothe's algorithm should be good for the short-term case and sphere-packing covers the long term (expanded to an arbitrary bounding volume), I'm not quite sure how to solve the middle case. Any guesses?
Krogothe uses a greedy algorithm finding the spot on the map with the highest metal area concentration (add each metal-pixel in extractor radius to find metal area concentration). It marks the point as the first 'best metal spot' then reduces all nearby metal concentrations as if a metal extractor was placed there before repeating the process until no spots remain or N such spots have been found. In summar, the algorithm picks out the largest spot, then the next largest, then the next, and so on.
This works - to a degree. For one, it fails to handle metal maps very well. Dealing with them isn't too hard however - the mathematical solution to 'circle packing' (2 dimensional spheres, actually) provides the optimal solution for stuffing the maximum number of constant-sized circles in a given size square (ie, our map).
What the greedy algorithm fails to account for are situations where it is NOT best to gobble up the best concentration, but rather split that concentration up over 2 or more metal extractors. For example, suppose we're playing a map with an oval section of metal that grows denser towards the center (ie, sparse outside, dense inside). Krogothe's algorithm will take the middle of this concentration (which is the most short-term efficient). This deplets the metal from the edges and now they may not be half as good as they would have been had one placed two metal extractors at the 1/3 and 2/3 points in circle width (long-term efficient).
What we're looking for here seems to fall under the mathematical 'covering problems'. I found some PhD-level resources on covering all the dots with a minimal circle and a rad looking Optimal location of a mining facility, but I'm not $40 worth of interested in this problem (also, I'm aware it is taking about factors other than what we're discussing). Wikipedia has some interesting information as well, but nothing concretely describing how to solve this type of problem. Fundamentally, we can think of the problem as, 'what is the maximum economic value for covering a set of weighted points using n-radius circles (circle has a cost, each point has a value).' This allows us to view the income rates as either short-term (30 seconds), medium-length (10 minutes), or long-term (3 days). In the first case, a greedy algorithm will probably be quite effective (though, perhaps, non-optimal). In the second, we're looking at maximizing economic value for the cost of each metal extractor. In the last case, we're looking to cover every single point of metal.
Given that Krogothe's algorithm should be good for the short-term case and sphere-packing covers the long term (expanded to an arbitrary bounding volume), I'm not quite sure how to solve the middle case. Any guesses?