1

Suppose I have a the following file foo.lp:

foo(x).

Now when I run gringo -t -c x=1 foo.lp I obviously get:

foo(1).

Now I want to know how to achieve the same behavior as the -c command line option from the Python API, like when I have:

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


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

So that I can access the ground program / models of the solved program with the constant term replaced.

user1747134
  • 2,374
  • 1
  • 19
  • 26
  • 1
    I think you are interested in grounding subprograms, i.e. use the program directive with arguments and ground as you like. Here are some examples: https://github.com/potassco/clingo/blob/master/examples/clingo/multishot/opt.py – tphilipp Jul 07 '21 at 18:28

1 Answers1

2

Turns out it's possible to initialize Control with the command-line parameters, so this does the trick:

ctl = Control(["-c", "x=1"])
user1747134
  • 2,374
  • 1
  • 19
  • 26