Utility Selectors
Utility selectors are the tools responsible for selecting one of the evaluated Contexts based on scores produced by evaluators. Selector Context can take the form of any built-in or user-defined data type.
For a utility selector to work, a user must provide it with a collection of evaluated Contexts and their evaluators. Also, the selector’s Context type needs to match the type of all given evaluators.
Utility Selector Types
Grail provides two selection methods:
-
max - an object with the highest score will be chosen.
-
roulette - an object will be chosen at random. The probability of selecting a given object is proportional to its score.
Those methods are realized respectively by the following functions:
-
grail::utility::max_selector::GetBestOption
in C++ andGrail.Utility.MaxSelector.GetBestOption
in C#. -
grail::utility::roulette_selector::GetBestOption
in C++ andGrail.Utility.RouletteSelector.GetBestOption
in C#.
Max Selector
Public Interface
Get Best Option
This function is responsible for selecting the most suitable Context from the options passed as its arguments. The detailed argument list is as follows:
-
a collection of Contexts and corresponding evaluators,
-
a reference to SelectionResult structure to store the result,
-
validator - a function determining whether an evaluated Context is valid and can be chosen at the moment of selection.
Roulette Selector
While selection by max is straightforward, roulette selection requires some more explanation. As mentioned in the introduction, roulette selection chooses one of the options at random, the probability being proportional to the options utility score. However, there are also additional parameters, guiding the selection process: * the number of top behaviors taken into account, * the relative utilility threshold; options below this threshold will be ignored.
Those parameters are defined in a special structure called RouletteOptions
.
Public Interface
Get Best Option
This function is responsible for selecting a Context (according to the procedure described above) from the options passed as its arguments. The detailed argument list is as follows:
-
a collection of Contexts and corresponding evaluators,
-
a reference to SelectionResult structure to store the result,
-
RandomNumberGenerator instance to be used by the selector,
-
RouletteOptions configuration structure,
-
validator - a function determining whether an evaluated Context is valid and can be chosen at the moment of selection.
API Reference
-
C++
-
C#
INVALID API LINK
INVALID API LINK
RouletteOptions API