Hi! Thank you for your answer. As I stated, I am a beginner to gecode and constraint programming at all. I did not try reification, but by this keyword I managed to solve the problem.
However, I still think, that I am formulating my constraint in a bad way. I managed to reduce my (sub)problem to the following: I have an one-dimensional array ############# Furthermore, I have patterns such as Pattern 1 = aa#a Pattern 2 = b#b#b where the hash means an empty field. I want to place these patterns on the array, i.e. possible placements are Placement 1: aa#a###b#b#b# Placement 2: aabab#b###### No I want to store the position (i.e. the column) of each pattern in an IntVarArray c, i.e. in Placement 1 it is c=(0; 7) in Placement 2 it is c=(0; 2). However I do not know, how to formulate the non-overlapping. I have three possible Ideas: 1. For each pattern I have an BoolVarArray to indicate if the pattern is placed there For Placement 1 I have two arrays (for pattern 1 = 1101000000000) and (for Pattern 2 = 0000000101010) Then I have constraints c_a=j <==> x_{j+0} = x_{j+1} = x_{j+3} = 1 c_b=j <==> y_{j+0} = y_{j+2} = y_{j+4} = 1 2. I have one IntVarArray that stores the pattern placed at this field. For Placement 1 this is 1101000202020 Then I have constraints c_a=j <==> x_{j+0} = x_{j+1} = x_{j+3} = 1 c_b=j <==> x_{j+0} = x_{j+2} = x_{j+4} = 2 3. I assign different numbers to each point of the the pattern, I.e. pattern 1 = 12#3 and Pattern 2=4#5#6 For Placement 1 this is 1203000405060 Then I have constraints c_a=j <==> x_{j+0} = 1 c_a=j <==> x_{j+1} = 2 c_a=j <==> x_{j+3} = 3 c_b=j <==> x_{j+0} = 4 c_b=j <==> x_{j+2} = 5 c_b=j <==> x_{j+4} = 6 However I am somehow lost, how to formulate such constraints efficiently. Although this seems a little bit similar to the Pentomino example, with my current gecode-skills I am not able to transfer the Ideas. Best Regards, Uwe ----------------ursprüngliche Nachricht----------------- Von: "Christian Schulte" cschu...@kth.se An: "'Uwe Nowak'" uwe.no...@itwm.fraunhofer.de , users@gecode.org Datum: Thu, 23 May 2013 17:49:07 +0200 ------------------------------------------------- > Hi, > > Did you try reification? While not great, it should not be too hard to pull > this off. Or am I missing something here? > > Best > Christian > > -- > Christian Schulte, Professor of Computer Science, KTH, > www.ict.kth.se/~cschulte/ > > > -----Original Message----- > From: users-boun...@gecode.org [mailto:users-boun...@gecode.org ] On > Behalf > Of Uwe Nowak > Sent: Thursday, May 23, 2013 3:40 PM > To: users@gecode.org > Subject: [gecode-users] Problem to formulate a constraint > > I am a beginner with gecode and have a problem to formulate a constraint. > I was looking through all channel constraints, however they do not seem to > fit my needs, or I am unable to formulate my needs in the language of the > channel constraints. > > I have the following variables > *an IntVar c with a finite set of values {A_1,...,A_n} *an IntVarArray p > > I have the following fixed parameters > For each value A_t I have a finite set of fixed indexed values I_t (e.g, an > std::set<int>) > A constant B > > Now I want to formulate the following constraints for(t = 1...n){ > c=A_t ==> for all I in I_t: p[i]=B > } > > > I thought to create an IntVarArgs of the subset of p with the indices I_t > However, than I have tor formulated for an IntVarArgs q_t: > for(t = 1...n){ > c=A_t ==> For all elements q_t[i]=B > } > > However, I do not find the right expressions to formulate this in gecode... > > > > _______________________________________________ > Gecode users mailing list > users@gecode.org > https://www.gecode.org/mailman/listinfo/gecode-users > > _______________________________________________ Gecode users mailing list users@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users