Hello Everybody, After having loaded libraries ic and ic_global, we give the query: ?- N = 4, Count = 0, length(L, N), L #:: 1..N, ic_global:alldifferent(L), L = [X1,X2,X3,X4], (X2 #> X1) + (X3 #> max([X1,X2])) + (X4 #> max([X1,X2,X3])) #= Count. N = 4 Count = 0 L = [X1{1 .. 4}, X2{1 .. 4}, X3{1 .. 4}, X4{1 .. 4}] X1 = X1{1 .. 4} X2 = X2{1 .. 4} X3 = X3{1 .. 4} X4 = X4{1 .. 4} There are 6 delayed goals. Yes (0.00s cpu) As we may see, from the query we can infer that X1 = 4. Is there any alternative way to pose the query in order to get this result? Note that Count might be anything between 0 and 3 (if we assign it the value 3, we get the answer X1 = 1, X2 = 2, X3 = 3, X4 = 4, as we might expect). But what if Count is less than 3? How could we get the most propagation possible? Also, note that this is a simplified version of a more general program, where N might be anything and the constraint on the sum of constraints is constructed recursively. Regards, PanagiotisReceived on Mon Feb 20 2023 - 10:41:02 CET
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST