/* Global constraint lex_between in Picat. From Global Constraint Catalogue http://www.emn.fr/x-info/sdemasse/gccat/Clex_between.html """ lex_between (LOWER_BOUND, VECTOR, UPPER_BOUND) Purpose The vector VECTOR is lexicographically greater than or equal to the fixed vector LOWER_BOUND and lexicographically smaller than or equal to the fixed vector UPPER_BOUND. Example ( <5, 2, 3, 9>, <5, 2, 6, 2>, <5, 2, 6, 3> ) The lex_between constraint holds since: * The vector VECTOR=<5, 2, 6, 2> is greater than or equal to the vector LOWER_BOUND=<5, 2, 3, 9>. * The vector VECTOR=<5, 2, 6, 2> is less than or equal to the vector UPPER_BOUND=<5, 2, 6, 3>. """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> N = 4, LowerBound = new_list(N), LowerBound :: 0..9, UpperBound = new_list(N), UpperBound :: 0..9, Vector = new_list(N), Vector :: 0..9, LowerBound = [5, 2, 3, 9], % Vector = [5, 2, 6, 2], UpperBound = [5, 2, 6, 3], lex_between(LowerBound, Vector, UpperBound), Vars = Vector ++ LowerBound ++ UpperBound, solve(Vars), println(lowerBound=LowerBound), println(vector=Vector), println(upperBound=UpperBound), nl, fail, nl. go => true. lex_between(LowerBound,Vector,UpperBound) => lex_lt(LowerBound, Vector), lex_lt(Vector, UpperBound).