Parametric search
{{Short description|Algorithmic optimization method}}
{{Distinguish|Faceted search}}
In the design and analysis of algorithms for combinatorial optimization, parametric search is a technique invented by {{harvs|first=Nimrod|last=Megiddo|year=1983|authorlink=Nimrod Megiddo|txt}} for transforming a decision algorithm (does this optimization problem have a solution with quality better than some given threshold?) into an optimization algorithm (find the best solution). It is frequently used for solving optimization problems in computational geometry.
Technique
The basic idea of parametric search is to simulate a test algorithm that takes as input a numerical parameter , as if it were being run with the (unknown) optimal solution value as its input. This test algorithm is assumed to behave discontinuously when , and to operate on its parameter only by simple comparisons of with other computed values, or by testing the sign of low-degree polynomial functions of . To simulate the algorithm, each of these comparisons or tests needs to be simulated, even though the of the simulated algorithm is unknown.
To simulate each comparison, the parametric search applies a second algorithm, a decision algorithm, that takes as input another numerical parameter , and that determines whether is above, below, or equal to the optimal solution value .
Since the decision algorithm itself necessarily behaves discontinuously at , the same algorithm can also be used as the test algorithm. However, many applications use other test algorithms (often, comparison sorting algorithms). Advanced versions of the parametric search technique use a parallel algorithm as the test algorithm, and group the comparisons that must be simulated into batches, in order to significantly reduce the number of instantiations of the decision algorithm.
=Sequential test algorithm=
In the most basic form of the parametric search technique, both the test algorithm and the decision algorithms are sequential (non-parallel) algorithms, possibly the same algorithm as each other. The technique simulates the test algorithm step by step, as it would run when given the (unknown) optimal solution value as its parameter . Whenever the simulation reaches a step in which the test algorithm compares its parameter to some other number , it cannot perform this step by doing a numerical comparison, as it does not know what is. Instead, it calls the decision algorithm with parameter , and uses the result of the decision algorithm to determine the output of the comparison. In this way, the time for the simulation ends up equalling the product of the times for the test and decision algorithms. Because the test algorithm is assumed to behave discontinuously at the optimal solution value, it cannot be simulated accurately unless one of the parameter values passed to the decision algorithm is actually equal to the optimal solution value. When this happens, the decision algorithm can detect the equality and save the optimal solution value for later output.
If the test algorithm needs to know the sign of a polynomial in , this can again be simulated by passing the roots of the polynomial to the decision algorithm in order to determine whether the unknown solution value is one of these roots, or, if not, which two roots it lies between.
An example considered both by {{harvtxt|Megiddo|1983}} and {{harvtxt|van Oostrum|Veltkamp|2002}} concerns a system of an odd number of particles, all moving rightward at different constant speeds along the same line. The median of the particles, also, will have a rightward motion, but one that is piecewise linear rather than having constant speed, because different particles will be the median at different times. Initially the particles, and their median, are to the left of the origin of the line, and eventually they and their median will all be to the right of the origin. The problem is to compute the time at which the median lies exactly on the origin.
A linear time decision algorithm is easy to define: for any time , one can compute the position of each particle at time and count the number of particles on each side of the origin. If there are more particles on the left than on the right, then
Using this decision algorithm as both the test algorithm and the decision algorithm of a parametric search leads to an algorithm for finding the optimal time
Thus, the simulation ends up running the decision algorithm on each of the particle crossing times, one of which must be the optimal crossing time.
Running the decision algorithm once takes linear time, so running it separately on each crossing time takes quadratic time.
Megiddo remarks that, for this specific problem, there exists a simple linear time algorithm that does not involve parametric search: just determine the time at which each particle crosses the origin and return the median of these times. However, he explains that parametric search often matches the best known running time or gives the fastest known algorithm for more advanced problems.
=Parallel test algorithm=
As {{harvtxt|Megiddo|1983}} already observed, the parametric search technique can be substantially sped up by replacing the simulated test algorithm by an efficient parallel algorithm, for instance in the parallel random-access machine (PRAM) model of parallel computation, where a collection of processors operate in synchrony on a shared memory, all performing the same sequence of operations on different memory addresses. If the test algorithm is a PRAM algorithm uses
In the case of the example problem of finding the crossing time of the median of
The best choice for this algorithm (according to its theoretical analysis, if not in practice) is the sorting network of {{harvs|author1-link=Miklós Ajtai|last1=Ajtai|author2-link=János Komlós (mathematician)|last2=Komlós|author3-link=Endre Szemerédi|last3=Szemerédi|year=1983|txt}}. This can be interpreted as a PRAM algorithm in which the number
Because of the large constant factors arising in the analysis of the AKS sorting network, parametric search using this network as the test algorithm is not practical. Instead, {{harvtxt|van Oostrum|Veltkamp|2002}} suggest using a parallel form of quicksort (an algorithm that repeatedly partitions the input into two subsets and then recursively sorts each subset). In this algorithm, the partition step is massively parallel (each input element should be compared to a chosen pivot element) and the two recursive calls can be performed in parallel with each other. The resulting parametric algorithm is slower in the worst case than an algorithm based on the AKS sorting network. However, van Oostrum and Veltkamp argue that if the results of past decision algorithms are saved (so that only the comparisons unresolved by these results will lead to additional calls to the decision algorithm) and the comparison values tested by the simulated test algorithm are sufficiently evenly distributed, then as the algorithm progresses the number of unresolved comparisons generated in each time step will be small. Based on this heuristic analysis, and on experimental results with an implementation of the algorithm, they argue that a quicksort-based parametric search algorithm will be more practical than its worst-case analysis would suggest.
=Desynchronized sorting=
{{harvtxt|Cole|1987}} further optimized the parametric search technique for cases (such as the example) in which the test algorithm is a comparison sorting algorithm. For the AKS sorting network and some other sorting algorithms that can be used in its place, Cole observes that it is not necessary to keep the simulated processors synchronized with each other: instead, one can allow some of them to progress farther through the sorting algorithm while others wait for the results of their comparisons to be determined. Based on this principle, Cole modifies the simulation of the sorting algorithm, so that it maintains a collection of unresolved simulated comparisons that may not all come from the same parallel time step of the test algorithm. As in the synchronized parallel version of parametric search, it is possible to resolve half of these comparisons by finding the median comparison value and calling the decision algorithm on this value. Then, instead of repeating this halving procedure until the collection of unresolved comparisons becomes empty, Cole allows the processors that were waiting on the resolved comparisons to advance through the simulation until they reach another comparison that must be resolved.
Using this method, Cole shows that a parametric search algorithm in which the test algorithm is sorting may be completed using only a logarithmic number of calls to the decision algorithm, instead of the
{{harvtxt|Goodrich|Pszona|2013}} combine Cole's theoretical improvement with the practical speedups of {{harvtxt|van Oostrum|Veltkamp|2002}}. Instead of using a parallel quicksort, as van Oostrum and Veltkamp did, they use boxsort, a variant of quicksort developed by {{harvtxt|Reischuk|1985}} in which the partitioning step partitions the input randomly into
On the example problem of finding the median crossing time of a point, both Cole's algorithm and the algorithm of Goodrich and Pszona obtain running time
Comparison with binary search and randomized search
The bisection method (binary search) can also be used to transform decision into optimization. In this method, one maintains an interval of numbers, known to contain the optimal solution value, and repeatedly shrinks the interval by calling the decision algorithm on its median value and keeping only the half-interval above or below the median, depending on the outcome of the call. Although this method can only find a numerical approximation to the optimal solution value, it does so in a number of calls to the decision algorithm proportional to the number of bits of precision of accuracy for this approximation, resulting in weakly polynomial algorithms.
Instead, when applicable, parametric search finds strongly polynomial algorithms, whose running time is a function only of the input size and is independent of numerical precision. However, parametric search leads to an increase in time complexity (compared to the decision algorithm) that may be larger than logarithmic. Because they are strongly rather than weakly polynomial, algorithms based on parametric search are more satisfactory from a theoretical point of view. In practice, binary search is fast and often much simpler to implement, so algorithm engineering efforts are needed to make parametric search practical. Nevertheless, {{harvtxt|van Oostrum|Veltkamp|2002}} write that "while a simple binary-search approach is often advocated as a practical replacement for parametric search, it is outperformed by our [parametric search] algorithm" in the experimental comparisons that they performed.
When only concerned with expected performance, a randomized optimization technique {{harv|Chan|1998}} can be used in place of parametric search. This method only incurs a constant factor increase in time complexity while still giving a strongly polynomial algorithm.
Applications
File:Thiel-Sen estimator.svg compared to simple linear regression]]
Parametric search has been applied in the development of efficient algorithms for optimization problems, particularly in computational geometry {{harv|Agarwal|Sharir|Toledo|1994}}.
They include the following:
- A centerpoint of a point set in a Euclidean space is a point such that any half-space containing the centerpoint also contains a constant fraction of the input points. For
d -dimensional spaces, the optimal fraction that can be achieved is always at least1/(d+1) . Parametric-search based algorithms for constructing two-dimensional centerpoints were later improved to linear time using other algorithmic techniques. However, this improvement does not extend to higher dimensions. In three dimensions, parametric search can be used to find centerpoints in timeO(n^2\log^4 n) {{harv|Cole|1987}}. - Parametric search can be used as the basis for an
O(n\log n) time algorithm for the Theil–Sen estimator, a method in robust statistics for fitting a line to a set of points that is much less sensitive to outliers than simple linear regression {{harv|Cole|Salowe|Steiger|Szemerédi|1989}}. - In computer graphics, the ray shooting problem (determining the first object in a scene that is intersected by a given line of sight or light beam) can be solved by combining parametric search with a data structure for a simpler problem, testing whether any of a given set of obstacles occludes a given ray {{harv|Agarwal|Matoušek|1993}}.
- The biggest stick problem involves finding the longest line segment that lies entirely within a given polygon. It can be solved in time
O(n^{8/5+\epsilon}) , forn -sided polygons and any\epsilon>0 , using an algorithm based on parametric search {{harv|Agarwal|Sharir|Toledo|1994}}. - The annulus that contains a given point set and has the smallest possible width (difference between inner and outer radii) can be used as a measure of the roundness of the point set. Again, this problem can be solved in time
O(n^{8/5+\epsilon}) , forn -sided polygons and any\epsilon>0 , using an algorithm based on parametric search {{harv|Agarwal|Sharir|Toledo|1994}}. - The Hausdorff distance between translates of two polygons, with the translation chosen to minimize the distance, can be found using parametric search in time
O((mn)^2\log^3 mn) , wherem andn are the numbers of sides of the polygons {{harv|Agarwal|Sharir|Toledo|1994}}. - The Fréchet distance between two polygonal chains can be computed using parametric search in time
O(mn\log mn) , wherem andn are the numbers of segments of the curves {{harv|Alt|Godau|1995}}. - For
n points in the Euclidean plane, moving at constant velocities, the time at which the points obtain the smallest diameter (and the diameter at that time) can be found using a variation of Cole's technique in timeO(n\log^2 n) . Parametric search can also be used for other similar problems of finding the time at which some measure of a set of moving points obtains its minimum value, for measures including the size of the minimum enclosing ball or the weight of the maximum spanning tree {{harv|Fernández-Baca|2001}}.
References
- {{citation
| last1 = Agarwal | first1 = Pankaj K. | author1-link = Pankaj K. Agarwal
| last2 = Matoušek | first2 = Jiří | author2-link = Jiří Matoušek (mathematician)
| doi = 10.1137/0222051
| issue = 4
| journal = SIAM Journal on Computing
| mr = 1227762
| pages = 794–806
| title = Ray shooting and parametric search
| volume = 22
| year = 1993| citeseerx = 10.1.1.298.6047
}}
- {{citation
| last1 = Agarwal | first1 = Pankaj K. | author1-link = Pankaj K. Agarwal
| last2 = Sharir | first2 = Micha | author2-link = Micha Sharir
| last3 = Toledo | first3 = Sivan
| doi = 10.1006/jagm.1994.1038
| issue = 3
| journal = Journal of Algorithms
| mr = 1300253
| pages = 292–318
| title = Applications of parametric searching in geometric optimization
| volume = 17
| year = 1994| s2cid = 380722 | doi-access = free
}}.
- {{citation
| last1 = Ajtai | first1 = M. | author1-link = Miklós Ajtai
| last2 = Komlós | first2 = J. | author2-link = János Komlós (mathematician)
| last3 = Szemerédi | first3 = E. | author3-link = Endre Szemerédi
| contribution = An {{math|O(n log n)}} sorting network
| doi = 10.1145/800061.808726
| isbn = 0-89791-099-0
| pages = 1–9
| title = Proceedings of the 15th ACM Symposium on Theory of Computing (STOC '83)
| year = 1983| s2cid = 15311122 }}.
- {{citation
| last1 = Alt | first1 = Helmut | author1-link = Helmut Alt
| last2 = Godau | first2 = Michael
| doi = 10.1142/S0218195995000064
| issue = 1–2
| journal = International Journal of Computational Geometry & Applications
| mr = 1331177
| pages = 75–91
| title = Computing the Fréchet distance between two polygonal curves
| url = http://www.staff.science.uu.nl/~kreve101/asci/ag-cfdbt-95.pdf
| volume = 5
| year = 1995}}.
- {{citation
| last1 = Chan | first1 = Timothy M
| doi = 10.1145/276884.276915
| title= Proceedings of the Fourteenth Annual Symposium on Computational Geometry
| pages = 269–278
| year = 1998
| chapter= Geometric applications of a randomized optimization technique
| isbn = 0-89791-973-4
| url = https://dl.acm.org/doi/pdf/10.1145/276884.276915}}.
- {{citation
| last = Cole | first = Richard
| doi = 10.1145/7531.7537
| issue = 1
| journal = Journal of the ACM
| mr = 882669
| pages = 200–208
| title = Slowing down sorting networks to obtain faster sorting algorithms
| volume = 34
| year = 1987| s2cid = 2301419
| doi-access = free
}}.
- {{citation
| last = Cole | first = Richard
| doi = 10.1137/0217049
| issue = 4
| journal = SIAM Journal on Computing
| mr = 953293
| pages = 770–785
| title = Parallel merge sort
| volume = 17
| year = 1988| s2cid = 2416667
}}.
- {{citation
| last1 = Cole | first1 = Richard
| last2 = Salowe | first2 = Jeffrey S.
| last3 = Steiger | first3 = W. L.
| last4 = Szemerédi | first4 = Endre | author4-link = Endre Szemerédi
| doi = 10.1137/0218055
| issue = 4
| journal = SIAM Journal on Computing
| mr = 1004799
| pages = 792–810
| title = An optimal-time algorithm for slope selection
| volume = 18
| year = 1989}}.
- {{citation
| last = Fernández-Baca | first = D.
| doi = 10.1007/s00453-001-0001-2
| issue = 1
| journal = Algorithmica
| mr = 1816864
| pages = 1–11
| title = On nonlinear parametric search
| volume = 30
| year = 2001| s2cid = 20320912
}}.
- {{citation
| last1 = Goodrich | first1 = Michael T. | author1-link = Michael T. Goodrich
| last2 = Pszona | first2 = Paweł
| arxiv = 1306.3000
| contribution = Cole's parametric search technique made practical
| contribution-url = http://cccg.ca/proceedings/2013/papers/paper_19.pdf
| title = Proc. 25th Canadian Conference on Computational Geometry (CCCG 2013)
| year = 2013| bibcode = 2013arXiv1306.3000G}}.
- {{citation
| last = Megiddo | first = Nimrod | authorlink = Nimrod Megiddo
| doi = 10.1145/2157.322410
| issue = 4
| journal = Journal of the ACM
| mr = 819134
| pages = 852–865
| title = Applying parallel computation algorithms in the design of serial algorithms
| volume = 30
| year = 1983| s2cid = 2212007 | doi-access = free
}}.
- {{citation
| last = Reischuk | first = Rüdiger
| doi = 10.1137/0214030
| issue = 2
| journal = SIAM Journal on Computing
| mr = 784745
| pages = 396–409
| title = Probabilistic parallel algorithms for sorting and selection
| volume = 14
| year = 1985}}.
- {{citation
| last1 = van Oostrum | first1 = René
| last2 = Veltkamp | first2 = Remco C.
| contribution = Parametric search made practical
| doi = 10.1145/513400.513401
| isbn = 1-58113-504-1
| location = New York, NY, USA
| pages = 1–9
| publisher = ACM
| title = Proceedings of the Eighteenth Annual Symposium on Computational Geometry (SoCG '02)
| year = 2002| hdl = 1874/18869
| s2cid = 1551019
| hdl-access = free
}}.