Category Archives: Phil

Phil 4.4.12

8:00 – 4:30 CSIP

  • Taking a small detour into Hibernate, to see if that can create a Java Object that Drools can operate on.
    • Some relevant articles from 2008-2009, also here
    • Installing hibernate eclipse plugins from here. Well I thought I was. It appears there is a conflict with Ant. Which is funny, because the book “Harnessing Hibernate” has all their examples built with Ant. It is to laugh.
    • Hmm. Ant using Maven is kind of nice. Definitely more explicitly clear. it depends on maven-ant-tasks-2.0.6.jar that needs to reside in the Ant library. And if you add a link to that library as an external jar in the Ant preferences in Eclipse, it seems to work quite well.
    • Well, not quite. The 2.0.6 jar only points to the default .m2/repository. You need the 2.1.3 jar if you want that to work. And that took 2 hours. Grr. Somebody should update the Safari book code repository.
    • Chapter 1
    • Chapter 2
    • Chapter 3

Phil 4.3.12

8:00 – 1:30, 3:30 -6:00  CSIP

  • Ok ,now that we have working(?) code, I have something to walk through while reading the book.
  • The Drools team suggests that you use the joda DateTime library. It looks pretty nice, too – http://joda-time.sourceforge.net/. They also have a bunch of other interesting libraries at http://joda.sourceforge.net/
  • Setting a global value in a rule
    • Java
      // Import the class
      import droolsbook.bank.service.BankingInquiryService;
      
      // create the session
      static StatelessKnowledgeSession session;
      
      // create rule engine
      KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
      KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(configuration);
      
      // declare our global
      BankingInquiryService inquiryService = new BankingInquiryServiceImpl();
      
      // make a session
      session = knowledgeBase.newStatelessKnowledgeSession();
      
      // add the global to the session
      session.setGlobal("inquiryService", inquiryService);
    • Drools rule (.drl file)
      // import
      import droolsbook.bank.service.*;
      
      // declare
      global BankingInquiryService inquiryService;
      
      // use the global in a rule (note the surrounding eval(), which can evaluate any code that returns a TRUE or FALSE).
      rule "accountNumberUnique"
          when
              $account : Account(eval(!inquiryService.isAccountNumberUnique($account)))
          then
              error(kcontext, $account);
      end
  • Chapter 4
  • Nice data visualization using webGL

Phil 4.2.12

8:00 – 5:00 CSIP

  • Went to the customer site to fill out paperwork
  • Proceeding somewhat blindly is a somewhat Droolsy direction. Documentation is pretty sucky.
  • Thinking about how to use rules against a database. This might require the creation of Java classes that have the structure of the table. It’s possible that this could be done with reflection, which I haven’t used since TUMMS. Here’s the Java trail just in case: http://docs.oracle.com/javase/tutorial/reflect/
  • Found the source for the book: http://code.google.com/p/droolsbook/
    • Reindexing maven repositories…
    • had to add the following to the droolsBookParent/pom.xml in the <dependencyManagement><dependecies> section
      <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>1.6.0</version>
      </dependency>
    • had to add the JDK to the JRE section of Eclipse Java properties. It was overriding JAVA_HOME
    • Better. Maybe even good enough. The banking example is working:
      [INFO] Reactor Summary:
      [INFO]
      [INFO] Drools Book Parent ................................ SUCCESS [0.694s]
      [INFO] Banking Core ...................................... SUCCESS [3.705s]
      [INFO] Validation ........................................ SUCCESS [7.324s]
      [INFO] ETL with iBatis ................................... SUCCESS [12.815s]
      [INFO] DSL ............................................... FAILURE [4.146s]
      [INFO] Decision Tables ................................... SKIPPED
      [INFO] Ruleflow .......................................... SKIPPED
      [INFO] Stateful Rules .................................... SKIPPED
      [INFO] Complex Event Processing .......................... SKIPPED
      [INFO] Drools Flow ....................................... SKIPPED
      [INFO] Testing ........................................... SKIPPED
      [INFO] Integration ....................................... SKIPPED
      [INFO] Performance ....................................... SKIPPED
      [INFO] Sample Application ................................ SKIPPED
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 29.097s
      [INFO] Finished at: Mon Apr 02 16:58:52 EDT 2012
      [INFO] Final Memory: 32M/199M
      [ERROR] Failed to execute goal on project dsl: Could not resolve dependencies for project droolsbook:dsl:jar:1.1-SNAPSHOT: The following artifacts could not be resolved: droolsbook:etl_iBatis:jar:tests:1.1-SNAPSHOT, droolsbook:validation:jar:tests:1.1-SNAPSHOT: Failure to find droolsbook:etl_iBatis:jar:tests:1.1-SNAPSHOT in http://www.fgmdev.com:8081/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of corprepo has elapsed or updates are forced -> [Help 1]

Phil 3.30.12

8:00 – 9:30 CSIP

  • More Drools JBoss Rules 5.0 Developer’s Guide, chapter 2
  • Drools JBoss Rules 5.0 Developer’s Guide, chapter 3
    • Starting the Banking Domain Model example

9:30 – 12:00 FP

  • Developer meeting at UMBC

12:00 – 4:00 CSIP

  • Building classes and interfaces for a pretty complex model. We’ll see if this can be made to work…

Phil 3.29.12

8:00 – 4:00 CSIP

  • Drools JBoss Rules 5.0 Developer’s Guide
    • It is not only difficult to represent business logic in a imperative programming style language, but also hard to differentiate between code that represents the business logic and the infrastructure code that supports it.
    • We declare rules in pretty much the same way as the business analyst does the requirements—as a group of if-then statements. The rule engine can then take these rules and execute them over our data in the most efficient way. Rules, which have all of their conditions true, have their then part evaluated. This is different from imperative style programming languages where the developer has to specify how it needs to be done explicitly (with a sequence of conditionals and loops).
    • rule represents one requirement. This is more readable and maps to business requirements more naturally.
    • Well, having the right resource makes a difference. I have compiled and run a simple set of rules against multiple objects!
    • eval is a catch-all solution. It allows execution of any Java/MVEL code (according to the selected dialect) that returns true or false. It should be used only as a last resort when all other options have failed. This is because the rule engine cannot optimize eval. The expression is evaluated every time there is a change in the current rule’s condition (a fact is added, modified, or removed). They don’t have to return time-constant values. Writing eval as the last condition in a rule is a good practice.
    • How to get a reference to the current class being evaluated: $a:Account ( balance < 100, name != “Ted”). The ‘$’ is convention and not required

Lunch meeting to go over Noveta changes

Phil 3.28.12

8:00 – 4:30 CSIP

  • Visualizing Drools (Visualizing Inference Process of a Rule Engine – VINCI’11, August 4–5, 2011, Hong Kong, China.)
  • Onward with chapter 2
    • When there is one or more Activations on the Agenda they are said to be in conflict, and a conflict resolver strategy is used to determine the order of execution. At the simplest level the default strategy uses salience to determine rule priority. Each rule has a default value of 0, the higher the value the higher the priority.
  • Sheesh, had a whole slew of computer problems this morning. I was missing dlls, Some projects were pointing to debug libraries so they couldn’t distribute properly, and then my TortoiseSVN  just… evaporated. Had to reboot, reinstall, and reboot again. Everything appears to be working now though.
  • Wish I could find where this tool (RuleFlow?) is hidden in eclipse
  • Chapter 3: Advanced Concepts and Theory
    • After regular inserts you have to retract facts explicitly. With logical assertions, the fact that was asserted will be automatically retracted when the conditions that asserted it in the first place are no longer true
    • It is important to note that for Truth Maintenance (and logical assertions) to work at all, your Fact objects (which may be JavaBeans) must override equals and hashCode methods (from java.lang.Object) correctly. As the truth maintenance system needs to know when two different physical objects are equal in value, both equals and hashCode must be overridden correctly, as per the Java standard.
  • Chapter 4: User Guide
  • ‘Hello world’ setup”
    • KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
      // Check the builder for errors
      if( kbuilder.hasErrors() ) {
          System.out.println( kbuilder.getErrors() );
          return;
      }
      
      // Resources of any type can be added iteratively
      kbuilder.add( ResourceFactory.newFileResource( "/project/myrules1.drl" ), ResourceType.DRL);
      kbuilder.add( ResourceFactory.newFileResource( "/project/myrules2.drl" ), ResourceType.DRL);
      
      if( kbuilder.hasErrors() ) {
          System.out.println( kbuilder.getErrors() );
          return;
      }
      
      Collection<KnowledgePackage> kpkgs = kbuilder.getKnowledgePackages();
  • Ok, this is a nice introduction to concepts, but I’m not really getting the opportunity to build something in an kind of understandable way. There’s not much documentation, and only one book that appears to provide the overview – That’s the “Drools JBoss Rules 5.0 Developer’s Guide”. The reviews on Amazon are mixed, leaning to bad, but it’s the only game in town. I’ve bought and downloaded the Kindle edition and will try that tomorrow.

Phil 3.27.12

8:00 – 8:30 FP

  • Tried running the hand code on my laptop but ran into DLL problems. It was the debug version, so I recompiled the release version today. Let’s see if that makes it easier.
  • A useful page explaining all this, including that debug dlls are not redistributable.

8:30 – 4:30 CSIP

  • Ok, now that I’ve got the examples compiled and running (In Swing! How quaint), let’s see how to use this thing.
  • Chapter 2. Use cases and examples
  • Sent Ed a status update
  • Ok, I got the Drools Developer’s Cookbook, and it looks like I was doing this in the wrong order. Going to start over with the rules engine (Expert)
  • Chapter 1. The Rule Engine
    • An object type constraint plus its zero or more field constraints is referred to as a pattern. When an inserted instance satisfies both the object type constraint and all the field constraints, it is said to be matched.
    • Downloaded drools-distribution-5.3.0.Final, which contains example code. Some problems compiling, but the HelloWorld works, so we won’t worry for now…
    • This process is called inference, and it’s essential for the working of a Stateful Session. Stateless Sessions typically do not use inference, so the engine does not need to be aware of changes to data. Inference can also be turned off explicitly by using the sequential mode.

Phil 3.25.12

10:00 –  2:00 FP

  • What a soggy weekend.
  • Integrating collision detection and response into the hand.
  • Checked out from SVN – still working!
  • Firngertips are now being calculated in world space.
  • Spent a good deal of time getting the global to local (CollisionCube) transformations working. They still haven’t been tested through the rotations, but are working for translation and scaling.
  • Wired up the volume components. At this point the simulation is pretty much ready to hook up to the Arduino.

Phil 3.23.12

8:00 – 12:30 FP

  • It’s going to be an abbreviated day. I’ve got to be over at my parent’s old house in the early afternoon to let in the GB&E guy, and since the weather’s * phenomenal* I’m going to go for a longer and early bike ride. Given all the rain in the forecast for the weekend, I’ll be here to make up the hours, probably more likely on Sunday.
  • Adding in CollisionCube. It’s drawing, and I’m getting fingertip position info for collisions. More on Sunday
  • Checked into SVN

Phil 3.22.12

8:00 – 4:00 FP

  • Looks like I’ll have the CSIP project to charge to soon. Woohoo!
  • debugging RightHand::drawPrimitive() – fixed. Passing by value rather than by reference. D’oh.
  • Shiny hand model! Now I need to wire the graphics to the FingerIO classes – partly done, waiting on putting in the CollisionCube.
  • Tried adding the FingerIO classes directly to RightHand, but the class isn’t instanced by the time show() gets called in KF_GUI. So the FingerIO classes went back to the KF_Hand_window class, and I added pointers to the RightHand class. Not really happy with this, but it will do for now as I get all the other pieces working. And better than the alternative of grabbing the parent of the window class while still reaching into the RightHand class.
  • Next, put all the changed code back into the fluid code – done
  • Adding CollisionCube drawableObject – most pieces are in and I need to test.

4:00 – 5:00 CSIP

  • Spent about 45 min talking CSIP with Ed.
  • Start figuring out drools, with particular emphasis on creating xml that can be ingested and used to create running rule sets. Note that RulePoint could be a starting point for look-and-feel, as this may be the basis for the request for the system.

Phil 3.21.12

8:00 – 3:00 FP

  • Now that the basic framework is put together, adding in the hand. Starting with making shiny cubes and cylinders.
  • When making textures, *don’t* compress your tga files!
  • Added a color modulated reflection shader. This will probably be our main shader for charts, too.
  • Need to add a bit of lighting to the shiny objects. Going to finish building the hand fist.
  • In the process of debugging RightHand::drawPrimitive().

Phil 3.20.12

8:00 – 5:30 FP

  • Spring! That bears repeating. Spring!
  • Working on the hand
  • Building a new FLTK widget to show
    • Communication with Arduino
    • Force on each finger
    • Volume for each finger
    • Sound for each finger
    • Hand view
  • Now I need to wire up the controls
  • Added pointers to the pressure and volume sliders as well as the sound text within the FingerIO helper class. Works well.
  • Wiring up the text output – done. Wound up using a simple multiline Fl_Output class rather than a Fl_Text_Output because when I tried to add a buffer, the code kept crashing trying to create a callback. Not sure that I was making the call in the right place?

Phil 3.19.12

8:00 – 10:30 VISIBILITTY/OH

  • Stopped in to talk to Al F. Things are proceeding apace, apparently.

10:30 – 12:00, 3:00 – 5:00 FP

  • Getting started on the final(?) version of the hand
  • Need to talk to Tom about coding up the arduino, but today’s schedule may not allow. Tomorrow?

Phil 3.14.12

8:00 – 4:30 FP

  • Happy PI day! I wonder if there will be bigger celebrations in 2015?
  • Back to building libraries.
    • Release Library is done.
  • Adding test project to solution that tests the library
    • Discovered that a dll was probably not the way to go, so changed the project settings so that it now generated a static library. For once, that was pretty straightforward – Properties->Configuration Properties->General->Configuration Type and select from the dropdown.
    • Everything is compiling and linking, adding some actual content now.
    • Well I’ll be damned – everything works (In debug and release mode!).
  • Same old picture, but with much better foundations:
  • Installed AtomineerUtils, a nifty plugin if Visual Studio that generates documentation frameworks