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:

http://delicious.com/ajlopez/ruleengine

I reviewed JBoss Drools Expert (see http://delicious.com/ajlopez/drools). 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:

https://github.com/ajlopez/AjRools

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
rules
# Rule for Child Fever
rule
	when
		Temperature > 38
		Age <= 12
	then
		HasFever is true
end
# Rule for Adult Fever
rule
	when
		Temperature > 37
		Age > 12
	then
		HasFever is true
end
end

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

rule
when
	p is_a Patient
	p.Temperature is 39
then
	p.HasFever is true
end

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

http://www.ajlopez.com

http://twitter.com/ajlopez

3 Comments »

  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 ( http://archive.msdn.microsoft.com/solverfoundation ). 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:

WordPress.com Logo

You are commenting using your WordPress.com 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

The Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 68 other followers

%d bloggers like this: