How to encode a sequence of n non-decreasing integer of [0, ..., m] fulfilling the following conditions:no or minimal redundancyonly use 1 integer variable or k independent integer variables with a range of [0, ..., j(k)], It means there exist an inverse function f-1(x) to map the encoded sequence, an integer x of the domain [0, 1, ..., |valid sequence| - 1], back the original sequence.usual integer operationsno or minimal lookup tablesclosed form formula to decode back to the sequence without loops or recursionsFor example,0, 0, 0, 00, 0, 0, 10, 0, 0, 2...0, 0, 0, m0, 0, 1, 10, 0, 1, 2...m, m, m, mThe purpose of this counting function is to enumerate all possible values in the non-decreasing integer sequence later being used in constraints.
How to encode a sequence of non-decreasing integers with an integer without redundancy, loops, and recursions
algorithms;permutations;counting;encoding scheme;constraint programming