<[EMAIL PROTECTED]> writes: > > Hi there, > I think using the element constraint is the correct choice. > Maybe the little example I attached will help you out. > At least you can use the element constraint to model > > B[C[i-1]]=A[i] > > and indeed the alg also does > > A[i]=B[C[i-1]] > > see http://www.gecode.org/gecode-doc-latest/group__TaskIntIntElement.html > > > 2) I also tried 'element' to express this constraint > > > > Int Var x; > > element(this, B, C.get(i - 1), x); > > rel(this,A.get(i),IRT_EQ,x); > > So this was quite right, but you can directly use > > element(this, B, C[i - 1], A[i]); > > so you don't need the rel constraint. > > If there are any further questions, let us know. > :-D > Cheers > Patrick > > > Attachment (arrayex.cc): application/octet-stream, 1932 bytes > > _______________________________________________ > Gecode users mailing list > [EMAIL PROTECTED] > https://www.gecode.org/mailman/listinfo/gecode-users >
Thank you, I now see rel is useless and element is just enough. But one point is; we will need Var indexes inevitable when the relations get nested. For example; A[i] = B [ C [A[j]] ] 1) obviously rel does not work. rel(this, A.get(i), IRT_EQ, B.get(C.get(A.get(j)))) 2) I tried to introduce new Vars, but below did not work also. IntVar intermediate1= new IntVar(this,min,max); IntVar intermediate2= new IntVar(this,min, max); element(this, C, A.get(j), intermediate1); element(this, B, intermediate1, intermediate2); rel(this, A.get(i), IRT_EQ, intermediate2); 3) Any way to write this constraint? Thanks! _______________________________________________ Gecode users mailing list [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users
