Library: Sub 3 – Building in Triangles

Building Pattern--> Structural -->

Building in Triangles

Rainbird is great at making decisions in the absence of data,  and in situations in which the certainty of data is less than 100%.

To be able to make a decision involving missing data, Rainbird must be able to infer an outcome.

In order for Rainbird to be able to infer, we need to create a mechanism or pattern that enables Rainbird to reach an outcome via an alternative route.

One of the basic build structures in Rainbird is a “triangle”. The triangle structure is formed by three concepts.  In the example triangle built in this article, we have built a generic map that will infer a Solution to a Problem for a Person. The triangle build will have one main subject (Person) and one main object (Solution). The second object (Problem) allows us to infer for our main object (Solution).

Three string concepts, (a Person, a Problem and a Solution), form the basis of the triangle mechanism.

Next, we connect the concepts together with relationships. The relationship names are defined by the nature of the relationship between each concept:

  • Person HAS A Problem
  • Problem IS SATISFIED BY Solution
  • Person SHOULD MAKE USE OF Solution


Figure 1: Creating the map’s Concepts and Relationships

Note – f we wanted a user to be able to select more than one problem at a time whilst they were running the query, the relationships would all need to be set to ‘plural’. 

The relationship between the ‘person’ (%S) and ‘solution’ (%O) concepts is the key relationship in the triangle, as Rainbird will be using this relationship to infer the object of the pattern/mechanism (the Solution) based on the subject that it concerns (the Person). The direction of the arrows indicates the direction of the relationship – in our case, subject to object.

Currently, if Rainbird was asked to derive the ‘solution’ at this stage, Rainbird would ask the end user, “What solution should a person take?” ; instead of asking the end user for the decision, Rainbird can infer the decision. We need to create a rule to tell Rainbird how to infer the solution, by outlining to Rainbird the ‘alternative route’ to the answer. We therefore build our rule on the relationship ‘person should make use of solution‘.

A rule is made up of:

  1. The relationship on which the rule sites
  2. The conditions under which an object can be derived
  3. Expressions that might be used to transform or compare an object

Once the concepts are all linked with relationships, if we were to write down the logic of the rule, the rule for the triangle would be:

 

A Person ‘should make use of’ Solution.


WHEN
A Person ‘has a’ Problem


AND
Problem is ‘satisfied by a’ Solution


Figure 2: Creating the overall Rule

 


Before continuing with the map build,
create a query based on this new rule in order to test the rule and ensure that the logic is working correctly.

 

We want to ensure that Rainbird asks the correct questions to the user that will complete the query. As we only want Rainbird to ask what the problem (the subject of the relationship) is, the question configuration is set to ‘Second form (subject) only’ and rewritten to be ‘What is the Problem?’.


Figure 3: Changing the question wording

In order for the user to complete the query, the following concept instances for the ‘Problem’ and the ‘Solution’ concepts are created:

  • Solution concept instances:  drink, eat and sleep
  • Problem concept instances: thirst, hunger and tired


Figure 4: Creating Instances for the Solutions

Note – in the example triangle map, each problem concept matches exactly one solution concept, but in other maps, subject and object concepts do not require the same amount of concept instances to work together.

Once concept instances have been created, facts (or ‘relationship instances’) that link specific concept instances together with a relationship, can be made. In the example map, our facts will connectproblem concept instance with a solution concept instance on the ‘is satisfied by a’ relationship. The facts will tell Rainbird the solution to each problem.

To create a fact, open a ‘Problem’ concept instance and select the suitable ‘Solution’ concept instance for each ‘Problem’ concept instance:

Figure 5: Creating facts by matching problems with solution

After we’ve populated the map with concept instances and created facts between them, we can re-run our initial query.

Rainbird will first ask the user to “What is the Problem?’. If, for example, we select ‘thirst’, Rainbird will then ask‘Which solution solves the problem of thirst?’:

Figure 7: Which solution solves the problem of ‘thirst’?

Rainbird knowsdrinksolves the problem of ‘thirst‘,  and greys out the ‘drink’ answer, because a fact that links the ‘thirst‘ and ‘drink‘ concept instances on the ‘is satisfied by‘ relationship exists in the knowledge map.

Rainbird still asks the ‘which solution solves the problem of ‘thirst’ question, even though the ‘Thirst is satisfied by Drink’ fact exists , because Rainbird can create facts between concept instances at run-time.

For example, an end-user could type in ‘Water‘, which would create a ‘Thirst is satisfied by Water’ fact. The user could also select another concept instance from the ‘solution’ concept instances that exist in the map,  and Rainbird would create another fact between the selected ‘solution’ concept instance with the ‘thirst’ concept instance.

As we want to stop Rainbird from creating facts at run-time, and to use only use the facts that have been inserted into the knowledge map, we switch off the questions in the two relationships ‘do something’ and ‘is satisfied by’ by changing t ‘questions configuration’  setting from ”All” to “None”.

Figure 8: Changing the question configuration

The RBLang below will create the triangle map used in the example when imported into Rainbird. Click on ‘Export .rbird’ to download the knowledge map or ‘copy RBLang’ and paste the code directly into Rainbird

 

Query and Results

The main query is built on the rule ‘should make use of’. The outcome of the query will be the Solution to the Problem the user selects at run-time.

Article Feedback form
Did you find this article useful?

Version 1.01 – Last Update: 26/02/2021

Bitnami