Curve
A curve is a type of Evaluator representing a mathematical function transforming one value into another. Grail’s curves operate on floating point numbers (R→R).
Each curve has to be informed which Context may be passed through it during evaluation. Contexts can take form of any built-in or user-defined data type.
A user can inherit from Curve
class to create their own custom curves or they can make use of Grail’s built-in curve types.
Basic Curves
Let’s assume that x
means input value.
Step Function
-
threshold
-
beforeThresholdValue
-
afterThresholdValue
This function returns afterThresholdValue
if x
is greater than threshold
.
Otherwise returns beforeThresholdValue
.

Linear Function
-
slope
-
intercept
This functions returns result of operation slope
* x
+ intercept
.

Power Function
-
exponent
-
slope
-
intercept
This function takes a linear function and raises it to a power determined by exponent
The result of the linear function slope
* x
+ intercept
is lower bounded by 0
.

Sigmoid Function
-
range
-
slope
-
threshold
-
displacement
The sigmoid function, also known as the logistic function, is a mathematical function that has a characteristic "S-shaped" curve. It is commonly used as an activation function in neural networks.
We use the following formula:

Bounded Curves
Lowerbound
Lowerbound curves cannot return a result lesser than their lowerValue
.

-
C++
-
C#
auto linearCurve = std::make_shared<grail::evaluator::LinearFunction<ContextType>(someConsideration, 1, 0);
auto lowerbound = std::make_shared<grail::evaluator::LowerBound<ContextType>>(linearCurve, 0); // linearCurve bounded to range <0;inf>
var linearCurve = new LinearFunction<ContextType>(someConsideration, 1, 0);
var lowerbound = new LowerBound<ContextType>(linearCurve, 0); // linearCurve bounded to range <0;inf>
Upperbound
Upperbound curves cannot return a result greater than their upperValue
.

-
C++
-
C#
auto someConsideration = std::make_shared<SomeConsideration>();
auto upperbound = std::make_shared<grail::evaluator::UpperBound<ContextType>>(someConsideration, 1); // someConsideration bounded to range <-inf;1>
var someConsideration = new SomeConsideration();
var upperbound = new UpperBound(someConsideration, 1); // someConsideration bounded to range <-inf;1>
Double-Sided Bound
Double-Sided Bound curves cannot return results less than lowerValue
and greater than upperValue
.

-
C++
-
C#
auto doubleBounded = std::make_shared<grail::evaluator::DoubleSidedBound<ContextType>>(aggregator, 0, 1); // aggregator bound to range <0;1>
var doubleBounded = new DoubleSidedBound<ContextType>(aggregator, 0, 1); //aggregator bound to range <0;1>