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

SatisfactionLink does not leave behind *-PatternGroundingKey-* #2215

Open
buj opened this issue Jun 10, 2019 · 5 comments
Open

SatisfactionLink does not leave behind *-PatternGroundingKey-* #2215

buj opened this issue Jun 10, 2019 · 5 comments

Comments

@buj
Copy link
Contributor

buj commented Jun 10, 2019

See example pattern-matcher/satisfaction.scm.

Supposedly, when a SatisfactionLink is evaluated, the satisfying assignment should be attached to the key *-PatternGroundingKey-*---thus one should be able to retrieve it by running

(cog-value satlink (Predicate "*-PatternGroundingsKey-*"))

This is however not the case: running (cog-keys satlink) reveals that in fact no keys are attached to satlink.

@linas
Copy link
Member

linas commented Jun 10, 2019

Hmm. Yeah, its a beta feature that must have gotten broken. It was added to fix a performance problem for ghost, at the request of @amebel but I guess that it is no longer used, and got borken along the way.

The correct fix is to go ahead and do #1502 and maybe #1507 and maybe #1750 ...

... but this is quite a large bit of work, and no one is banging down the doors for it yet, so it's been on the back burner. I think it would be fairly easy(?) to code, once the design is clear; but there are enough subtle questions that the best design isn't entirely clear. (I did start coding this, once upon a time, and promptly ran into issues)

@linas
Copy link
Member

linas commented Feb 10, 2020

OK, so there is now a better solution; see the example that is part of pull req #2500 . This provides a more flexible, easier-to-use API than the original *-PatternGroundingKey-* thing. Although I'm still stumped as to how ghost is able to work, given that this fairly major function got broken along the way. @amebel any comments about ghost, and how it deals with cached search results?

@amebel
Copy link
Contributor

amebel commented Feb 10, 2020

it used _satisfiability_cache to pass the grouding to implicator, see here. Values were not that mature at the time of implementation.

@linas
Copy link
Member

linas commented Aug 12, 2020

See issue #2530 and specifically, see the branch-new cog-execute-cache! which is the latest and best way of doing this. That is, the example code should instead say (cog-execute-cache! (SatisfactionFoo) (Pedicate "*-PatternGroundingKey-*)) ...

Here's the docs:

cog-execute-cache! EXEC KEY [METADATA [FRESH]]
   Execute or return cached execution results. This is a caching version
   of the `cog-execute!` call.

   If the optional FRESH boolean flag is #f, then if there is a Value
   stored at KEY on EXEC, return that Value. The default value of FRESH
   is #f, so the default behavior is always to return the cached value.

   If the optional FRESH boolean flag is #t, or if there is no Value
   stored at KEY, then the `cog-execute!` function is called on EXEC,
   and the result is stored at KEY.

   The METADATA Atom is optional.  If it is specified, then metadata
   about the execution is placed on EXEC at the key METADATA.
   Currently, this is just a timestamp of when this execution was
   performed. The format of the meta-data is subject to change; this
   is currently an experimental feature, driven by user requirements.

   At this time, execution is synchronous. It may be worthwhile to have
   an asynchronous version of this call, where the execution is performed
   at some other time. This has not been done yet.

@linas
Copy link
Member

linas commented Aug 12, 2020

p.s. @amebel there is no urgent need to change _satisfiability_cache but I think that the idea of the cog-execute-cache! is the right long-term direction. It still has rough spots, e.g. the meta-data, and it is not clear if the cached results should be stored in files ... (and how to stop them from being stored in files.... etc.)

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

No branches or pull requests

3 participants