我在SICStus Prolog(clpfd)中有一个程序,我想看看labeling
期间发生了什么。我试过trace
但是它太冗长了,这使得很难理解究竟发生了什么(为哪些变量分配了哪些值,约束如何传播等等。)
我的程序的缩短版本:
runTT(Goal) :-
PLST_1 in {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59},
DLST_1 in {0, 1, 2, 3, 4},
DLST_1 #= PLST_1 / 12,
% T: Bo, S: A, D: 1
PLST_2 in {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59},
DLST_2 in {0, 1, 2, 3, 4},
DLST_2 #= PLST_2 / 12,
Domain__I0_01_0 in 0..1, Domain__I0_01_1 in 0..1, Domain__I0_01_2 in 0..1, Domain__I0_01_3 in 0..1, Domain__I0_01_4 in 0..1, Domain__I0_01_5 in 0..1, Domain__I0_01_6 in 0..1, Domain__I0_01_7 in 0..1, Domain__I0_01_8 in 0..1, Domain__I0_01_9 in 0..1, Domain__I0_01_10 in 0..1, Domain__I0_01_11 in 0..1, Domain__I0_01_12 in 0..1, Domain__I0_01_13 in 0..1, Domain__I0_01_14 in 0..1, Domain__I0_01_15 in 0..1, Domain__I0_01_16 in 0..1, Domain__I0_01_17 in 0..1, Domain__I0_01_18 in 0..1, Domain__I0_01_19 in 0..1, Domain__I0_01_20 in 0..1, Domain__I0_01_21 in 0..1, Domain__I0_01_22 in 0..1, Domain__I0_01_23 in 0..1, Domain__I0_01_24 in 0..1, Domain__I0_01_25 in 0..1, Domain__I0_01_26 in 0..1, Domain__I0_01_27 in 0..1, Domain__I0_01_28 in 0..1, Domain__I0_01_29 in 0..1, Domain__I0_01_30 in 0..1, Domain__I0_01_31 in 0..1, Domain__I0_01_32 in 0..1, Domain__I0_01_33 in 0..1, Domain__I0_01_34 in 0..1, Domain__I0_01_35 in 0..1, Domain__I0_01_36 in 0..1, Domain__I0_01_37 in 0..1, Domain__I0_01_38 in 0..1, Domain__I0_01_39 in 0..1, Domain__I0_01_40 in 0..1, Domain__I0_01_41 in 0..1, Domain__I0_01_42 in 0..1, Domain__I0_01_43 in 0..1, Domain__I0_01_44 in 0..1, Domain__I0_01_45 in 0..1, Domain__I0_01_46 in 0..1, Domain__I0_01_47 in 0..1, Domain__I0_01_48 in 0..1, Domain__I0_01_49 in 0..1, Domain__I0_01_50 in 0..1, Domain__I0_01_51 in 0..1, Domain__I0_01_52 in 0..1, Domain__I0_01_53 in 0..1, Domain__I0_01_54 in 0..1, Domain__I0_01_55 in 0..1, Domain__I0_01_56 in 0..1, Domain__I0_01_57 in 0..1, Domain__I0_01_58 in 0..1, Domain__I0_01_59 in 0..1,
global_cardinality([ PLST_1, PLST_2, PLST_3 ], [0-Domain__I0_01_0, 1-Domain__I0_01_1, 2-Domain__I0_01_2, 3-Domain__I0_01_3, 4-Domain__I0_01_4, 5-Domain__I0_01_5, 6-Domain__I0_01_6, 7-Domain__I0_01_7, 8-Domain__I0_01_8, 9-Domain__I0_01_9, 10-Domain__I0_01_10, 11-Domain__I0_01_11, 12-Domain__I0_01_12, 13-Domain__I0_01_13, 14-Domain__I0_01_14, 15-Domain__I0_01_15, 16-Domain__I0_01_16, 17-Domain__I0_01_17, 18-Domain__I0_01_18, 19-Domain__I0_01_19, 20-Domain__I0_01_20, 21-Domain__I0_01_21, 22-Domain__I0_01_22, 23-Domain__I0_01_23, 24-Domain__I0_01_24, 25-Domain__I0_01_25, 26-Domain__I0_01_26, 27-Domain__I0_01_27, 28-Domain__I0_01_28, 29-Domain__I0_01_29, 30-Domain__I0_01_30, 31-Domain__I0_01_31, 32-Domain__I0_01_32, 33-Domain__I0_01_33, 34-Domain__I0_01_34, 35-Domain__I0_01_35, 36-Domain__I0_01_36, 37-Domain__I0_01_37, 38-Domain__I0_01_38, 39-Domain__I0_01_39, 40-Domain__I0_01_40, 41-Domain__I0_01_41, 42-Domain__I0_01_42, 43-Domain__I0_01_43, 44-Domain__I0_01_44, 45-Domain__I0_01_45, 46-Domain__I0_01_46, 47-Domain__I0_01_47, 48-Domain__I0_01_48, 49-Domain__I0_01_49, 50-Domain__I0_01_50, 51-Domain__I0_01_51, 52-Domain__I0_01_52, 53-Domain__I0_01_53, 54-Domain__I0_01_54, 55-Domain__I0_01_55, 56-Domain__I0_01_56, 57-Domain__I0_01_57, 58-Domain__I0_01_58, 59-Domain__I0_01_59]),
Goal = [PLST_1, PLST_2],
labeling([], Goal).
感谢任何提示!
注意:我也想删除“域名地狱”,但据我所知,Prolog我不能使用一个变量(例如Domain_01)。