Sampling labeled items on a conveyor belts

106 Views Asked by At

I have items on a moving conveyor belt. Every item has a label with a number that goes from $1$ to $N$; on the conveyor belt there are more than $N$ items. I have a camera above the items on the belt, the camera is in a fixed position; an example with $N=8$ (where * is the camera):

                   *
...7 6 5 4 3 2 1 8 7 6 5 4 3 2 1 8 7 6 5 4 3 2...
-------------------------------------------------

The camera knows when it can take a picture of the item because it is triggered by the presence of the item. The camera can't see the label on the items. It is assumed that the labels are ordered, there are no gaps, there are no duplicated labels in the wrong positions.

For quality control purpose, the camera should take pictures of the items but it is not fast enough to take one picture for every item and so basically it can take the picture of one item, then skips the following $M$ items, then take the picture of one item, then skips the following $M$ items and so on; $M\gt0$ is a characteristic parameter of the camera in use.

My goal is to find a sampling method in order to have pictures evenly distributed among the $N$ labels and to skip the least number of items.

I have tried to solve the problem in this way: I compute a prime factorization of $N$; then I choose a prime $P$ that does not belong to the prime factorization of $N$ and $P\gt M+1$. Then the sampling goes in this way: the camera takes the picture of one item, then skips the following $P-1$ items, then takes the picture of one item, then skips the following $P-1$ items and so on.

For example with $N=10$, $M=7$, my solution is $P=11$.

I made some simulations of the above sampling method and it seems to meet my goal, but I would like to know whether it can be proved to be correct and/or optimized.

1

There are 1 best solutions below

2
On BEST ANSWER

Suppose you take a photo once every $R$ turns. Then the labels are evenly distributed if and only if $R$ is coprime to $N$. Thus you want $R$ to be the least number at least as large as $M$ which is coprime to $N$.

The way this is proved is by first showing that the sequence $R,2R,3R,4R,\ldots\pmod N$ is periodic; then showing it is always $N$-periodic, and that it has no smaller period precisely if $R$ and $N$ are coprime. If $N$ and $R$ are coprime, that means that $R,2R,\ldots,NR\pmod N$ are all distinct, so they are exactly the numbers $1,2,\ldots,N$ in some order, and after that, the sequence repeats these numbers in the same order indefinitely. Thus you get an even distribution. If the period is smaller than $N$ however, some labels will never show up at all.