- fetches packages and drones (arrays of objects) from an API
- loops through these collections and calculates the time for each member to reach the depot (for a package or a drone not already carrying a package, this is a direct trip; for a drone already carrying a package, this is a trip to its current destination, then to the depot)
- stores the time for each trip in a new property on the object
- sorts the array by that property, in ascending order
- with the packages and drones sorted, loops through the packages array in reverse (beginning with the package with the longest travel time to the depot)
- for each package, loops through the drones array, and for each drone, if it hasn’t already been assigned another package, i.e., if it’s not busy (see below), calculates the travel time for the drone to pick up the package from the depot and deliver it to its destination and adds that duration to the current time (UTC)
- if the arrival time is on or before the deadline, assigns the drone to the package and adds the drone to the ‘busy’ array; if no drone can make the delivery on time, adds the package to the ‘unassigned’ array
- displays the results in the browser in a simple layout
-
Notifications
You must be signed in to change notification settings - Fork 0
johnthecomposer/dispatcher
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A dispatcher that assigns drones to packages to be delivered.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published