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

Error with external example: Term::simplify must be called after Term::unpool #179

Closed
d4hines opened this issue Nov 26, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@d4hines
Copy link

d4hines commented Nov 26, 2019

In trying to work with the external assignment examples, I've been hitting this error. It occurs both in Lua and Python (the output below is from Lua):

$ cd examples/clingo/external/ && clingo external.lp external-lua.lp
clingo version 5.4.0
Reading from external.lp ...
*** ERROR: (clingo): main: error: error calling main:
  RuntimeError: [string "external-lua.lp:1:1-13:6"]:3: Term::simplify must be called after Term::unpool
stack traceback:
  [C]: in method 'ground'
  [string "external-lua.lp:1:1-13:6"]:3: in function 'main'
  [C]: in ?

UNKNOWN

Models       : 0+
Calls        : 1
Time         : 0.045s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 0.000s

Here's my versions:

$ clingo --version
clingo version 5.4.0
Address model: 64-bit

libclingo version 5.4.0
Configuration: without Python, with Lua 5.3.4

libclasp version 3.3.5 (libpotassco version 1.1.0)
Configuration: WITH_THREADS=1
Copyright (C) Benjamin Kaufmann

License: The MIT License <https://opensource.org/licenses/MIT>

As an aside, I've got a question about external atoms for my use case. In external.lp, there's the fact #external p(1;2;3). That means the model will only be able to solve against one of those 3 values, right? My domain is dealing with monitor coordinates. Modeling a 4k monitor with coords(0..4096,0..2160) consumes about a gigabyte of memory, which is unacceptable for my application. Is there a way to use externals parameterized over unbounded domains? Alternatively, coords will only ever have one value at a time - is there some other way to incrementally ground against the one, changing value? Or am I really looking for lazy grounding at this point?

@rkaminsk
Copy link
Member

This is a regression in clingo-5.4. As a workaround for now you can replace

#external p(1;2;3).

by

#external p(1..3).

I'll fix the issue for the next release.

Regarding your question. Maybe you should not use multi-shot solving at all or at least limit it to a small number of steps. Maybe you can delete your control object and create a new one after one action is processed. Also note that there is a small caveat, currently clingo does not free the memory it uses for its symbols until the application exits. Symbols will be reused but you might still end up having symbols for all coordinates. This is something I am planning to address but it won't happen anytime soon.

@rkaminsk rkaminsk self-assigned this Nov 27, 2019
@rkaminsk rkaminsk added the bug label Nov 27, 2019
@rkaminsk rkaminsk added this to the v5.4.1 milestone Nov 27, 2019
rkaminsk added a commit that referenced this issue Dec 2, 2019
The check whether an external contained a pool was wrong.
@rkaminsk rkaminsk closed this as completed Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants