【问题标题】:Counting the number of true predicates and limiting计算真谓词的数量并限制
【发布时间】:2017-01-25 12:20:01
【问题描述】:

有没有一种特定的方法可以限制使用指定事实的可用真实谓词的数量?

目前我总共有 (2)。作为一个事实。 我认为这会起作用:

:- 总计(N), #count{x:something_to_limit(x)} = K, K=N.

但是,这不会将 something_to_limit 谓词的数量限制为指定的 total(2) 事实,其中 N 等于 2。

任何帮助将不胜感激:)

【问题讨论】:

    标签: answer-set-programming clingo


    【解决方案1】:

    x:something_to_limit(x) 中的x 是一个常量符号,您可能想使用变量X。约束

    :- total(N), #count{X:something_to_limit(X)} = K, K=N.
    

    应该可以。

    【讨论】:

    • 这将消除谓词 something_to_limit 对于恰好 2 个常量为真的所有答案集(使用 total(2))。如果你想得到恰好 2 个原子为真的解,你需要在 #count 之前添加 not
    猜你喜欢
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多