以可读形式列出 Eclipse CLP 中的所有约束
Listing all constraints in Eclipse CLP in a readable form
我有一个 ECLiPSe 脚本,其目标是将我的问题编码为一组算术约束。在 REPL 中,我最终得到了一个延迟目标列表,如下所示:
-(_2941{4 .. 7}) + _2900{1 .. 4} #=< 0
_2941{4 .. 7} - _2900{1 .. 4} #= 3
-(_3393{7 .. 21}) + _3352{4 .. 18} #=< 0
_3393{7 .. 21} - _3352{4 .. 18} #= 3
_3845{14 .. 17} - _3804{4 .. 7} #= 10
_4297{18 .. 21} - _4256{14 .. 17} #= 4
-(_4749{19 .. 22}) + _4708{18 .. 21} #=< 0
_4749{19 .. 22} - _4708{18 .. 21} #= 1
...
是否有谓词可以在约束存储中为我提供类似的可读约束列表?
delayed_goals
给出了一些特定于库的约束(如 prop_ic_con(ic_con(... <some special characters> etc ))
而不是上面清单中的干净输出。我需要将其从 shell 脚本输出到文件,而不是来自默认隐藏延迟目标的交互式循环。
从内部目标到可读目标的转换由
目标-portray-转换。输出谓词
printf and write_term 可以选择调用此翻译,例如
?- 3*X+6*Y #> 9, delayed_goals([G]), printf("%Gmw", [G]), nl.
6 * Y{-1.0Inf .. 1.0Inf} + 3 * X{-1.0Inf .. 1.0Inf} #> 9
?- 3*X+6*Y #> 9, delayed_goals([G]), write_term(G, [as(goal)]), nl.
6 * Y{-1.0Inf .. 1.0Inf} + 3 * X{-1.0Inf .. 1.0Inf} #> 9
您还可以使用 portray_term/3:
显式调用翻译
?- 3*X+6*Y #> 9, delayed_goals([G]), portray_term(G, P, goal).
G = prop_ic_con(ic_con(...))
P = (6 * Y{-1.0Inf .. 1.0Inf} + 3 * X{-1.0Inf .. 1.0Inf} #> 9)
我有一个 ECLiPSe 脚本,其目标是将我的问题编码为一组算术约束。在 REPL 中,我最终得到了一个延迟目标列表,如下所示:
-(_2941{4 .. 7}) + _2900{1 .. 4} #=< 0
_2941{4 .. 7} - _2900{1 .. 4} #= 3
-(_3393{7 .. 21}) + _3352{4 .. 18} #=< 0
_3393{7 .. 21} - _3352{4 .. 18} #= 3
_3845{14 .. 17} - _3804{4 .. 7} #= 10
_4297{18 .. 21} - _4256{14 .. 17} #= 4
-(_4749{19 .. 22}) + _4708{18 .. 21} #=< 0
_4749{19 .. 22} - _4708{18 .. 21} #= 1
...
是否有谓词可以在约束存储中为我提供类似的可读约束列表?
delayed_goals
给出了一些特定于库的约束(如 prop_ic_con(ic_con(... <some special characters> etc ))
而不是上面清单中的干净输出。我需要将其从 shell 脚本输出到文件,而不是来自默认隐藏延迟目标的交互式循环。
从内部目标到可读目标的转换由 目标-portray-转换。输出谓词 printf and write_term 可以选择调用此翻译,例如
?- 3*X+6*Y #> 9, delayed_goals([G]), printf("%Gmw", [G]), nl.
6 * Y{-1.0Inf .. 1.0Inf} + 3 * X{-1.0Inf .. 1.0Inf} #> 9
?- 3*X+6*Y #> 9, delayed_goals([G]), write_term(G, [as(goal)]), nl.
6 * Y{-1.0Inf .. 1.0Inf} + 3 * X{-1.0Inf .. 1.0Inf} #> 9
您还可以使用 portray_term/3:
显式调用翻译?- 3*X+6*Y #> 9, delayed_goals([G]), portray_term(G, P, goal).
G = prop_ic_con(ic_con(...))
P = (6 * Y{-1.0Inf .. 1.0Inf} + 3 * X{-1.0Inf .. 1.0Inf} #> 9)