Comments (7)
I think I'm running into similar issues with a different example - the greet example of the docs. I noticed that if I explicitly set priority via salience, then there are no issues. If not, I run into issues on both examples.
In the greet example I managed to find that activations are being wrongly removed from the list in the _update_agenda method in strategies.py, because the keys seem to be the same for different activations (when salience not specified!).
Basically, I see that the location question is popped from the list to be fired and then _update_agenda removes the name question from the list, mistakenly. Also, I didn't manage to understand why it is popping activations and then deleting them in the _update_agenda. I'm sure there's a reason for that, but I can't see it.
Commenting out the del statement in _update_agenda makes the greet example work fine as well. Let me know if you think that they are different issues. I can create another one. I'll leave the greet code here, as it might be helpful:
from experta import *
class Greetings(KnowledgeEngine):
@DefFacts()
def _initial_action(self):
yield Fact(action="greet")
@Rule(Fact(action='greet'),
NOT(Fact(name=W())))
def ask_name(self):
self.declare(Fact(name=input("What's your name? ")))
@Rule(Fact(action='greet'))
def ask_test(self):
self.declare(Fact(test=input("What's your test? ")))
@Rule(Fact(action='greet'),
NOT(Fact(location=W())))
def ask_location(self):
self.declare(Fact(location=input("Where are you? ")))
@Rule(Fact(action='greet'),
Fact(name=MATCH.name),
Fact(location=MATCH.location))
def greet(self, name, location):
print("Hi %s! How is the weather in %s?" % (name, location))
engine = Greetings()
engine.reset() # Prepare the engine for the execution.
engine.run() # Run it!
from experta.
I just installed directly from github now (was running 1.9.2 installed with pip) and the bug @orenwangtencent reported has been fixed. I can't reproduce it anymore and I see that the activations' keys are now different :) I will check the greetings example again and if I find something I'll report on a different issue.
from experta.
Oh thank u a lot, @grizonic . I tried to install from the develop branch of the GitHub, yet still no luck. But assigning a randint for salience definitely do the trick. I am trying to figure out the activation keys now!
from experta.
HI! Sorry for the delay and thank you for reporting this.
I am working on it and will be fix soon.
from experta.
I've just published v1.9.4, the random behavior should be fixed now. Please check if this works for you.
On the other hand, the new tests that I wrote to fix this issue arose two new issues #12 and #13.
#12 in particular causes that the order of execution between runs can be undefined when the strategy doesn't have strict rules. This will be the case for example with your code if you remove the declare statement. If you do so both rules will match but with the current implementation the order in which red_light and yellow_light get run can be different between different executions of the Python interpreter.
from experta.
Yeah it worked normally now, both the example above and my own code. @nilp0inter thx very much! BTW Really Good library, to learn from and integrate into projects.
from experta.
Glad to hear that! Thank you both @orenwangtencent and @grizonic .
from experta.
Related Issues (20)
- Last activation is not executed HOT 2
- RETE network generation is not idempotent
- Activations are not well-ordered HOT 1
- ’EXISTS' cannot return accuracy results, influenced by the pattern order insider. HOT 9
- NA
- Firing a rule only once HOT 1
- Fact can only be modified once based on the fact name HOT 4
- Strategy bug found by hypothesis
- Investigate negative delays HOT 1
- Need some help about the GC of KnowledgeEngine HOT 1
- multifieldwildcard HOT 1
- How to show fired rule. HOT 1
- Looping Experta for use with a chatbot
- Implementation of the water jugs problem
- Is there still room for optimization in the judgment?
- Is there an easy way to modify facts?
- Python expert system facts generated from an Excel table
- experta
- Check that the fact does not exist, but with the data of another fact
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from experta.