Coder Social home page Coder Social logo

bestrouteproblem's Introduction

BestRouteProblem

		Best Route Problem

Assumptions: Each restaurant serves to a unique user. No of restaurants are equal to number of users. As soon as the order is received, the restaurant starts preparing. Have considered the speed of delivery guy to be 20km/hr.

Calculation If we assume n orders to be delivered.Its basically same as calculating permutations possible for arranging Ri,Ci where i is from 1 to N. Since only restaurant can precede a customer corresponding , so each case is then divided by 2.So,we can say that there are total ((2n)!/2^n) cases possible for each delivery.

The Approach So we can understand the brute way of doing the problem will be going through each path possible and then deciding which ones the shortest. The approach that I have taken is that at any point of time , whenever we pick orders from two restaurants ,we give it a bit higher priority as compared to other orders and hence focus towards delivering them first.Only when such orders are delivered to the customers we pick up another order from our list and assign it to the delivery guy.

All the orders are initially in pending list, we only move orders from pending list to optimized list when optimized list has less than five orders. Why was this number kept exactly at 5 ? Since (2n)!/(pow(2,n)) for n=5 => 113400 and for an average computer this would take one sec to find the optimal path.

How to decide whether which order moves from pendling list to optimized list? For this I have calculated the minimum time to reach the restaurant will be the one that we will cater to. The minimum time would be simply max(time taken to reach that restaurant, avg prep. time). So, the order with minimum time moves to optimized list.

Once each order is in optimized list, we basically calculate all the permutations possible with those orders, weed out sequences where destination of customers precede their restaurants.

We use priority list to cater to the orders who have been already picked by the delivery guy , priority list size can be maximum two, hence we are having threshold such that the delivery guy cannot have more than two orders at a time with him/her.

Running the code: The BestRoute java file creates instances of restaurants,customers and orders and is the trigger point for the code. At any point of time orderService.getNextLocation();gives the delivery guy information about where to go next and to what coordinates.

bestrouteproblem's People

Contributors

bhaskarboora avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.