From: Malcolm R. <mal...@cs...> - 2007-10-08 03:08:44
|
I'm trying to make a constraint based representation of a list of variable length. Basically, I have an array of, say, 100 element variables V_0, ..., V_99, plus a length variable L in [0,100]. Semantically, the first L of the element variables are in the list, the others are irrelevant. I then have a bunch of different constraints which apply to all elements in the list (and only those). So essentially, for each such constraint C(V), I form a list of 100 constraints which state whether the constraint applies to each element, depending on the length variable: L > 0 => C(V_0) L > 1 => C(V_1) ... L > 99 => C(V_99) It seems to me that introducing 100 constraints like this is inefficient. I'd much rather have a single constraint which watched as the lower bound of L increased and added individual element constraints on the fly. So when L is foung to be greater than 2, C (V_0), C(V_1) and C(V_2) are added to the problem. The apparent difficulty with this is the backtracking behaviour. If on backtracking we determine that L is less than 2, then we need to retract C(V_2) from the constraint store. Is there any easy way to do this in Choco? Malcolm -- Many clever men like you have trusted to civilisation. Many clever Babylonians, many clever Egyptians, Many clever men at the end of Rome. - G.K.Chesterton, The Napoleon of Notting Hill |