"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 location selector. This location selector looks for the highest
// score of a stop among the not yet assigned stops and returns it, wrapped
selector := func(s fleetEngine.State) model.IntDomain {
for _, l := range s.Locations().Slice() {
if i.Score[l] > highestScore {
highestScore = i.Score[l]
return model.Domain(model.Range(index, index))
router, err := route.NewRouter(
route.Selector(selector),
return router.Solver(opt)