Monday, July 25, 2011

Guvnor's Asset Viewer

New for 5.3.0.Beta1 we have changed where asset groups are shown.

Those familiar with Guvnor 5.2.0 (and prior) will know asset groups have previously been listed within the Explorer tree-view underneath the package name. Starting from 5.3.0.Beta1 we have moved asset groups to a new screen, shown as a tab in the main view.

The format of the new screen is being trialled for 5.3.0.Beta1. There has been some discussion whether a single table containing all assets would be better - with collapsible rows to group different types of asset.

The immediate problem with this approach is however that finding different asset types on a "paged table" becomes more cumbersome for the user; as they'd have to sort by type and page through.

We therefore ask for community feedback.

The asset groups are configurable within a compile-time preferences file; src/main/resources/drools-asseteditors.xml. This file is used at GWT compile time to wire-up asset types with their respective editor, group and group icon.

An example extract from the foregoing file looks like this:-

<icon>images.ruleAsset()</icon> <title>constants.BusinessRuleAssets()</title>

We have also made a few changes to the Knowledge Bases tree view:-
  • Hierarchical view, as has been the default up to 5.2.0.Final.
  • "Flat" view with no nesting
  • The tree's nodes can be fully expanded or collapsed.

As always you can watch a video demonstrating these features here or here.

Wednesday, July 20, 2011

Paul Haley to Keynote Rules Fest

I'm really excited that Rules Fest has managed to persuade Paul Haley to keynote. So if you haven't bought your tickets yet, what are you waiting for?

Paul Haley
"Currently a consultant at Vulcan, Inc. and principal at Automata, Inc., Paul has been involved in practical AI since the early 80's. His accomplishments span selling, developing and applying advanced technology in securities, banking, insurance, health care, telecommunications, and government applications. At Inference Corporation, he co-developed ART (Automated Reasoning Tool), the progenitor of CLIPS and later Jess."

ART really did some amazing stuff back in the day and was probably, and may still be, the most expressive rule engine:
"After benchmarking many expert system shells and rule-based programming languages, NASA standardized on Rete Algorithm-based production systems and selected ART over OPS5, presumably because ART is more expressive and more functional." (Answers to common questions about AI)
Although I hope we are starting to bite at it's heels :)

Paul was one of the first, over 20 years ago, to write a true opportunistic backward chaining (OBC) system with automatic subgoaling, able to handle real variable unification in a prolog derivation query like way. This very much inspired the OBC work in Drools that we are still in the process of developing:
Data-Driven Backward Chaining (alternative link)

Haley Authority was recognised as the leader in ontologies and natural language authoring. This is very much refected in Paul's favour topics these days around semantic ontologies and event processing. I'm sure he'll be discussing these in his keynote, so you really shouldn't miss it.

Haley Authority 5.2 review

Haley Authority 6.0 review

Monday, July 18, 2011

Mario Fusco to join as core Drools engine developer

It gives me great pleasure to announce that Mario Fusco will be joining the Drools team to work on the core engine in August.

Mario is the author of OSS Lambdaj which brings functional programming and closures to java, and the Hammurabi Scala rule engine.

Lambdaj (JavaOne Audio podcast)


Mario initially will be focusing on improving the end user experience of the core engine, specifically in authoring DRL. Below is a list of areas he'll be responsible for, during his first 6 months. Of course he isn't limited to just those :)
  • Improved syntax error reporting
  • Killing all parser bugs and also expression and action evaluation bugs.
  • Better masking of the underlying execution engine (MVEL leaks too much)
  • Helping us move to a single language (no more dialects).
  • Micro benchmarking so we can better track performance and memory regressions
  • ASM bytecode compilation so we can reduce our dependency on JDT over time, which is too heavy. ASM will allow a more runtime JIT approach to expressions and actions.
  • Maintaining the Eclipse DRL editor.
  • Help with future DRL design discussions especially on functional programming.
More importantly this allows core maintenance to be spread across more people, which gives Edson and myself more time to do research so we can innovate faster.

Recent Video and Audio Interviews

RedMonk has published a video interview online and JBoss Asylum an audio interview with myself and Michael Anstis.

Red Monk

JBoss Asylum

Thursday, July 14, 2011

Taking the rest of the year off

So my time sheet says I've worked my 1920 hours this year already, so I guess I'll be taking the rest of the year off in lieue.


btw j/k - on taking the time off, not on hours worked.

Declarative sub-classing comes to Guvnor

Following in the footsteps of Drools Expert 5.2, we have added support for declarative sub-classing to Guvnor.

Visual declarative modelling support within Guvnor now supports sub-classing your imported POJO model and/or existing declared types.

Obviously the guided editors reliant upon your fact model, e.g. guided rule editor, now also include inherited fields when authoring assets.

Here's a couple of screen shots showing it is use:-

Declarative modelling

Defining a rule

You can also watch the feature being used here.

Wednesday, July 13, 2011

jBPM Form Builder project follow-up of the week

As I've mentioned before, the jBPM Form Builder project has been going for a few weeks and it's getting more interesting every week! Today we finally added a REST API that allows the project to store and obtain form definitions in Guvnor. The API exposes forms through the URL:

And UI components throught the URL

Here's a video by clicking on the screenshot

As new functionalities go, the Form Builder now has the following new features:

- REST API for forms and ui components
- Copy / Cut / Paste functionalities, both with keyboard shortcuts and menu options
- Tree view, from which there's a screenshot below:

You can see all new technical configurations from here
See you all next wednesday for a new update, and feel free to comment!

Thursday, July 07, 2011

Develop complex jBPM processes all in Guvnor? Yes, you can!

(click on image to view the video)
Click here to view the video!

The above video showcasts some of the new jBPM web-based tooling support added to Drools Guvnor and the Oryx Designer used by jBPM to allow both business users and developers to create complex BPMN2.0 processes without depending on the traditional development environments.

The new tooling support includes:
* jBPM Custom-workitem definition editor in Guvnor.
* Oryx Designer ability to store processes to PNG and PDF formats.
* Ability to view the BPMN2.0 source of the process in Guvnor.
* Oryx Designer ability to generate process task forms which are fully-executable in jBPM Console. Templates also include form validation support out-of-the-box.
* Tight integration between Oryx Designer and Drools Guvnor.

In this video we create a simple medicine checkout procedure process which used both human tasks and a custom email notification workitem all in Guvnor, then execute it inside jBPM Console.

Wednesday, July 06, 2011

jBPM Form Builder follow-up

jBPM Form Builder has changed a lot in the last week. We can finally add menu items to the server configuration from the UI, so you can save custom UI components to be reused by other users, or by you at some other time. Here's a small demo to see it working. Here's a current snapshot of the tool:

jBPM Form Builder

To make this work, a small refactor had to be done. Since GWT doesn't seem to support reflection on client side code, a map implementation of the methods in the representational model had to be added. In this way, all objects know how to repopulate themselves from a Map object and how to export themselves to a Map object.

On my next update, i'll try and have an exposed REST interface for form definitions, of which this is a tentative model:

String saveForm( FormRepresentation form ): It would recieve form representation though JSON, and return an identifier you can use to refer to the saved form definition instance later on.
String saveFormItem( FormItemRepresentation item ): The same as saveForm, but for a visual component that would be a part of a form later on. Also returns an identifier you can use to refer to the save form item definition instance later on.
UIComponentWrapper generateFormTemplate( String formId, String language ): Generates a wrapper with information about a given form template or visual component and its expected inputs
UIComponentWrapper generateFormItemTemplate( String formItemId, String language ): Same as before, but for a form item.

Feel free to share any points of view on this interface, and see you next week!

Traits, Duck Typing and Dynamic Semantic Learning

Duck typing is the ability to say that something implements an interface. In this article I'll focus on triples (sets of key value pairs) such as Maps in Java or Dictionaries in other languages - <Map-instance, key-obj, value-obj>. I will outline how the concepts of traits could be used in Drools to infer semantic abstractions over sets of triples, which allows for dynamic semantic learning over time. The terms map and triple set will be used interchangeably.

Duck Typing:
"When I see a bird that walks like a duck and swims like a duck and quacks like a duck, I call that bird a duck."

"the form of subject-predicate-object expressions. These expressions are known as triples in RDF terminology. The subject denotes the resource, and the predicate denotes traits or aspects of the resource and expresses a relationship between the subject and the object. For example, one way to represent the notion "The sky has the color blue" in RDF is as the triple: a subject denoting "the sky", a predicate denoting "has the color", and an object denoting "blue"."

Duck typing over triples is the ability to say that the instance that represents the set of triples can be treated like an instance of a interface. This allows static type safe access to dynamic triple structures, it also allows abstraction through semantic representation of what that thing is; i.e. it's not just a set of arbitrary triples, it is a Student. MVEL does not yet support the "dons", as in "wears" keyword, so please take this as illustrative. The keyword may change eventually but it was proposed by Davide Sottara, who is POCing this idea.

I'll use MVEL like syntax to demonstrate:
bean = [ name : "Zod", age : 150 ]

bean dons Human
assertEquals( "Zod", )
assertEquals( 150, bean.age)
Without the don's keyword to duck type the map to the interface this would not compile as the compiler would report a static typing error of unknown fields for “name” and “age”.

Now that we know duck typing can be used to allow static type safety access to map. What else can we do? In a rule based system if we used triples to represent facts (which is what semantic ontologies do) we can't declare up front what interfaces a map wears, and those interfaces might change over time too. So we can use special rules to dynamically apply traits to a triple set.
rule Human when

$tp : Map( this contains [ "name" : String, "age" : int ] )
$tp dons Human// that $tp instance is now recognised by all other rules that match on Human

rule HelloWorld when
$s : Human() // this will actually match against the Map "donned" to Human
println( "hello " + $ );
We can see the rule that applies the trait can probably have a first class representation for it's use case. Which makes the rules intent far more obvious thus increasing the readability and maintainability of the system.
trait Human( String name, int age ) when

In the above, "trait" is a new keyword and Human is the trait name. We pass all the fields and their type as arguments. The triple set must contain at least those keys, but of course it may contain more. Notice we have an empty "when" block. The reason for this is we can apply different logic as to when a trait is applied, beyond just matching known keys to fields.

For instance if someone is Human and is also 18 years of age or younger we can apply a further abstraction and say the are not just Human but also a Student. We use the "dons" keyword after the arguments to say the existing traits the Map must already wear, i.e. abstractions we already know about the thing.
trait Student( String name, int age ) dons Human  when

age( < 18; ) end
The proposed syntax would allow argument names to be used as the pattern head and the type is inferred. We could also allow operators to be used in the positional syntax. This is to give compact sugar for "Integer( this < 18 ) from age".

So now we have a system to detect and recognise sets of triples and declare what traits they have; what abstractions we infer for them. As the system learns new things keys may be added to the map and new abstractions can be inferred by declaring more traits,which in turn allows further reasoning. Keys may also be removed which results in traits being removed.

One of the problems of a purely tripled based approach is performance, both in terms of execution speed but more important memory usage. If "name" and "age" both have to be represented as objects the system is going to bloat fast. What we want is to allow a mixed type system of static and dynamic relations. The relations are what we refer to for each of the key/value pairs in the triple set, i.e. a property (bean getter and setter pair, normally on a member field) is a relation on a class.

When a normal bean is inserted we will know it don's all the interfaces it implements and thus all the properties those interfaces declares. When accessing those properties we will do so via the standard getter or setters. This means properties we know up front and that don't change, can be declare using standard java fields with getter and setters. Allowing quick access and low memory utilisation. However we will allow further relations (triples) to be associated with the instance, as “dynamic” properties.

The specialised 'trait' rules will uniformly detect existing static properties or dynamically added properties. It's important to remember that a trait is a runtime applied interface to given instance, and just that instance. Bean instances of the same concrete type can wear different traits at any given time. Except of course for the statically declare interfaces on the concrete implementation.

Lets work through a complete example now. Human is a type declaration which is generated as an actual class from which beans can be initiated, “name”, “age” and “gender” are static relations. Young, Boy and FussyEater are all interfaces. Human extends TripleSet so that we know that further dynamic relations can be added and traits applied. We detect the bean instance is “< 18” and thus the trait Young is applied and that if the gender is M the trait Boy is applied. Further if a property exists, either static or dynamic (the two are seamless in the syntax) called “dislikes” with a value of “carrots” we apply the FussyEater trait.
declare Human extends TripleSet

String name;
int age;
Gender gender; // M/F enum

trait Young(int age) dons Human when
age( < 18; )

trait Boy(Gender gender) dons Young when
Gender( Gender.M; )

trait FussyEater(String dislikes) dons Boy when
dislikes( “carrots”; )
Now that we have a system that can detect and declare fussy eaters, lets use it. First declare a person who is 16, that will be an actual bean instance. Then add the dynamic property “dislikes”. Finally insert a new command to give that person some ice cream.
// Lets declare a new triple for a given bean instance that we instantiated from Human

Human human = new Human( “Zod”, 16 )
human.add( [dislikes : “carrots”] )
insert ( human )
insert( new GiveIceCream( human ) );
We can now have a single rule that disallows fussy eaters from getting ice cream. How cool is that :)
rule “Don't give icecream to boys who are fussy eaters”

$f : FussyEater()
$d : GiveIceCream( $f; )
retract ( $d )
Because traits can be applied conditional on facts and facts can be logically inserted to be maintained by the truth maintenance system, that means we can have traits who existence is dependant on those logical insertions. When the series of premesis that creates the chain of logical insertiosn breaks the trait depending on it will be un-applied to the instance. See this previous blog for more details on TMS "Drools Inference and Truth Maintenance for good rule design and maintenance".

Drools Expert on Android

There was recently an interesting exchange of emails on the Drools user mailing list about running Drools Expert on Android, which has been the Holy Grail of some users for some time.

One particularly active community member on this front, Abhay Chaware, blogs about their experiences, tricks and tips here.

Unfortunately Abhay was unable to solve the final hurdle as the blog reveals, however let Abhay's research spur other talented community members to attempt the same and hopefully close the last(?) issue.

As the title of Abhay's blog suggests "At least I tried".

Saturday, July 02, 2011

Real-time planning with Drools Planner: demo video

Real-time planning problems, such as airport runway scheduling, have a paradox:
  • Optimizing such a planning problem into a usable, good solution takes minutes or even hours (because they are NP-complete).
  • The planning facts can change up to a few (milli)seconds before the planning is used.
So by the time the solver finds a good solution to the problem, the problem might have already changed.

Yet, JBoss Drools Planner can handle this. For Drools Planner 5.3, I 've created out-of-the-box support for real-time planning (sources of the prototype are here). Take a look at a demo video:

Real-time planning with Drools Planner: demo video from Geoffrey De Smet on Vimeo.


Here the log of a different run which shows what's going on:

08:44:44,055 [pool-1-thread-1] INFO  Solving with random seed (0).
// The solution is feasible after 2450 ms
08:44:46,505 [pool-1-thread-1] INFO  Greedy phase ended at step index (199) for best score (0hard/-80090soft).
08:44:46,639 [pool-1-thread-1] INFO  Step index (0), ..., new best score (0hard/-79840soft), ...
08:44:52,194 [pool-1-thread-1] INFO  Step index (84), ..., new best score (0hard/-73820soft), ...
// Another thread schedules the computer deleting event, while the Planner thread is solving
08:44:52,246 [AWT-EventQueue-0] INFO  Scheduling deleting of computer (Computer 3).
08:44:52,254 [pool-1-thread-1] INFO  Step index (85), ...,     best score (0hard/-73820soft), ...
08:44:52,257 [pool-1-thread-1] INFO  Done 1 PlanningFactChange(s), new score (0hard/-71520soft), possibly uninitialized. Restarting solver.
// The solution is feasible again after 71 ms
08:44:52,317 [pool-1-thread-1] INFO  Greedy phase ended at step index (9) for best score (0hard/-75250soft).
08:44:52,374 [pool-1-thread-1] INFO  Step index (0), ..., new best score (0hard/-74850soft), ...
08:44:55,666 [pool-1-thread-1] INFO  Step index (57), ..., new best score (0hard/-70660soft), ...

Use cases

In the demo I am scheduling computer processes on a grid of computers, but there are plenty of other real-time planning problems, such as:
  • Train station track/platform scheduling
  • Airplane gate scheduling at the airport
  • Hospital emergency room/doktor/patient scheduling
  • ...
And all of these need to be able to scale in data and constraints, which is no problem for Drools Planner.