I'm trying to create an algorithm that performs the following. It needs to form an injection from an integer to a unique choice of traits from multiple categories. For example, if I had 32 traits per category and 8 categories, I could do the following:
DOMAIN
1, ..., 1000000
RANGE
00000 00000 00000 00000 00000 00000 00000 00000 ... 11111 11111 11111 11111 11111 11111 11111 11111
32^8 total possible combinations
With each 5 bit block representing one category and one trait. The problem is that we need these to be weighted, yet the combination of categories to be a injection. I've been able to solve the two halves of this problem independently, but not together; we can solve weighted by allocating more bits to a category and having traits as a fraction of the whole, for example (8 bits each) and have traits as a fraction, so we would have 8 bits 8 traits. Then we can have, for example one trait that is 4/256, one that is 200/256 likely.
However, then the problem is that I can't find a way to efficiently ensure injection in this case. Is there an algorithm that can ensure both a injection and weighted results efficiently?
Aucun commentaire:
Enregistrer un commentaire