2017-02-09 29 views
1

我有一个ECLiPSe脚本,其目标是将我的问题编码为一组算术约束。在REPL,我最终得到的延迟目标清单看起来如下:以可读形式列出Eclipse CLP中的所有约束条件

-(_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脚本输出到文件,而不是默认隐藏延迟目标的交互循环。

回答

0

从内部目标翻译到由 目标 - portray -transformation执行。输出谓词 printfwrite_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) 
+0

万分感谢@jschimpf!很多方法可以做到我需要的东西! – Alek81