Comments (4)
@arsalans interesting concept. My understanding of decision trees is that for each permutation of the conditions, there is a defined set of actions. Although it would be easy for the engine to take in a list of conditions and compute a rule per permutation, I'm confused as to how the engine would know the appropriate event to fire in each circumstance. Maybe I just need you to expand on the use case you provided so I can understand the problem you're trying to solve.
from json-rules-engine.
@CacheControl So, how about if I write my rule like this, and again, I am trying to be as naive as possible:
var decisionTable =
{
{
"color": "Blue",
"price": 10
},
{
"color": "Red",
"price": 11
},
{
"color": "Green",
"price": 13
},
{
"color": "Yellow",
"price": 14
}
};
var helper =
{
"condition": "color",
"event": "price"
};
new DecisionTable (decisionTable, helper);
So now, the DecisionTable object knows what are the conditions and what are the events to send.
from json-rules-engine.
@arsalans Ah ok, I think I get it now. In json-rules-engine vernacular it's essentially wanting to vary the event based on which condition succeeded.
To me, this almost feels like an accessory package that would act as a rule generator - it would take in the decision tree data structure you posted above, and use it to generate a rule per decisionTable row. json-rules-engine would be responsible for the lower-level execution of the generated rules.
Alternatively, you may want to look at the ruleResult feature just released in 2.0.0 - you can use the ruleResult
argument provided in the success/failure events to determine which condition was successful, and use the condition's factResult
("yellow", "red", etc) to lookup from a prices hash you maintain outside the engine.
It terms of whether or not this belongs in json-rules-engine itself, right now it feels like something I'd like to keep separate; I want to keep json-rules-engine as the low level executor of basic boolean logic + firing events, while more complex rule orchestrations such as decisionTables are probably better suited as plugins/extensions.
from json-rules-engine.
Here's the ruleResult docs I mentioned above.
from json-rules-engine.
Related Issues (20)
- Adding path values to events HOT 2
- is this project still active HOT 9
- Not able to resolve JsonPath when it includes a where condition HOT 1
- Operator availability - between operator HOT 1
- OnSuccess/OnFailure properties as part of the rule - Security Issue
- Slow performance while having large array of facts. HOT 9
- How to feed engine multiple facts as array! HOT 1
- Complex rule for the fact HOT 2
- woops HOT 1
- Feat: Type-safety using a FactTypeMapping HOT 1
- Is it possible to make sure that a fact triggers at most one rule? HOT 2
- Uncaught TypeError: (0 , _hashIt2.default) is not a function HOT 8
- Error: Cannot find module 'lodash' HOT 1
- problems with the execution of my rules HOT 4
- Example issue - undefined parameter HOT 1
- RuleResult class missing from type declarations HOT 1
- What the best way to launch the rule engine
- Parent child rule
- Ability to stop rules execution after success for array of inputs
- How to create multiple 'aggregate' facts on a 'parent' object calculated from child objects (composition)
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 json-rules-engine.