我有一组变量T_1, T_2, ..., T_N
,我想在 CLPFD 中重写以下伪代码:
T_1 in 0..59,
T_2 in 0..59,
...
T_n in 0..59,
all_different([T_1, T_2, ..., T_n]),
FOREACH x in 0 to 59 do:
IF (x \in [T_1, T_2, T_3, ..., T_n]) THEN
Slot_x = 1
ELSE
Slot_x = 0
ENDFOREACH
我怎样才能做到这一点?
我会使用count:
T_1 in 0..59,
T_2 in 0..59,
...
count(0, [T_1, T_2, ..., T_n], #=, Slot_0) % The number 0 can be at most once in the list
count(1, [T_1, T_2, ..., T_n], #=, Slot_1) % The number 1 can be at most once in the list
...
但我相信更有经验的程序员不会这样写。