Wednesday, December 5, 2007

CLIPS and Waltz 50

Greetings:

I finally got around to doing a really simple task - that of just checking the latest claim by some guys that CLIPS 6.30 ran with extra-ordinary speed. OK, it does. I think - but it uses internal deftemplates rather than going through the laborious process of creating external objects like those of us in the "real world" have to do. My experience with Jess is that using a deftemplate that is associated with an external object almost doubles the time it takes. My suspicion is that it would double again if the deftemplate were removed from the internal code entirely. So that will be my task for this coming month - to migrate the CLIPS Waltz-50 benchmark to pure external objects. And to create the testing for the WaltzDB-16 that is even harder than Waltz-50.

Meanwhile, here are the results for the test run that I did on my Mac Core 2 Duo laptop (2 GHz, 2GB of RAM) - if you see where I made a mistake somewhere, let me know. I did compare it to the OPSJ and JRules rules for Waltz-50 and CLIPS is doing some things that you cannot do with Java. Things like getting the arc-tan of an angle so quickly - and, yes, Java does have arc-tan and things like that in the Math class, but doing Math in Java is slower than in C. Java has to work at things like that. So, after I re-write either the Java benchmark or the CLIPS benchmark so that they are both pretty much the same, I'll re-run and re-test all of these. Meanwhile, here is the test result using the code provided with CLIPS 6.30. Two other things that I would like to do is to run CLIPS against Mark Proctors new benchmark as well as against our new 10K Data Cleansing benchmark. (I need to finish writing that one because I don't CARE if you cheat or not - just how fast can you get the answer. It's a good one for the business world if I ever finish it.)

CLIPS> (load waltz.clp)
Defining deftemplate: stage
Defining deftemplate: line
Defining deftemplate: edge
Defining deftemplate: junction
Defining defglobal: MOD-NUM
Defining deffunction: atan2
Defining deffunction: get-y
Defining deffunction: get-x
Defining deffunction: get-angle
Defining deffunction: inscribed-angle
Defining deffunction: make-3-junction
Defining defrule: begin +j+j
Defining defrule: reverse_edges +j+j+j
Defining defrule: done_reversing =j+j+j
Defining defrule: make-3_junction +j+j+j+j+j
Defining defrule: make_L =j=j=j+j+j
Defining defrule: done_detecting =j+j+j
Defining defrule: initial_boundary_junction_L +j+j+j+j+j+j
Defining defrule: initial_boundary_junction_arrow =j+j+j+j+j+j+j
Defining defrule: second_boundary_junction_L +j+j+j+j+j+j
Defining defrule: second_boundary_junction_arrow =j+j+j+j+j+j+j
Defining defrule: match_edge +j+j+j+j
Defining defrule: label_L =j+j+j+j+j
Defining defrule: label_tee_A =j+j+j+j+j
Defining defrule: label_tee_B =j=j+j+j+j
Defining defrule: label_fork-1 =j+j+j+j+j+j
Defining defrule: label_fork-2 =j=j+j+j+j+j
Defining defrule: label_fork-3 =j=j=j+j+j+j
Defining defrule: label_fork-4 =j=j+j+j+j+j
Defining defrule: label_arrow-1A =j+j+j+j+j+j
Defining defrule: label_arrow-1B =j=j=j+j+j+j
Defining defrule: label_arrow-2A =j=j+j+j+j+j
Defining defrule: label_arrow-2B =j=j=j+j+j+j
Defining defrule: label_arrow-3A =j=j+j+j+j+j
Defining defrule: label_arrow-3B =j=j=j+j+j+j
Defining defrule: label_arrow-4A =j=j+j+j+j+j
Defining defrule: label_arrow-4B =j=j=j+j+j+j
Defining defrule: label_arrow-5A =j=j+j+j+j+j
Defining defrule: label_arrow-5B =j=j=j+j+j+j
Defining defrule: done_labeling =j+j
Defining defrule: plot_remaining +j+j+j
Defining defrule: plot_boundaries =j+j+j
Defining defrule: done_plotting =j+j+j
TRUE
CLIPS> (load waltz50.clp)
Defining defrule: startup +j+j
TRUE
CLIPS> (watch statistics)
CLIPS> (reset)
CLIPS> (run)
14065 rules fired Run time is 1.03537487983704 seconds.
13584.4516550506 rules per second.
9097 mean number of facts (10806 maximum).
1 mean number of instances (1 maximum).
2298 mean number of activations (12616 maximum).
CLIPS>


SDG
Yaakov

1 comment:

James Owen said...

OK - Here's a comment to my own blog. I actually went through Gary's code line for line EXCEPT for the waltz-50 stuff. diff will depend on which version of which rulebase that you're using so I'm going to accept it that nobody would re-write that one. (It's generated data, anyway, so it can differ from implementation to implementation.)

So, Gary: It's clean and passes inspection compared to the original UT benchmarks. Congratulations on really improving an already great product.

SDG
Yaakov