Optimization Models for Water Management in Chemical Processes and Shale Gas Production