【问题标题】:How to replace constants terms from python API in clingo / gringo?如何在 cligo / gringo 中替换 python API 中的常量术语?
【发布时间】:2021-07-07 08:20:57
【问题描述】:

假设我有以下文件foo.lp:

foo(x).

现在当我运行gringo -t -c x=1 foo.lp 时,我显然得到了:

foo(1).

现在我想知道如何实现与 Python API 中的 -c 命令行选项相同的行为,例如:

from clingo.control import Control
ctl = Control()
ctl.load('foo.lp')


#ctl.ground() # What to do here exactly?

这样我就可以访问已解决程序的基本程序/模型并替换了常数项。

【问题讨论】:

标签: python logic-programming answer-set-programming clingo


【解决方案1】:

事实证明可以使用命令行参数初始化Control,这样就可以了:

ctl = Control(["-c", "x=1"])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    • 2011-05-01
    • 2021-02-02
    • 2013-04-22
    • 1970-01-01
    相关资源
    最近更新 更多