An Optimization Principle for Computing Stationary MHD Equilibria with Solar Wind Flow