Menu

global variables

Help
Dr_Muttley
2012-05-16
2013-05-17
  • Dr_Muttley

    Dr_Muttley - 2012-05-16

    Hi Bruce,

    I have the following problem: I have a very expensive BC rule that I would like to be run only once, and its results stored somewhere for further retrieval during the proof.

    The initial idea would have been to have an auxiliary knowledge base, but then "assert" is not in the kfb syntax, so the BC rule can't store the result there.

    Maybe I could do something really silly, such as store the result in an environment variable or write to a tempfile. Is there any more elegant solution within the framework, e.g. manipulating the context?

    Thanks,
          M.

     
  • Bruce Frederiksen

    You can add facts to fact bases by using a python premise in the when clause.  Then you can add BC rules to check for the fact.  If it finds the fact, it succeeds immediately.  Use special.claim_goal() to prevent the expensive BC rule from running in that case.

    You can also store the success or failure of the expensive BC in the fact to prevent rerunning the expensive BC rule in a failure situation.

    Let me know if you need more details on how to do any of this.

     
  • Dr_Muttley

    Dr_Muttley - 2012-05-17

    Hi,

    thanks, this is an interesting option. But how is the engine defined in the python premise?

    After a night of sound sleep, I figured out my problem can be factorized in two set of rules, run after each other. So I thought the following: I first activate ruleset #1, and then use the output of engine.prove_goal to write out an auxiliary kfb file. Then I either force a recompile (is it possible, btw?) or I instantiate a second engine using ruleset #2.

    Does it sound a viable option to you?

    Thanks,
           M.

     

Log in to post a comment.