I have a vector using Matlab whose values are from 1 to 18, I need to perform permutations of those values considering that certain numbers cannot go together. For example:
vector = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18]
In the conditions I have that the following numbers cannot go together:
1 and 7
1 and 8
1 and 17
1 and 18
2 and 6
2 and 7
2 and 8
2 and 17
2 and 18
So a valid permutation could be:
[1 2 4 3 5 6 7 8 9 10 11 12 13 14 15 17 16 18]
An invalid permutation could be:
[1 7 4 3 5 6 2 8 9 10 11 12 13 14 15 17 16 18] 1 and 7 together
[1 8 4 3 5 6 2 7 9 10 11 12 13 14 15 17 16 18] 1 and 8 together
[1 17 4 3 5 6 2 8 9 10 11 12 13 14 15 7 16 18] 1 and 17 together
These conditions must apply in any position of the vector. I have no ideas how to do this, if someone could give me ideas I would really appreciate it.