A main task to solve while designing a radio interferometer is the location of the antenna-elements, a problem that defines the interferometer response. The solution determines which points of the Fourier plane (or uv plane) will be sampled, together with their density. These characteristics are extremely important because the antenna locations, in turn, define the synthesized beam or point spread function (PSF) of the whole instrument. An inadequate array configuration implies an ill- constructed synthesized beam. Consequences of inadequate arrays are for example the need to delete measures over a range of spatial frequencies due to low signal-to-noise ratio (SNR), or, at the data reduction stage, to degrade spatial resolution in order to get a cleaner image. In this work, we implement a method to optimize the antenna locations, starting with an initial random configuration and a desired or objective sample density function, taking into account if there are terrain constraints.