A New Modular Parametric Search Framework
Total Page:16
File Type:pdf, Size:1020Kb
EuroCG 2016, Lugano, Switzerland, March 30{April 1, 2016 A New Modular Parametric Search Framework Christian Knauer∗ David K¨ubely Fabian Stehn∗ Abstract values, representing k comparisons to λopt. Exploiting the monotonicity of P , all comparisons of a batch can Parametric search is a technique to develop efficient be resolved by O (log k) calls to As. After resolving deterministic algorithms for optimization problems. a batch of critical values, each process can continue The strategy requires an algorithm for the decision until a new batch of k comparisons is collected and variant of the problem at hand. Given this decision resolved in the same way. algorithm, the strategy can be seen as a black box Throughout this process, an interval I = (λ−,λ+] is that does not really exploit characteristics of the un- maintained, where λ− is the largest value encountered derlying problem: It computes an optimal solution by so far such that dec (λ−) = false and λ+ is the keeping track of the values that appear in comparisons P smallest value encountered so far with dec (λ+) = of the decision algorithm. P true; this implies that λ 2 I. Through the course In this abstract, we present a new parametric search opt of this process, at least one instance of the parallel framework written in Java. We show how parametric algorithm A has to carry out a comparison with the search based algorithms can be implemented and ex- p actual optimal value λ , which implies that λ will plored with the framework. It allows to quickly spec- opt opt appear as a critical value. Since P is a minimization ify or change crucial functionalities which influence problem, we have that λ = λ+ after all processes of the specific behaviour (and performance) of the re- opt A terminated. This gives a combined minimization sulting optimization algorithm. We focus on a trans- p algorithm C that computes λ in O(T ·(k+T ·log k)) parent, simple-to-use, and modular design, and dis- opt p s deterministic time; see [6] for details. cuss the implementation of a specific algorithm that computes an optimal shortcut of a polygonal curve. 1 Introduction 1.1 Applications Parametric search is a powerful and fairly general The technique has been applied to a wide range of method to compute the (exact) optimal solution λopt problems. In the field of computational geometry, of an optimization problem P in one variable. Let P e.g., the technique has been used to compute the be a minimization problem whose objective function Fr´echet Distance [2] between two polygonal curves. is monotone, that is, for the decision variant decP of Recently, Große et al. [4] showed how to efficiently P there is a value λopt such that decP (λ) = true , compute a diameter-optimal shortcut between ver- λ ≥ λopt. In oder to apply Megiddo's [6] parametric tices of a polygonal curve. Agarwal et al. [1] present search technique, two ingredients are required: several applications in context of geometric optimiza- tion. 1. A sequential algorithm As that solves decP for any value λ in Ts time, and 2. a parallel algorithm Ap using k processes, solving decP for an unknown value of λopt in Tp time. 1.2 Related work Ap is an algorithm that uses k (independent) pro- cesses whose control-flow depends on the outcome of The first implementations of parametric search algo- comparisons. Each comparison can be resolved by re- rithms are due to Toledo [9] (solving extremal polygon lating a value that is derived from the input to the placement problems) and Schwerdt et al. [8] (comput- (unknown) value of λopt. The basic idea is to fol- ing the diameter of moving points) roughly twenty low the control-flow of each process until it requires years ago. Van Oostrum and Veltkamp [7] were the the solution to such a comparison and to collect these first to provide a general framework, written in C++. comparisons in batches (these collected values are usu- Their framework includes a detailed documentation as ally called critical values). A batch hence consists of k well as two reference implementations to compute the Median of Lines [6] and the Fr´echetdistance between ∗ Institut f¨ur Informatik, Universit¨at Bayreuth, two polygonal curves [2]. They experimented with dif- fchristian.knauer, [email protected], yInstitut f¨urInformatik, Abteilung I, Universit¨at Bonn, ferent sorting algorithms and showed that Quicksort [email protected] can replace a parallel sorting network in practice. This is an extended abstract of a presentation given at EuroCG 2016. It has been made public for the benefit of the community and should be considered a preprint rather than a formally reviewed paper. Thus, this work is expected to appear in a conference with formal proceedings and/or in a journal. 32nd European Workshop on Computational Geometry, 2016 1.3 Contribution backs: It forces the developer to scatter code to sched- uled methods which makes the parallel algorithm even In Chapter 2, we present a new general parametric harder to read, understand or debug. Realizing com- search framework. Two (geometric) algorithms that plex parallel algorithms is considerably more involved have been realized in this framework are discussed in with this design. Moreover, the developer has no Chapter 3. chance to control or influence the parallel steps and The framework can be used as a black box to imple- the evaluation of batches separately. ment efficient optimization algorithms (based on de- With our framework we offer the chance to hook cision algorithms) with minimal adaptation effort for into the scheduling or the handling of critical val- the task at hand. It is designed to provide the capabil- ues, if desired or necessary. Both frameworks share ity to easily exchange not only the sorting algorithm (conceptually) similar components, e.g., a scheduler, (a central component of the parametric search tech- processes or a decision algorithm. However, the de- nique) but also the strategy that is used to solve the sign of our framework meets additional requirements. comparisons of a batch, or the scheduler that man- The most striking difference is that we separate the ages the (simulated) parallel execution of the individ- scheduling component from the management of crit- ual processes. Standard performance enhancements, ical values. We provide ready-to-use functionalities such as \Cole's trick" [3] are built in along with other to reduce the implementation effort; c.f. Section 2.2. optimizations. Several parameters can be used to fine- Among these are different strategies to resolve criti- tune the performance of the final algorithm. cal values of a batch which can be easily exchanged to From this point of view, our approach is twofold: study their impact on the overall performance. This On the one hand, the framework can be used as provides an insight into how critical values are pro- a black box that merely requires to provide an im- cessed in a certain application and may reveal char- plementation of the corresponding decision algorithm acteristics of the underlying problem. and parts of Ap that determine and organize critical The core components of the framework have already values. On the other hand, it allows a deeper look been released online [10]. The code of the whole para- \under the hood" of the general mechanism of para- metric search framework together with the demo ap- metric search in order to study, analyse and compare plications will be released as a part of a larger frame- an algorithm and to gain deeper insight into the orig- work within this year. inal problem. In Chapter 3, we discuss how a recent algorithm for computing shortcuts has been realized with the 2.1 Design Choices framework, and we show how the framework allows to Our framework is written in Java and consists of four study the effect of optimization strategies on the ac- components. A single responsibility is assigned to tual computation times. Numerical effects which may each component in order to (re-)use or interchange arise in practical applications are discussed briefly. them independently. In the following, we briefly de- scribe these components and their role within the 2 The Framework framework. One component is the serial decision algorithm As In this section, we describe the general structure of which has to be provided by the developer. The im- our framework and discuss where and why it differs plementation has to support a method to decide decP from the reference framework by van Oostrum et al. for any given value λ ≥ 0. The outcome of a call to [7]. To keep the implementation effort as small as pos- As is a boolean value; either true (if λ ≥ λopt) or sible, van Oostrum et al. identify essential parts of the false (if λ < λopt). technique so that certain components can be reused The remaining three components constitute the in different implementations. Their framework pro- parallel algorithm Ap. We aim to restrict the ac- vides Quicksort and Bitonicsort together with an au- cess to the decision algorithm during the execution tomated organization of the comparisons in a batch. of Ap. Whenever decP needs to be solved for a con- The framework encapsulates and hides the scheduling crete value λ, the component Oracle has to be asked: of comparisons and the management of critical val- In contrast to As, the oracle may also return the value ues. In case that Ap is a parallel sorting algorithm, unknown, implying that λ 2 I, which forces the call- it is certainly a benefit to hide all this complexity ing process to wait. This allows us to delay a single which reduces the implementation effort considerably.