Optimal design of morphing structures