Code Monkey home page Code Monkey logo

Comments (5)

ricardobur avatar ricardobur commented on June 30, 2024

Hi @nilp0inter,

I am using pyknow library to build some logic based on logic and facts. I have faced the same behavior as you explain in this issue. In fact, I had the same error as it seems in one point (not exactly when) the activations in the agenda have a factid that has being retracted (so it does not exists any more).

I have created on a fork the behavior that I would need, but I suppose the problem should be solved by ensuring the activation facts has the proper factid that stays in the facts list of the engine, no?

Thanks!

from pyknow.

nilp0inter avatar nilp0inter commented on June 30, 2024

This is maybe a regression after the last optimizations made this year. A couple of regression tests and a git bisect could help here.

from pyknow.

lucasmpaim avatar lucasmpaim commented on June 30, 2024

+1 any updates on this?

from pyknow.

lucasmpaim avatar lucasmpaim commented on June 30, 2024

for my case this decorator solves my problem:

def safe_access_fact(attr, fact_type):
    def func_receiver(func):
        def inner(*args, **kwargs):
            database = args[0]
            for fact in database.facts.items():
                if isinstance(fact[1], fact_type):
                    return func(*args,
                                **kwargs,
                                **{attr: fact[1]})
            return func(*args, **kwargs)
        return inner
    return func_receiver

And the use:

    @Rule(
        EXISTS(SystemPreCheck()),
        Common(current_state=QuestionsBlock.SYSTEM_PRE_CHECK),
        ~SystemPreCheck(have_error_within_time_limit=W()))
    @safe_access_fact('system', SystemPreCheck)
    def have_error_within_time_limit(self, system):
        read = auto_read([True, False])
        print(f'Existe defeito atribuído dentro do prazo?: {"y" if read else "n"}')
        self.modify(system, have_error_within_time_limit=read)

if I use the AS.* << operator, I receive a retracted fact, causing the error

from pyknow.

nilp0inter avatar nilp0inter commented on June 30, 2024

Already fixed in Experta

from pyknow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.