Optimize sequence of pick and place operations upon arrival of workpiece on conveyor