To support custom metrics within our Platform you can use a statistics convention as part of the run output. This convention is used for both runs and experiments. The convention is purely optional. If you want to use the experimentation system in particular or want to communicate metrics to the system in general, you have use this convention.
Let’s start with an example. Below you see the JSON output of a meal allocation example.
The above statistics
object is interpreted as follows:
- The
schema
is the version of the convention. This is required and indicates which version of the convention is used. - The
run
object contains statistics about the run itself. - The
result
object contains statistics about the result of the run.
Your run output needs to meet the following requirements for the system to extract the statistics information:
- The output of the run must be a valid JSON object.
- The output must contain a
statistics
object. - The
statistics
object must contain aschema
string with the value"v1"
. This version determines what schema is expected. - The content of the
statistics
object conforms to thev1
schema described below. - The maximum size of the statistics object without unnecessary whitespaces is 10kb.
Add custom statistics
If you have a custom app, you may wish to add custom statistics to your result. You can do this by passing a computed statistic in to output.statistics.result.custom
.
Consider an example from vehicle routing. You want to add unplanned stop count as a custom statistic, you can:
- Format the output using the
nextroute
factory formatter. - Add custom unplanned stop count to the formatted solution output.
An example is shown below:
V1 schema
In addition to the schema
key, there can be up to three keys in the statistics
object:
run
: Information about the run itself. For example the total duration of the solver and number of iterations.result
: Information about the result of the run. For example the objective value.series_data
: Time series data for the run such as the progression of the value function over time.
All numerical values are interpreted as floating point (IEEE 754) values. This includes the special string values "nan"
, "inf"
, "+inf"
and "–inf"
as JSON does not support these values natively.
All keys except for schema
are optional and can be omitted.
schema
A string that determines the structure of the statistics
object. This is required and must be "v1"
.
run
key | type | description |
---|---|---|
duration | float | The runtime of the complete search in seconds. Optional, but must be a finite and positive number. |
iterations | int | The total number of iterations. Optional, but must be a positive number. |
custom | object | Optionally contains arbitrary structure a user can define. By convention all information here applies to the complete run and only numeric values are interpreted, the rest is ignored. All keys within the object must only contain alphanumeric characters, _ and - . The minimum length of a key is 1 and the maximum length is 60. |
result
key | type | description |
---|---|---|
value | float | The value of the result. Usually the objective value of the best solution. Optional. For non finite results use the special string values "nan" , "inf" , "+inf" and "–inf" . |
duration | float | Time in seconds until that specific result was found. Optional, but must be a finite and positive number. |
custom | object | Optionally contains arbitrary structure a user can define. By convention all the information here applies to the result and only numeric values are interpreted, the rest is ignored. All keys within the object must only contain alphanumeric characters, _ and - . The minimum length of a key is 1 and the maximum length is 60. |
series_data
key | type | description |
---|---|---|
value | Series | The progression of the objective value over time. Optional. |
custom | []Series | An optional array of Series . This can be used to communicate any type of two dimensional data sequences. |
Complex example
Below is a more complex example that also contains time series data.
The time series below is a simple example of a value function progression over time. The custom series are examples of how you can communicate more complex data, e.g. the usage of a custom operator over time.
How the statistics are used
If the output conforms to the statistics convention the system extracts it and makes it available for further processing. The main application right now is within the experimentation system. For example all metrics from the statistics convention are displayed in the run table and are also summarized automatically.
What if my output is not JSON?
To use the statistics convention your output must be a valid JSON. In these cases (e.g. a CSV output) we suggest to wrap your non-JSON output as a base64 encoded string in a JSON object.