The Rule Engine Flex-Evaluator

The flexible evaluator of the Rule Engine powers the ability of a user to freely use mathematical modelling language syntax to define business rules. We empower business users as "power users" to use the rule chains with mathematical functions and pseudo code.


In this article, we shall understand the different types of syntax and usage capabilities for this engine.


Preface

If you are here, you are probably using the Nighthack Rule Engine in it's Core or Academic Evaluator form. Please ensure, you have the power-user modules enabled and access rights / permissions to the test system in place.


Overview of Capabilities


Simple Arithmetic


The standard BODMAS with any expression is supported out of the box. The evaluator understands precedence order and using parentheses to group expressions to ensure proper evaluation.


Rule Expression Input: '5 + 3 * 2'
#=> 11
Rule Expression Input:  '(5 + 3) * 2'
#=> 16

Higher Arithmetic


The following additional functionalities are available for usage:


^ - exponential power

'(2 ^ 3) * 2'
#=> 16

% - modulus

'16%4'
#=> 0
'16%5'
#=> 1

Trigonometric


SIN, COS, TAN - use only if setting up a complex calculation system.

Do not use in business rules unless calculating for architecture.


Logical


& > Logical AND of two values in binary (do not use for Business rules)

'2&10'
#=> 2

| > Logical OR of two values in binary (do not use for Business rules)

'16|4'
#=> 20

IF > Conditional Evaluation

if (condition, <Do this on true>, <Do this on false>)

if (13>1, 4, 0)
#=> 4

Numeric - Special


MAX(value1, value2, value3, value4)

MAX(2,4,65,7,8)
#=> 65

MIN(value1, value2, value3, value4)

MIN(2,4,65,7,8)
#=> 2

SUM(value1, value2, value3)

SUM(2,4,8)
#=> 14

AVG(value1, value2, value3)

AVG(16,4,2,51,23)
#=> 19

COUNT(value1, value2, value3, value4) : Count number of values passed to function

COUNT(16,4,2,51,23)
#=> 5

ROUNDING OF NUMBERS : Consists of Rounding up and Rounding down

ROUNDDOWN : Floor operator

ROUNDUP : Roof operator

ROUNDDOWN(12.235)
#=> 12

ROUNDUP(12.235)
#=> 13

Mixing and matching for decisions


Combine IF with calculations

if ((13*0.25)>1, 13*0.25, 2.5)
#=> 3.25

Other examples can be enabled based on use case and type of rules you will use

12 views0 comments

Recent Posts

See All

Create a blog post subtitle that summarizes your post in a few short, punchy sentences and entices your audience to continue reading. Welcome to your blog post. Use this space to connect with your rea

Create a blog post subtitle that summarizes your post in a few short, punchy sentences and entices your audience to continue reading. Welcome to your blog post. Use this space to connect with your rea

Create a blog post subtitle that summarizes your post in a few short, punchy sentences and entices your audience to continue reading. Welcome to your blog post. Use this space to connect with your rea