In this paper an approach to the optimization of the magnetic design of a Permanent Magnet (PM) linear generator for the exploitation of the energy contained in sea waves is presented. This approach consists of a two step procedure: the first one takes into account the stochastic features of the sea wave motion and describe the working condition of the machine under this motion by adopting a lumped parameter model. In this step the objective function is the energy production. The second step optimizes the generator by using the results obtained in the first step as the constraints that must be fulfilled by a design based on a Finite Element Method (FEM) analysis. Furthermore, the approach is applied to design and build a PM linear generator. Some experimental tests carried on the built linear generator are presented.