Custom output¶
Info
This feature is only available for Platform. You can find a list of all available features.
You can change the default output that is generated by our vehicle routing engine. If you would like to calculate and track some KPI then we recommend you to use our statistics convention because it allows you to track this data running experiments on our platform. You can read more about this in the Metrics section.
But you can also generate your complete own output. For example, this may be useful if you want to integrate the engine into an existing system where several services depend on a certain output structure.
Example¶
First create a new struct which will repesent your output data:
type customOutput struct {
Custom string `json:"custom,omitempty"`
Value float64 `json:"value,omitempty"`
}
And then create a new function that takes a nextroute.Solution as an input
and returns the output struct.
func toOutput(solution nextroute.Solution) customOutput {
value := 0.0
for _, t := range solution.Model().Objective().Terms() {
value += solution.ObjectiveValue(t.Objective())
}
return customOutput{
Custom: "hello world",
Value: value,
}
}
Now we adapt the solver function to adhere to this new struct and change its
return value to the new output struct:
Lastly, use the new output function to return you custom output: