An encouraging way to convert ocean wave energy into electricity through direct drive is by using a linear, synchronous, longitudinal-flux permanent-magnet machine (LFM), where the piston is driven by a buoy. In this paper, the speed of the piston is assumed to be constant or sinusoidal. The paper presents an automated method for optimizing the design variables of an LFM with a rectifier, using time-stepping finite-element analysis. The method yields feasible LFM designs tailored to a given ocean wave climate, assuming constant or sinusoidal piston speed. The method will help to avoid a large amount of field calculations to obtain an optimal LFM driven by a buoy. The systematic approach results in a transparent investigation, giving the engineer an easy way to determine the best design. The paper presents LFM designs for a calm site in the Baltic Sea as examples.