Optimizing future imaging survey of galaxies to confront dark energy and modified gravity models