find coefficients for hashing a sequence

10 views
Skip to first unread message

ofer...@gmail.com

unread,
Jun 5, 2024, 10:15:10 AMJun 5
to MiniZinc
Given an array of integers A = <a_1..a_n> where a_1..a_n is a permutation of 1..n, I would like to compute a scalar 'signature' of A, sig(A), such that for any two distinct permutations of A, their signatures are different. 
For example, suppose that I compute my signature with a sum
sig(A) = \Sigma_{i=1..n} (i * A[i])
i.e., multiply each element with its idx. This does not work because, e.g., Sig(2,3,1) = Sig(3,1,2).
I can either
1. stay with this signature but find coefficients other than simply the idx. I could not find a way to model in minizinc the problem of finding those coefficients. Any idea ?
2. find a different signature. Any idea ?


Krzysztof Bordon

unread,
Jun 5, 2024, 10:21:22 PMJun 5
to mini...@googlegroups.com

You can use a sequence of increasing prime numbers for this purpose: sig(A) = \Sigma_{i=1..n} (Prime[i] ^ A[i])
where Prime[] = (2, 3, 5, 7, 11, 13, ...). For example, for the permutation A = (2, 3, 1) the Sig(A) would be 2^2 + 3^3 + 5^1 = 4 + 27 + 5 = 36. The signature proves to be different for any different permutation.

Best regards,
KB



--
You received this message because you are subscribed to the Google Groups "MiniZinc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minizinc+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/minizinc/597024ef-04f3-44c3-97bb-26a1d6ad8c0an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages