I have this problem:
find as large a set S of strings (words) of length 8 over the alphabet W = { A,C,G,T } with the following properties:
Each word in S has 4 symbols from
{ C,G }
Each pair of distinct words in S differ in at least 4 position.
I did first point. I said that 8 variables take values between 1 and 4 and 1 and 2 must appear in 4 places:
V = {x1, x2, x3, x4, x5, x6, x7, x8}
D = {1, 2, 3, 4}
C = {1 and 2 must appear in 4 places; I uses `ICF.among()` function}
Now, for the second point, I have no idea. Maybe it's wrong the way I begin. I don't know if it's possible to create constraints between solutions.
I used choco3, and here is the code:
Solver s = new Solver("My pb");
IntVar[] var = new IntVar[8];
for(int i=0;i<8;i++)
var[i]=VariableFactory.bounded("Letter"+i, 1, 4, s);
IntVar o = VariableFactory.bounded("Occurence", 4, 4, s);
int[] ind = {1,2};
int[] ind1={3,4};
s.post(ICF.among(o, var, ind));
s.findSolution();
do{
for(int i=0;i<8;i++){
System.out.print(s.getVar(i)+" ");
}
System.out.println();
}while(s.nextSolution());