Curve

A curve is a type of Evaluator representing a mathematical function transforming one value into another one. 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.

Constant Function

Parameters
  • value

This function returns value disregarding it’s input.

Constant Function

Step Function

Parameters
  • threshold

  • beforeThresholdValue

  • afterThresholdValue

This function returns afterThresholdValue if x is greater than threshold. Otherwise returns beforeThresholdValue.

Step Function

Linear Function

Parameters
  • slope

  • intercept

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

Linear Function

Power Function

Parameters
  • exponent

  • slope

  • intercept

This function takes linear function and raises it to power determined by exponent The result of linear function slope * x + intercept is lowerbound by 0.

Power Function

Exponential Function

Parameters
  • base

This function raises base to `x’th power.

Exponential Function

Sigmoid Function

Parameters
  • slope

  • threshold

Work in progress. One day it will become a properly working sigmoid function.

Sigmoid Function

Linearly Interpolated Curve

Simple linear interpolation applied to a set of points (from R2).

Linearly Interpolated Curve

Bezier Spline

This is a bezier spline created based on a set of waypoints and velocities coming in and out of them.

Bezier Spline

Staircase Function

Piecewise constant function with finite amount of pieces.

Staircase Function

Bounded Curves

Lowerbound

Lowerbound curves cannot return result lesser than their lowerValue.

Lowerbound Power Function
  • C++

  • C#

auto linearCurve = std::make_shared<LinearFunction<ContextType>(someConsideration, 1, 0);
auto lowerbound = std::make_shared<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 result greater than their upperValue.

Upperbound Power Function
  • C++

  • C#

auto someConsideration = std::make_shared<SomeConsideration>();
auto upperbound = std::make_shared<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 lesser than lowerValue and greater than upperValue.

Double-Bounded Power Function
  • C++

  • C#

auto doubleBounded = std::make_shared<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>