簡體   English   中英

以可讀的形式列出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 ))而不是上面列表中的clean輸出。我需要將它從shell腳本輸出到文件,而不是從交互式循環默認隱藏延遲目標。

從內部目標到可讀目標的轉換是通過目標 - 描繪 - 轉換來執行的。 輸出謂詞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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM