An Optimal Energy and Water Model for Design and Analysis of Water Resources of a River with Constraints on Energy and Ecology