"github.com/nextmv-io/code/engines/route"
vehicleEngine "github.com/nextmv-io/code/engines/route/vehicle"
"github.com/nextmv-io/code/hop/model"
"github.com/nextmv-io/code/hop/run/cli"
"github.com/nextmv-io/code/hop/solve"
"github.com/nextmv-io/code/hop/solve/alns"
// Struct to read from JSON in.
Stops []route.Stop `json:"stops,omitempty"`
Vehicles []string `json:"vehicles,omitempty"`
Threads int `json:"threads,omitempty"`
// Use the CLI runner to solve a Vehicle Routing Problem.
f := func(i input, opt solve.Options) (solve.Solver, error) {
// Custom ALNS implementation
repairOptions.Limits.Solutions = 1
operators := []alns.Operator{
Destroy: vehicleEngine.DestroySwap(),
Repair: vehicleEngine.Repair(repairOptions),
acceptor := alns.Hill(model.Minimize)
// Declare the router and its solver.
router, err := route.NewRouter(
// Do not append operators
route.Operators(operators, false),
route.Acceptor(acceptor),
route.Threads(i.Threads),
return router.Solver(opt)