Fritz Meissner
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Lane assignment algorithm We need to match orders to the best drivethrough lane based on the new order and the contents of each lane. The overview of the algorithm is: 1. if a lane is empty, assign the next order there 2. ignore lanes that are full 2. if no lanes are empty, calculate the scores for all lanes and the new order 3. place the order in the lane with the closest score to the score of the order 4. if there is a tie between lanes, place the order in the tied lane that has the lowest total order score 5. if there is a tie in order score, place the order in the lane with the fewest items ## Introductory order score Calculate the score of the new order and the orders in the lanes based on their cost (ranges have been chosen based on pickup order code): 0-5000 SAR = 5 5000-10000 SAR = 10 10000+ SAR = 20 Normalised the order score to always fall between 0 and 1 by dividing by 20. The exact groups do not need to stay fixed like this as long as the score can be normalised to between 0 and 1, so that it is comparable with other values in this document. We have discussed storing an exact value for the preparation of each product in the database, and adding up all the products in an order in order to determine an order score. That approach can be implemented after launch if it is helpful. ## Lane score formula This formula has been designed to give a higher value when there are larger size orders in the lane (high average), but to reduce as more orders are added to the lane. `max(0, average normalised order score - 0.25 * utilisation)` Where * average normalised order score = `sum of orders in lane / number of orders in lane` * utilisation = `number of orders in lane / max capacity of lane` This formula should produce a value between 0 and 1 for a lane so that it can be compared with a new order's score. This formula should be refined as time goes on, ideally with proper simulation (Connor has offered to help with this). ## Implementing the changes to current albaik-web code This is a plan for making a series of small changes to our current code. - implement a score calculation for an individual order based on [order score](#introductory-order-score) (suggestion: a small DriveThruOrderScore class might be good) - add a `MAX_CAPACITY` constant to Lane. This will be the same for all lanes, which might not match reality. A customisable value can be added after the whole algorithm has been implemented. - update `LaneAssignment` to ignore lanes that are full (use the `MAX_CAPACITY` constant) - update `LaneAssignment` to automatically choose the first empty lane if any are available - implement a lane utilisation calculation based on the hardcoded `MAX_CAPACITY` - implement the lane score calculation (suggestion: a method on `Lane`) - update `LaneAssignment` to take in an order score and return the lane with the closest lane score based on the formula above. --- # Modelling I (Connor) didn't make as much progress as I would have liked. Partly because it took a while to get my machine set up, partly because my brain was rusty, and partly because it's an even longer while since I used numpy/scipy instead of matlab. Having said that, I did make some progress and I hope this can lay the groundwork for future work. Broadly what we want to achieve is: - Evaluate lane assignment algorithms for suitability - Improve algorithms/order score weights Given a lane assignment algorithm, we can optimise the weightings/order score ratings to minimise “unfulfilled” orders —where an unfulfilled order corresponds to an order not being placed due to all lanes being full. In reality these orders would likely be moved to waiting bays, but this metric is a useful heuristic for measuring how well lane assignment is facilitating order throughput. ## What we have done so far 1. Rejected outliers from historical order data using modified Z-score 2. Approximated the probability distribution of order subtotal based on a subset of historical order data. 3. Used this distribution to calculate the probability an order has a subtotal in the bins defined by the order score (i.e 0-5000, 5000-10000, 10000+ SAR). 4. Guessed the range of “time to serve” each order subtotal bin corresponds to. 5. Run crude a time-stepping simulation to predict “unfulfilled orders”. ## Simulation assumptions (simplifications) ### Time to serve an order is linked to order subtotal Order subtotal is the basis upon which orders are scored, and a time to serve value is assigned to each order so that orders can be popped from the each lane queue over time. Orders with higher scores correspond to orders that take longer to serve. A time is chosen at random from a range of times, for each order. This could be improved if we had more accurate data (e.g similarly to how we used order subtotal data to obtain an approximate probability distribution for order subtotal). We might find that the existing order subtotal bins (which are used to estimate pickup preparation collection time) aren’t appropriate for predicting drive thru preparation collection times. ### Orders are placed regularly (i.e every X seconds) over a given time period. I doubt this is accurate, though. A simple, but quick, improvement might be to break down the model into “chunks”, whereby each time period has a different fixed order rate. This would account broadly for peaks in demand, and this might be good enough. A more complicated approach might use the probability an order is placed at any given time of day in a given branch to place orders irregularly (but more realistically). ### Unfulfilled orders are never fulfilled Rather than modelling waiting bays, this counts the number of unfulfilled orders. In reality, orders would go into a waiting area and be fulfilled at some point (i.e there is another queue). There might be a relationship between unfulfilled orders and future order rate (i.e when there are 5 unfilled orders, these need to be placed ASAP), but I’m not sure we should worry too much about this. ### Defined variables in simulation The below variables should be adjusted to reasonable values - Lane capacity (assumed equal across lanes) - Number of lanes - Order rate (assumed fixed) ## Next steps - Refine the code so we can optimise the algorithms/weights - Optimise algorithms/scoring weights for minimum unfulfilled orders - Explore order items as an indicator of order complexity ## Resources [GitHub repo](https://github.com/thoughtbot/albaik-lane-assignment)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully