Optimal planning of adaptive two‐stage designs