Expertsystemen

 

Advanced Conditions

Before reading this section, we highly recommend reading both Getting started with conditions and Conditions.

Whenever you add a condition to an action in the Studio, such as a formula, you can read it as “if the condition is satisfied, do this”. An everyday example may be something like “If it rains outside, I will have to put on my coat”. This condition is structured with a condition-part and a statement-part. The part “if it rains outside” is the condition, “I will have to put on my coat” is the statement. So, the general structure is: if condition then statement.

However, in reality you may encounter more complex structures. The Studio has else-conditions and condition blocks to help you with these.

The else-condition

An else-condition is an extension to the normal if-then structure of a condition. For example, consider the following: “If I have less than €100, I eat at home; if I have more I will go to a restaurant if it’s Saturday” In xxllnc Expertsystemen, you might come up with this structure:

Condition for the eating example
Condition for the eating example

However, now you have to check for ‘money’ twice! In the Studio you can solve this with an if-then-else structure. This is done in the following way:

Else-condition for the eating example
Else-condition for the eating example

Note that the check box for an else-condition will only appear whenever your previous action has a condition! This is due to the structure of and if-else-then: there can only be an else if there’s also an if.

Now, our variable eat will be ‘restaurant’ only if money is not lower than 100 and if the day is Saturday. Another example could be the activity of someone: if it’s raining, he will stay inside. If it’s not and the temperature is higher than 20 degrees, he will play football.

Else-condition for the activity example
Else-condition for the activity example

Condition blocks

You can also have multiple actions that you want to do that all depend on a single condition. For example, imagine your employer has rules for people over 40 years old. They have to work a bit more each day, but they get more salary and more holidays. In xxllnc Expertsystemen, you might model this situation this way:

All actions need a condition
All actions need a condition

However, now you have to enter the condition for each and every action. Furthermore, you might want to add extra condition, such as checking the current salary. To make this simpler, the condition block exists. A condition block has a condition and a begin and end, and everything between the begin and end will be done if the condition is true. For our example, this will look as follows in the action list:

All conditions have been put in the begin-end-block
All conditions have been put in the begin-end-block

You can add your own condition blocks through [ACTIONS > Block] under the subsection Model Flow. Doing so will add two actions: the begin and the end. The begin part of the block can be edited to change the condition. If you want to put actions in the block, you can drag them inside the block or use the arrows in the action list to move actions up or down.

Editing the condition of the block
Editing the condition of the block