The optima] allocation of buffer capacity in unbalanced production lines with reliable but variable workstations is a complex and little-researched topic. Analytic formulas for the throughput of these lines do not exist, so simulation is the only practical alternative for estimating throughput. Exhaustive search over all possible buffer allocations quickly becomes impractical beyond short lines and few buffers. Thus an algorithm is needed to efficiently find optimal or near-optimal allocations. We develop a simple search algorithm for determining the optimal allocation of a fixed amount of buffer capacity in an n-station serial line. The algorithm, which is an adaptation of the Spendley-Hext and Nelder-Mead simplex search algorithms, uses simulation to estimate throughput for every allocation considered. An important feature of the algorithm is that the simulation run length is adjusted during the running of the algorithm to save simulation run time when high precision in throughput estimates is not needed, and 10 ensure adequate precision when it is needed. We describe the algorithm and show that it can reliably find the known optimal allocation in balanced lines. Then we test the ability of the algorithm to find optimal allocations in unbalanced lines, first for cases in which the optimal allocation is known, and subsequently for cases in which the optimal allocation is not known. We focus particularly on lines with multiple imbalances in means and variances. In general, our algorithm proves highly efficient in finding a near-optimal allocation with short simulation run times. It also usually finds the true optimal allocation, but it is in the nature of this problem that many buffer allocations differ in throughput by small amounts that are difficult to resolve even with long simulation runs.