[英]Get non finite domains bounds with C# SWI-Prolog DLL
我正在使用 Swi-Prolog Csharp DLL 和 CLP(FD)。 我有以下 Prolog 文件:
:- use_module(library(clpfd)).
constr(V0,V1,V2,C0,C1,C2) :-
((V0 #= 1901) #\/ (V0 #= 1750)) #<==> C0,
((V1 #= 3) #\/ (5 #= V1)) #<==> C1,
((V2 #>= 1)) #<==> C2.
config(V1,V2) :- constr(1750,V1,V2,1,1,1).
V0,V1,V2 是我的變量。 C0,C1,C2 是我的約束具體化變量。 調用config(V1,V2).
,我想獲得 V1 和 V2 域值,以便滿足所有約束。
在 SWI-Prolog 界面中使用時,我得到:
1 ?- config(V1,V2).
V1 in 3\/5,
V2 in 1..sup.
現在我想知道如何在 SWI-Prolog 的 C# 端口中獲得這個結果。 調用query.SolutionVariables[0]["V1"]
或query.SolutionVariables[0]["V2"]
給我中間變量。
對於 V1,我可以使用標記策略( res(X,L) :- setof(X, indomain(X), L).
),但這不適用於 V2,因為它對應於非有限域。
因此,簡而言之,如何使用 C# Swipl DLL 獲取解決方案變量的非有限域信息?
提前致謝。
?- Goal_0 = config(V1,V2), Goal_0, copy_term(Goal_0, Goal_0, C_0s).
Goal_0 = config(V1, V2),
C_0s = [clpfd:(V1 in 3\/5), clpfd:(V2 in 1..sup)],
V1 in 3\/5,
V2 in 1..sup.
因此,使用copy_term/3
來獲取所有附加的約束。 然后使用常用術語ffi 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.