Pergunta

I would like to create a constraint that filters all duplicate rows in a nxn matrix, where every field consists of either 0 or 1. The matrix can be up to 10x10 rows and columns. E.g. we have the following 4x4 matrix:

0 1 0 1

1 1 1 0

0 1 0 1

1 0 1 1

Then row 1 and row 3 would be identical which should not be possible. I've been thinking for 4 hours now about this problem, but with no luck.

Can someone give me a hint please?

Foi útil?

Solução

As you're note, you can't "just" get the row (1,0,1,1) to occur twice in a datalog relation. The issue is, of course, that datalog relations store sets as opposed to lists or multisets of elements. The best way to deal with this is to add extra data to track either how often a row occurs to treat the matrix as map from indices to values. You might try one for the following:

myUnorderedMultiset[x,y,z,w]=count -> int(x), int(y), int(z), int(w), int(count).

or

myMatrix[rowIndex, columnIndex] = value -> int(rowIndex), int(columnIndex), int(value).
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top