Skip to content

Tushar2604/Dispatch_Load_Balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dispatch Load Balancer

A Spring Boot application that optimizes the allocation of delivery orders to a fleet of vehicles based on their locations, capacity, and priority.

Features

  • Haversine Distance Calculation: Accurately calculates distances between coordinates.
  • Optimized Dispatch: Assigns orders based on:
    • Priority (High > Medium > Low)
    • Vehicle Capacity
    • Minimum accumulated travel distance (Greedy approach)
  • REST API: Endpoints to input orders, vehicles, and retrieve the dispatch plan.
  • In-Memory Database: H2 database for easy setup and testing.

Prerequisites

  • Java 17 or higher
  • Maven 3.6+

Getting Started

  1. Clone the repository (if applicable)
  2. Build the project:
    mvn clean install
  3. Run the application:
    mvn spring-boot:run
    The application will start on http://localhost:8080.

API Documentation

1. Add Orders

Endpoint: POST /api/dispatch/orders Body:

{
  "orders": [
    {
      "orderId": "ORD001",
      "latitude": 12.9716,
      "longitude": 77.5946,
      "address": "MG Road, Bangalore",
      "packageWeight": 10,
      "priority": "HIGH"
    }
  ]
}

2. Add Vehicles

Endpoint: POST /api/dispatch/vehicles Body:

{
  "vehicles": [
    {
      "vehicleId": "VEH001",
      "capacity": 100,
      "currentLatitude": 12.9716,
      "currentLongitude": 77.6413,
      "currentAddress": "Indiranagar, Bangalore"
    }
  ]
}

3. Get Dispatch Plan

Endpoint: GET /api/dispatch/plan Response:

{
  "dispatchPlan": [
    {
      "vehicleId": "VEH001",
      "totalLoad": 10.0,
      "totalDistance": "5.20 km",
      "assignedOrders": [ ... ]
    }
  ]
}

H2 Console

Access the H2 database console at: http://localhost:8080/h2-console

  • JDBC URL: jdbc:h2:mem:testdb
  • User: sa
  • Password: password

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors