Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add single-shot solving option #269

Merged
merged 2 commits into from
Feb 22, 2021
Merged

add single-shot solving option #269

merged 2 commits into from
Feb 22, 2021

Conversation

rkaminsk
Copy link
Member

@rkaminsk rkaminsk commented Feb 20, 2021

See also potassco/clasp#64.

  • add --single-shot option to enable some optimization that cannot be applied in the multi-shot case
  • raise an error if more than one step is started in single-shot mode
  • add unit tests

@rkaminsk rkaminsk added this to the v5.5.0 milestone Feb 20, 2021
@rkaminsk rkaminsk self-assigned this Feb 20, 2021
@rkaminsk rkaminsk marked this pull request as ready for review February 22, 2021 10:30
@rkaminsk rkaminsk merged commit b366b64 into wip Feb 22, 2021
@rkaminsk rkaminsk deleted the feature/singe-shot branch February 22, 2021 10:46
@ssardina
Copy link

@rkaminsk question on the --single-shot and the Python API: can the option be set via the configuration of the Control? I couldn't find it but maybe I am missing it?

(sorry I follow-up here just in case somebody else find it)

@rkaminsk
Copy link
Member Author

The option has to be set upon creation of the control object. It cannot be set via the dynamic configuration.

@ssardina
Copy link

wow, thanks for the quick reply!

The option has to be set upon creation of the control object. It cannot be set via the dynamic configuration.

You mean via the arguments option of the Control class like this, right?

control = clingo.Control(arguments="--single-shot")

That is all good for my own application that creates a Control, but I couldn't see how to pass arguments if I use teh Application framework that comes with Clingo

Presumably the control object is created automatically, so is there any way of passing arguments like --single-shot?

@rkaminsk
Copy link
Member Author

wow, thanks for the quick reply!

The option has to be set upon creation of the control object. It cannot be set via the dynamic configuration.

You mean via the arguments option of the Control class like this, right?

control = clingo.Control(arguments="--single-shot")

That is all good for my own application that creates a Control, but I couldn't see how to pass arguments if I use teh Application framework that comes with Clingo

Presumably the control object is created automatically, so is there any way of passing arguments like --single-shot?

For the application, it can be passed on the command line as with clingo.

In principle one can also inject it into the options befor calling clingo_main. It's a bit hacky, but might suite your purpose:

args = sys.argv[1:]
if not "--single-shot" in args:
    args.append("--single-shot")
clingo_main(App(), args)

@ssardina
Copy link

Ohh, I see... so is clingo_main() function the one that creates the Control object (and uses args as arguments) and passes it to main?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants