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

Is it needed for creating a shared OrdinaryMatchNode? #44

Open
sc-syf opened this issue Dec 3, 2018 · 1 comment
Open

Is it needed for creating a shared OrdinaryMatchNode? #44

sc-syf opened this issue Dec 3, 2018 · 1 comment

Comments

@sc-syf
Copy link

sc-syf commented Dec 3, 2018

I checked the source code for creating OrdinaryMatchNode at https://github.com/buguroo/pyknow/blob/develop/pyknow/matchers/rete/utils.py#L167-L186

And compared it to the paper's figure 2.2(a) (matched for C1^C2).

Is it needed for creating a shared OrdinaryMatchNode If two conjunctive normal form has the same facts?

for example,
Rule(OR(AND(Fact(a=1), Fact(b=2), Fact(c=3)), AND(Fact(a=1), Fact(b=2), Fact(c=4))))
It seems that two OrdinaryMatchNode node for (Fact(a=1), Fact(b=2)) will be created.
Is it right?
or should we need a same OrdinaryMatchNode for (Fact(a=1), Fact(b=2))?

@nilp0inter
Copy link
Contributor

Our implementation is not based on that paper but in this one.

I didn't have time to inspect the code yet, but I think you are right. I transcribed the paper's example and there is more OrdinaryMatchNode instances that it should:

from pyknow import *

class KE(KnowledgeEngine):
    @Rule(OR(AND(Fact(1), Fact(2), Fact(3)),
             AND(Fact(1), Fact(2), Fact(4), Fact(5)),
             AND(Fact(1), Fact(2), Fact(4), Fact(3))))
    def test(self):
        pass

ke=KE()

ke.matcher.show_network()

network2

I will reread the original paper and the one you pointed out and see if there is any differences we can use to optimize the creation of the beta network.

Thank you!

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

No branches or pull requests

2 participants