An algorithm for Simulazion-Optimization of Multi-stage Flow Lines