Optimal process control