An algorithm for simulation-optimization of multi-stage flow lines