"github.com/nextmv-io/code/engines/route"
fleetEngine "github.com/nextmv-io/code/engines/route/fleet"
"github.com/nextmv-io/code/hop/model"
"github.com/nextmv-io/code/hop/run/cli"
"github.com/nextmv-io/code/hop/solve"
// Struct to read from JSON in.
Stops []route.Stop `json:"stops,omitempty"`
Vehicles []string `json:"vehicles,omitempty"`
Score []int `json:"score,omitempty"`
// Use the CLI runner to solve a Vehicle Routing Problem.
f := func(i input, opt solve.Options) (solve.Solver, error) {
// Define a vehicle sorter. This vehicle sorter sorts the vehicles that
// can service the selected stops and returns their vehicle indices in
sorter := func(s fleetEngine.State, stops, vehicles model.IntDomain) []int {
vehicleIndices := vehicles.Slice()
sort.SliceStable(vehicleIndices, func(j, k int) bool {
return i.Score[j] > i.Score[k]
router, err := route.NewRouter(
return router.Solver(opt)