partial multi-unit packages algorithm