0.0.4 • Published 5 months ago

@solvice.io/node-onroute-client v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

OnRoute API Client in Node

Based on the documentation in https://docs2.solvice.io/onroute

We have a hand-crafted API client (@solvice.io/node-onroute-client) for the OnRoute route optimisation API that is more memory efficient e.g. for large instances than autogenerated client based on openapi.

Installation

npm install @solvice.io/node-onroute-client --save

Usage

Define the client

const api: OnRouteApi = new OnRouteApi({ apiKey: "<api key>" });

VRP

Define a solve job to send to the solve endpoint. Look at the VRP model for more details.

const vrp: VRP = {
    solver: Solver.Vrp,
    locations: [
        { name: "depot", latitude: 51.21112, longitude: 4.093 },
        { name: "l1", latitude: 50.721112, longitude: 4.893 },
        { name: "l2", latitude: 50.42342, longitude: 4.693 },
    ],
    fleet: [
        { name: "bert", startlocation: "depot", shiftstart: 500, shiftend: 700 }
    ],
    orders: [
        { name: "o1", location: "l1", duration: 10 },
        { name: "o2", location: "l2", duration: 15 }
    ],
    options: { traffic: 1 }
}

Send VRP to the solver and fetch the solution.

// send to solver
const job: Job = await api.solve(vrp, 60);

// job has started solving
const startedSolving: Job = await api.pollSolving(job.id);

// job is solved. return solution
const solution: RoutingSolution = await api.pollSolved(job.id) as RoutingSolution;

PVRP

Define the Periodic VRP and add a planning period.

const vrp: PVRP = {
    solver: Solver.Pvrp,
    period: {
        start: Date.now(),
        end: Date.now()
    },
    locations: [
        { name: "depot", latitude: 51.21112, longitude: 4.093 },
        { name: "l1", latitude: 50.721112, longitude: 4.893 },
        { name: "l2", latitude: 50.42342, longitude: 4.693 },],
    fleet: [
        { name: "bert", startlocation: "depot", shiftstart: 500, shiftend: 700 }
    ],
    orders: [
        { name: "o1", location: "l1", duration: 10 },
        { name: "o2", location: "l2", duration: 15 }
    ],
    options: { traffic: 1 }
}
// send to solver
const job: Job = await api.solve(vrp, 60);

// job has started solving
const startedSolving: Job = await api.pollSolving(job.id);

// job is solved. return solution
const solution: PeriodicRoutingSolution = await api.pollSolved(job.id) as PeriodicRoutingSolution;
0.0.4

5 months ago

0.0.3

11 months ago

0.0.2

3 years ago

0.0.1

3 years ago