Skip to content

Instantly share code, notes, and snippets.

@agileurbanite
Created March 28, 2015 00:20
Show Gist options
  • Save agileurbanite/5fa3a29b10d9566cb05b to your computer and use it in GitHub Desktop.
Save agileurbanite/5fa3a29b10d9566cb05b to your computer and use it in GitHub Desktop.
Bike Allocation Problem

Problem:

Dispatch and redistribute bikes through different nodes based on distance and need.

Assumptions:

  • A need is defined as closest to, or is, zero capacity or closest to filled, or is filled capacity.
  • Distance and average time it takes to travel to node based on need from last point. (Who is your nearest neighbor?)
  • The optimal state of a node is half of it's capacity.
  • What is the current state of the van if it is less then the optimal state must be greater, it needs to travel to a neighbor with filled or close to filled capacity to redistribute or back to headquarters.
  • This must be at a scheduled interval, as a dispatch to reallocate bikes based on need would need to be on a scheduled basis, or there needs to be a way to calculate the optimal time to deliver and redistribute bikes with a cost benefit algorithm.

We should order the nodes based on distance first, then by need.

Distance ranges from 1 to 100 from current position

getAndSortClosestNodeBasedOnNeed(currentPosition)

Thoughts on array returned [ { distance: 1, currentDriveTime: 2, need: 4 }, { distance: 6, currentDriveTime: 5, need: -4 }, { distance: 15, currentDriveTime: 5, need: 2 } ]

verifyIfVanHasCapacity(currentCapacity)

If a need is negative then it is at surplus and can give bikes to the van.

Concerns

Average Ride Time Problem

It is safe to assume that even though a node has a need of four where it is approaching zero capacity that we should take into account the average ride time of users in that locale. If the average ride time is greater then the average time it takes for the van to travel to that distance and the van has capacity and it is the closest node, then yes, we can add bikes to that location.

However, those bikes must be picked back up when that busy riding time dies down in order to ensure that users have the ability to return bikes to an empty slot.

Then again it is better to return bikes to an empty slot rather then the negative user experience of trying to return a bike to a slot at capacity and trying to find a new bike slot. (App should notify user of current slot availability at nearest node)

Average Drive Time

We need to ensure that the nearest node with the most need might not necessarily equate to the most optimal solution. There might be road closures and traffic during peak hours that would affect the current proposed solution.

Broken Bikes

Broken bikes that need picking up will need to be attributed to the capacity the van can start off with, the proposed solution needs to be revisited and thought out to understand how we can accoutn for picking up of broken bikes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment