Comments (3)
Hi @richiesgr ,
For your problem, I would do something like this:
- add rules to engine
- for each input, run it against the engine to retrieve the matching rules.
- map each matching rule to a score
- sum the scores - that is the result for a single input
- repeat 2-4 for each input
- take the input which had the best result.
Code might look something like this:
static final Map<Rule, Integer> SCORES = new HashMap<>();
SCORES.put(rule1, 30);
SCORES.put(rule2, 50);
//etc...
int bestScore = Integer.MINIMUM;
Input bestInput = null;
for(Input i : inputs){
List<Rule> matchingRules = engine.getMatchingRules(i);
int score = matchingRules.toStream().map(r -> SCORES.get(r).sum();
if(score > bestScore){
bestScore = score;
bestInput = i;
}
}
//now use bestInput...
Would that satisfy your requirements?
from rules.
Of course it seems to be ok
my first question : it is not heavy to process like this ? I want to use it in low latency application based on Akka
Second question: is it thread safe at the engine level and MEVL itself? ( do I need to instanciate each time a new engine ?)
Thanks
from rules.
See DefaultEngineTest.testMultithreadingAndPerformance()
(https://github.com/maxant/rules/blob/master/rules/src/test/java/ch/maxant/rules/blackbox/DefaultEngineTest.java) => yes it is threadsafe and fast using MVEL. You do NOT need to instantiate several engines - just create one, as in the test.
from rules.
Related Issues (8)
- First it's cool ,second i have some questions. HOT 1
- Not able to initialize Engine on Android. HOT 1
- Help improve the logger performance HOT 1
- scalable to thousands of rules HOT 1
- Building Java 8 example based on Java8EngineTest - scala error? HOT 1
- Help improve logging performance. Debug logging HOT 2
- No Response after 10th rule HOT 1
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 rules.