Ongoing skills knowledge session

I work in a school district and we plan to use Drools to implement the following types of rules for students in district schools:

  • If the student has 3 absences during the year, their attendance rate goes into the WARN state.
  • If the student has 6 absences during the year, their attendance rate becomes CRITICAL.
  • If the student has 3 main cases of behavior during the year, their behavior indicator changes to the WARN state.
  • If the student has 2 minor and 2 main cases of behavior during the year, their indicator of behavior passes into the status of CRITICAL.
  • ... these are just examples from my head, but there are many other rules of a similar nature.

All of these rules can simply be expressed with the help of an expert Drools. In addition, student rule processing does not have to be synchronous. I have a couple of questions about the best way to implement this.

  • From one point of view, this can be considered as a system for monitoring the flow of events. This made me think of creating a session with a state in which each new event would be inserted. However, events occur within 9 months and are relatively infrequent. In addition, we could build a school session or a session for each student.

    • Will keeping a session in mind for a long time be a problem?
    • If the server failed, we would need to rebuild the session state from scratch or it would be advisable to take regular snapshots and simply restore the facts that have occurred since the snapshot.
  • Another option would be to save the session for each student after processing the event for that student. When the next event arrives, we will retrieve their session from the repository and insert a new fact. Thus, we will not need to extract all the facts for each engine start in order to obtain student status. Will such a configuration be supported? Are there any flaws in this?

  • A third approach would be to answer a new fact for the student, extracting all the other facts that must fulfill the rules, create a new KnowledgeSession and run the rules.

Any advice on what might be the best approach is welcome.

Dave

+4
source share
4 answers

I would go with solution number 2: one session per student. Considering the fact that you are not going to interact with the session too much, I would save it in db and only restore it as needed: a new absence / incident appears, the session for this student is restored with db, the facts are inserted, the rules are fulfilled and the received data is restored status.

The main drawback that I see in this scenario is that creating rules for more than one student is not easy, and you must feed your facts in more than one session. For example, if you want to receive a warning if you have more than 10 students with CRITICAL status in the same class. In this case, a session per class will be sufficient. So, as you can see, you have to decide what is best for you. But no matter which unit you choose (school, class, student), I would recommend the flow of execution that I mentioned earlier to you.

Drools already comes with support for saving databases using JPA. You can get more information about this function here: http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/#d0e3961

The basic idea is that instead of creating your ksessions with kbase.newStatefulKnowledgeSession() you are using a helper class called JPAKnowledgeService . This class will return a StatefulKnowledgeSession wrapper, which will retain its state after each method call. In this class, you will find 2 important methods: newStatefulKnowledgeSession() to create a new ksession and loadStatefulKnowledgeSession() to retrieve an existing session from the database.

Hope this helps,

+2
source

There is a fourth option to simplify maintenance. Create a single health knowledge session for the entire school district for all students. After the successful completion of each event, a session is saved if you need to restore working memory in the event of a JVM failure. You will need a larger RAM and heap space allocation, but RAM is cheap these days. (We use 32 GB of RAM and allocate 16 GB of XM and Xmx). Most likely your JVM will never go down if you have a 24x7 server.

+1
source

Being lazy, I would go for a third approach. I will store all events in the database, then I will process all students in batch mode once a day, week, month (as needed). This will allow you to create only one session with rules covering several students, classes, etc. If you do not have 3+ million students, you will be fine and this will be an app for performers.

0
source

Thanks for the suggestions and advice. I tend to number 2 for two reasons:

  • I think that gathering all the facts for a given student to repeat them from scratch for every event that comes up will be a difficult process that I would rather avoid.
  • Use case I deal with models as a very long monitoring process that makes me believe (after reading the use cases for Fusion) that inserting events into a constant KnowledgeSession is the way to go.
  • I do not think that the problem of the problem space (that is, the student and the classroom, school or the whole area) is a problem. If we need indicators in the class, then we will only have a new rule base for classes, which also consumes the corresponding events (tests, absence, etc.).

One caveat is that if the rules change, we need to reevaluate all affected students against the new rule base, which means collecting all the facts from the beginning of the school year. This should not happen at all, but if it becomes more frequent, I can move on to the 3rd approach.

Thanks again for the help.

0
source

All Articles