Computing families of periodic orbits through optimization methods