Angel \”Java\” Lopez on Blog

February 25, 2012

AjRools (1) Rule Engine in C#

Filed under: .NET, AjRools, Open Source Projects, Rule Engine — ajlopez @ 6:50 pm

Since last year, I was conducting a bit of research about rule engines, specially in Java:

I reviewed JBoss Drools Expert (see Past December, I assisted to Buenos Aires JBoss Meetup (see Spanish post)

In the old eighties, I met Rete Algorithm (see The Rete Matching Algorithm, Dr.Dobb’s). After all that, I decide to implement my own rule engine, in C#. You can check my progress at:

This is the current solution:

As usual, it was coded using TDD.

I have facts, that are asserted, like Temperature = 38. And rules, that based on the asserted facts, produce other asserted facts (I plan to add actions, too, beyond fact assertions). A rule example:

# Rules example
# Rule for Child Fever
		Temperature > 38
		Age <= 12
		HasFever is true
# Rule for Adult Fever
		Temperature > 37
		Age > 12
		HasFever is true

I have ideas to extend the rule engine to support objects with properties, not only variables:

	p is_a Patient
	p.Temperature is 39
	p.HasFever is true

but this feature is still in progress. I didn’t adopt the Rete algorithm, yet, or something similar. I want to have a running implementation, with tests. Then, changing internal algorithm is like an exercise on refactoring.

Pending work: more object+properties support, session (client use of the internal implementation), etc.

Keep tuned!

Angel “Java” Lopez


  1. Nice! Maybe this can eventually lead to a C# equivalent of drools, but with LINQ an other C# isms.
    Thanks for starting this. Notice that there is a Drools Planner as well. This is equivalent to
    Microsofts Solver Foundation CSP ( ). I keep hoping
    that Microsoft would try to blend the rules engine that came with WF (but make it RETE) and the Solver.
    Seems like the rules engine has gone no where for years.

    Comment by Will Smith — February 25, 2012 @ 10:45 pm

  2. […] object support in AjRools Expert complete – Add method with parameters in AjLang complete – Post about my work on AjRools complete – New post about my work on AjLisp in Ruby pending – Post about my […]

    Pingback by New Month’s Resolutions: March 2012 « Angel “Java” Lopez on Blog — March 7, 2012 @ 7:09 pm

  3. […] en AjRools Expert Completo – Agregar soporte de métodos con parámetros en AjLang Completo – Post sobre mi trabajo en AjRools Completo – Nuevo post sobre mi trabajo en AjLisp in Ruby Pendiente – Post […]

    Pingback by Resoluciones del Nuevo Mes: Marzo 2012 - Angel "Java" Lopez — March 7, 2012 @ 10:06 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: