Optimal control of membrane filtration systems