Algorithms for Sample Preparation with Microfluidic Lab-on-Chip