Skip to content
Free, intelligent routing for your logistics – now on JAVA.
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dashboard
routingengine
src
.DS_Store
.gitignore
LICENSE.md
README.md
pom.xml

README.md

ElasticRoute Logo

License: MIT

API for solving large scale travelling salesman/fleet routing problems

You have a fleet of just 10 vehicles to serve 500 spots in the city. Some vehicles are only available in the day. Some stops can only be served at night. How would you solve this problem?

You don't need to. Just throw us an array of stops, vehicles and depots and we will do the heavy lifting for you. Routing as a Service!

IMPORTANT NOTE: This will only run on Java 11 and above! If you have lower versions of Java, you need to install JDK 11!

Preface


ElasticRoute offers two APIs depending on your needs, and different sections of this documentation are relevant to you depending on which API you wish to interact with:

  • Routing Engine API – if you already have your own fleet management system and you only wish to use ElasticRoute to solve the routing problem and inspect the solution. This is effectively using ElasticRoute in a headless environment, a.k.a. "routing as a service".
  • Dashboard API – if your team uses the ElasticRoute web application to review stops and vehicles on a map, and you wish to push data from your existing applications to the ElasticRoute dashboard. Regardless of how you use ElasticRoute, this client library is capable of interacting with both services.

Routing Engine API


Getting Started

Maven:

<dependencies>
    <dependency>
        <groupId>com.detrack.elasticroute</groupId>
        <artifactId>routingengine</artifactId>
        <version>1.3</version>
    </dependency>
</dependencies>

Note: For IntelliJ IDE, because the default target bytecode is 1.5 which is incompatible with this library, you should add the following to your pom.xml. This is to ensure it is using javac 11.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <release>11</release>
            </configuration>
        </plugin>
    </plugins>
</build>

Plan Instantiation

To create a plan, you need to create List<Stop>, List<Depot>, List<Vehicle, and generalSettings For the full list of generalSettings please refer to this link

// creating a list of stops
List<Stop> stops = new ArrayList<>();
Stop stop1 = new Stop("stop1", "address1");
Stop stop2 = new Stop("stop2", "address2");
Stop stop3 = new Stop("stop3", "address3");

stops.add(stop1);
stops.add(stop2);
stops.add(stop3);

// creating a list of vehicles
Vehicle vehicle1 = new Vehicle("name1");
Vehicle vehicle2 = new Vehicle("name2");
Vehicle vehicle3 = new Vehicle("name3");

List<Vehicle> vehicles = new ArrayList<>();

vehicles.add(vehicle1);
vehicles.add(vehicle2);
vehicles.add(vehicle3);

// creating a list of depots
Depot depot1 = new Depot("name1", "address1");
Depot depot2 = new Depot("name3", "address3");
Depot depot3 = new Depot("name2", "address2");

List<Depot> depots = new ArrayList<>();

depots.add(depot1);
depots.add(depot2);
depots.add(depot3);

// creating the general settings
GeneralSettings generalSettings = new GeneralSettings("SG", "Asia/Singapore");

// Instantiate the Plan
Plan plan = new Plan(stops, depots, vehicles, generalSettings);

Create Plan

Note: id is the unique identifier for your plan. You can retrieve your plan using this id.

// Instantiate a plan before this code. In this example the name of the instantiated plan is plan
Plan.createPlan(plan, "id")

Get Plan

Plan.getPlan("id");

Get Plan Status

Returns a String

Plan.getPlanStatus("id");

Stop Plan

Stops an ongoing plan

Plan.stopPlan("id");

Delete Plan

Deletes the plan with the specified id

Plan.deletePlan("id");

Dashboard API


Getting Started

Maven:

<dependencies>
    <dependency>
        <groupId>com.detrack.elasticroute</groupId>
        <artifactId>dashboard</artifactId>
        <version>1.3</version>
    </dependency>
</dependencies>

Note: For IntelliJ IDE, because the default target bytecode is 1.5 which is incompatible with this library, you should add the following to your pom.xml. This is to ensure it is using javac 11.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <release>11</release>
            </configuration>
        </plugin>
    </plugins>
</build>

Stop

Single Stop

Note : List of fields is specified in the online API documentation

Instantiate a Stop

Note: Date format is YYYY-MM-DD

Stop stop = new Stop("stopName", "address");

Get Stop

Stop.getStop("stopName", "date");
Create Stop
Stop stop = new Stop("stopName", "address");
Stop.createStop(stop, "date");

Update stop (Without changing Stop name)

Stop stop = new Stop("stopName", "address");
// (optional) Change the fields here
Stop.setDepot("Warehouse1");

stop.updateStop();

Update stop (Change Stop name)

Stop stop = new Stop("stopName", "address");
stop.updateStop("stopToUpdate", "date");

Delete stop

Stop.deleteStop("stopName", "date");

Bulk Stops

Note : List of fields is specified in the online API documentation

Get Stops

List<Stop> stops = Stop.getStops("date");

or

List<Stop> stops = Stop.getStops("date", int limit, int pageNumber);

Create Stops

List<Stop> stops = new ArrayList<>();
Stop stop1 = new Stop("stop1", "address1");
Stop stop2 = new Stop("stop2", "address2");
Stop stop3 = new Stop("stop3", "address3");

stops.add(stop1);
stops.add(stop2);
stops.add(stop3);

Stop.createStops(stops, "date");

Replace All Stops

Note: This will delete ALL the stops on the specified date and replace it with the new one.

List<Stop> stops = new ArrayList<>();
Stop stop1 = new Stop("stop1", "address1");
Stop stop2 = new Stop("stop2", "address2");
Stop stop3 = new Stop("stop3", "address3");

stops.add(stop1);
stops.add(stop2);
stops.add(stop3);

Stop.replaceAllStops(stops, "date");

Delete Stops

Stop.deleteStops("date");

Vehicle

Single Vehicle

Note : List of fields is specified in the online API documentation

Instantiate a Vehicle

Vehicle vehicle = new Vehicle("name");

Get Vehicle

Vehicle vehicle = Vehicle.getVehicle("name");

Create Vehicle

Vehicle vehicle = new Vehicle("name");
Vehicle.createVehicle(vehicle);

Update Vehicle (Without updating the name)

Vehicle vehicle = new Vehicle("newName");
// (optional) Change the fields here
vehicle.setAvailMon(false);
vehicle.updateVehicle();

Update Vehicle (Update the name)

Vehicle vehicle = new Vehicle("newName");
// (optional) Change the fields here
vehicle.setAvailMon(false);
vehicle.updateVehicle("nameOfVehicleToUpdate");

Delete Vehicle

Vehicle.deleteVehicle("name");

Get Vehicles

List<Vehicle> vehicles = Vehicle.getVehicles();

or

List<Vehicle> vehicles = Vehicle.getVehicles(int limit, int pageNumber);

Create Vehicles

Vehicle vehicle1 = new Vehicle("name1");
Vehicle vehicle2 = new Vehicle("name2");
Vehicle vehicle3 = new Vehicle("name3");

List<Vehicle> vehicles = new ArrayList<>();

vehicles.add(vehicle1);
vehicles.add(vehicle2);
vehicles.add(vehicle3);

Vehicle.createVehicles(vehicles);

Replace All Vehicles

Vehicle vehicle1 = new Vehicle("name1");
Vehicle vehicle2 = new Vehicle("name2");
Vehicle vehicle3 = new Vehicle("name3");

List<Vehicle> vehicles = new ArrayList<>();

vehicles.add(vehicle1);
vehicles.add(vehicle2);
vehicles.add(vehicle3);

Vehicle.replaceAllVehicles(vehicles);

Update Vehicles

Vehicle vehicle1 = new Vehicle("name1");
Vehicle vehicle2 = new Vehicle("name2");
Vehicle vehicle3 = new Vehicle("name3");

// (optional) Change the fields here
vehicle1.setAvail(false);
vehicle2.setPriority(10);

List<Vehicle> vehicles = new ArrayList<>();

vehicles.add(vehicle1);
vehicles.add(vehicle2);
vehicles.add(vehicle3);

Vehicle.updateVehicles(vehicles);

Delete Vehicles

Note: This will delete ALL your vehicles

Vehicle.deleteVehicles();

Plan

Note: Date format is YYYY-MM-DD

Start Plan

Plan.startPlan("date");

Stop Plan

This will stop an ongoing plan

Plan.stopPlan("date");

Get Plan

String status = Plan.getPlanStatus("date");

Acknowledgement : This library is made using EA-Async library

You can’t perform that action at this time.