Scenarios and Rule Sets authoring


You can develop scenarios yourself visually using the Protege Graph Widget. You can develop Rule Sets (Drools Packages) and Rule Bases consisting of such packages for using not only inside a scenario framework, but in any domain, leveraging Drools inference capabilities by Protege visual knowledge manipulation capabilities.
 

    Scenario authoring

1. Open the "Instances" Tab and check there existing scenario and task schemes  (ScenarioOntology -> Activity -> ScenarioScheme | TaskScheme ...)..

2. To create your own scenario you should create a new instance of the class "Scenario" and fill its "title" slot with a name of it.

3. Click on the "Create instance" button (with a shining diamond). This will open a new ScenarioScheme form. Fill its "title" slot with a some name.

4. Drag and drop on the form tasks, decisions and joins from the palette on the left. Give them their names. Connect them by dragging and dropping arrows (this can be done when the cursor has a palm shape).

5. Fill in "initial_tasks" and "final_tasks" slots of the Scenario instance by adding some tasks from those you have dropped on the form (diamond with a plus button). Scenario is ready! You can run it using the "Play scenario" button. Tasks wil be executed in appropriate order, but nothing more because they are not filled with the actions.

6. To fill a task with the actions select it on the Scenario Scheme and click the "View Selected Instances" button (with the magnifier).

7. On the Task instance form fill in the "title", "task_scheme", "initial_actions" and "final_actions" slots similarly to how you did this on the Scenario instance form.

8. Do this for all tasks, decisions and joins on the Scenario Scheme. Now the Scenario is ready to execution fnally and can be run.

    Action and decision authoring

1. You can get acquainted with existing action implementations on the "Classes" Tab (ScenarioOntology -> Activity -> Action ...). Action descriptions on the "Classes" Tab would be translated to the Drools rules during the RuleBase creation. Some of them would be represented by two rules: "Start" rule and "Repeat" rule. The Start rule fire only once in the beginning of the action execution. After that the action goes to "REPEAT" state, and in this state the Repeat rule would be firing repeatedly, according to assertion into the Working Memory of a special fact object "DroClock", that in turn asserted from a timer. Some actions have no the Repeat part, so they would be translated only to one rule - Start rule and accordingly would fire only once for this action.

2. To create your own action you should create a new instance of the class "ActionClass" (:SYSTEM-CLASS -> :META-CLASS -> :STANDARD-CLASS -> ActionClass) and give it an action name.

3. Add to it existing slots or create for it new slots fore storing in them different information needed to action definition and execution.

4. Fill in its slots "start-when", "start-then", "repeat-when", "repeat-then" as needed in accordance with the Drools Rule Language syntaxis (see Drools documentation).

5. Put it in appropriate place in the ScenarioOntology. To do this find it and select on the "Classes" Tab and add to it corresponding superclass (using "Add superclasses" button below). Remove ":THING" class from its superclases.

6. Add it to the "for-creation" slot of the "ActionExecutor" Package.

7. Configure its representation on the Task schemes. To do this open a form of Task schemes on the "Forms" Tab. Double click on a form "p-scheme" and select on the appearing dialog a "Nodes" Tab. Find there and select your new action. Adjust its shape, color and other features. Don't forget to set its Connector slot to "next-actions" lest not be possible to connect it to other actions on the Task schemes.

8. Creation and configuration of decisions do likewise.

    Rule Sets authoring

1. To create a new Rule you should create a new instance of the class "Rule" and fill its slots as needed in accordance with the Drools Rule Language syntaxis (see Drools documentation).

2. To create a new Rule Set you should create a new instance of the class "Package" and fill its slots as appropriately.
In your own Sets you can use Domain Specific Language (DSL) (see Drools documentations for details). To do this create in Drools Ontology an instance of the "DSL" class and fill its source slot with DSL instructions. Put this instance in a "dsl" slot of the Package instance. Fill an "expander" slot with any string (for example "dsl").

3. To create a new Rule Base you should create a new instance of the class "RuleBase" and fill its "packages" slot with the instances of Packages for the corresponding Rule Sets.

4. When Protege starts and a project containing the DroolsTab open, on the "Drools" Tab would be opened an instance of RuleBase marked by an yellow stiker (annotated, in the Protege trminology). So, if you whant that your new RuleBase would open initially, move the yellow stiker on it (delete from the old RuleBase and create on the new one).

5. Same is hold for the "Openmap" Tab, that is a map that initially would be opened, is described by an annotated instance of the class "Openmap". So, you can create a new Openmap instance, describing your own map (see OpenMap documentation), annotate it and remove annotation from the old one, and next time you open this project the "Openmap" Tab would display your map.
  

Learn DroolsTab by familiarizing with classes and instances of projects in the "projects" folder, DroolsTab API javadoc and sources, and also documentation from Protege, OpenMap, Drools and Groovy home sites. If the DroolsTab attracts some interest and someone ask me I will be publishing some documentation gradually. For begin: http://protege.cim3.net/cgi-bin/wiki.pl?IntelligentGIS

Feel free to experiment with the DroolsTab and to write me with any questions and suggestions.

        Ru (mailto:sorokin@oogis.ru)