All Projects → Staffjoy → autoscheduler

Staffjoy / autoscheduler

Licence: MIT license
Staffjoy Suite (V1) Deprecated Microservice - Original autoscheduling algorithm, which combines shift creation and assignment. No longer compatible with open-source suite.

Programming Languages

julia
2034 projects
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to autoscheduler

Mobius Assignment
Staffjoy Suite (V1) Microservice - Shift Assignment Subject To Constraints
Stars: ✭ 23 (-66.18%)
Mutual labels:  math, scheduling
vector2d
2D Vector Library. Operates using Objects, Array or Float32Array types to allow flexible performance.
Stars: ✭ 28 (-58.82%)
Mutual labels:  math
hexo-filter-mathjax
💯 Server side MathJax renderer plugin for Hexo.
Stars: ✭ 76 (+11.76%)
Mutual labels:  math
lit
Literature for the self-taught AI practitioner! 📚
Stars: ✭ 199 (+192.65%)
Mutual labels:  math
HCubature.jl
pure-Julia multidimensional h-adaptive integration
Stars: ✭ 119 (+75%)
Mutual labels:  math
combinatorics.rb
Bringing (more) Combinatorics to Ruby.
Stars: ✭ 44 (-35.29%)
Mutual labels:  math
multitrainer
A math game for children to help them learning multiplication
Stars: ✭ 22 (-67.65%)
Mutual labels:  math
rclc
Mathematical expression calculator with big integers, floats, common fractions, and complex numbers support
Stars: ✭ 24 (-64.71%)
Mutual labels:  math
FixedPoint-Sharp
Fixed point math with 48.16 precision (based on lib by https://github.com/fholm)
Stars: ✭ 114 (+67.65%)
Mutual labels:  math
arabic-mathjax
Beautiful Arabic Math on all browsers. An extension for MathJax v2.
Stars: ✭ 12 (-82.35%)
Mutual labels:  math
maths-for-deep-learning-ai
A open source book covering the foundational maths of deep learning and machine learning using TensorFlow
Stars: ✭ 35 (-48.53%)
Mutual labels:  math
coo
Schedule Twitter updates with easy
Stars: ✭ 44 (-35.29%)
Mutual labels:  scheduling
Hecke.jl
Computational algebraic number theory
Stars: ✭ 142 (+108.82%)
Mutual labels:  math
BookLibrary
Book Library of P&W Studio
Stars: ✭ 13 (-80.88%)
Mutual labels:  math
dhroraryus
Dhroraryus generates schedules intelligently according to one's constraints and preferences
Stars: ✭ 16 (-76.47%)
Mutual labels:  scheduling
mish
A no-std libm implementation in Rust
Stars: ✭ 14 (-79.41%)
Mutual labels:  math
census-error-analyzer
Analyze the margin of error in U.S. census data
Stars: ✭ 15 (-77.94%)
Mutual labels:  math
math eval
✖️➕➖➗ `math_eval` safely evaluates mathematical expressions
Stars: ✭ 33 (-51.47%)
Mutual labels:  math
BUPT-ICS-Courseware
北京邮电大学 数学系 信息与计算科学专业 课件
Stars: ✭ 76 (+11.76%)
Mutual labels:  math
my-math-notes
All of my math stuff from grad school.
Stars: ✭ 41 (-39.71%)
Mutual labels:  math

Staffjoy Autoscheduler

Build Status Moonlight contractors

Staffjoy is shutting down, so we are open-sourcing our code. This repo was the original scheduling algorithm. The repo predates Staffjoy as a company by about a year, and it underwent constant rewrites and improvements. Along the way, we mixed integer programming libraries with techniques like dynamic programming. We used the Julia Programming Language, and Staffjoy is eternally grateful to the Julia JuMP project for making such a great library that it rekindled an interested in scheduling optimization algorithms that became Staffjoy.

This scheduler started serving paying customers via spreadsheets over email starting in January 2015, then eventually integrated with a web application that we launched at the end of that year. It served production traffic until it was replaced by Chomp decomposition and Mobius assignment in 2016.

In production, we used a proprietary third party solving package that provided significant speed gains. If that library is not present, the library falls back to a slower, open-source library. As such, some tests must be disabled for the public CI system.

Credit

The architect primary author of this repo was @philipithomas. This is a fork of the internal repository.

General Approach

This approach uses a variety of dynamic programming techniques and heuristics to create workers then assign them to shifts. It assumes that businesses are not open 24/7 (or, if they are, that all shifts turn over at one particular time.) It has two basic optimization models:

  1. Week Model - Assigns workers to days of the week to work, while maximizing lift - basically, a ratio of (worker availability)/(hours of work to do). A ratio of less than one is impossible to solve. We found that, the higher the ratio, the more likely a day model is to converge.
  2. Day Model - Given workers, and demand for a day, it generates assigned shifts, each with a start and end time, while minimizing the total number of hour scheduled.

It combines these two models with Serial Scheduling, where we start with one day of the week, run the Day Model, then schedule the following day - with its model being modified for how the previous day's schedule affects the following day, and continue this until the end of the week.

If a worker work slate on Monday, they can't open on Tuesday. If they have a limit of 40 hours per week and are scheduled for 34 hours, they cannot work more than 6 hours on any remaining day. Due to these changes, the model must be run serially.

In practice, we start the serial scheduling on each of the seven days of the week, and run the seven different serial scheduling models in parallel. Every Day Model is cached, so in practice - seeding the serial scheduler with all start days only adds additional computation time if the results change.

Overall, the algorithm basically functions like this:

  1. Minimize lift in the Week Model
  2. Run Serial Scheduling, starting with each day of the week. If we hit perfect optimality, return. Otherwise, keep the best solution.
  3. Re-run the Week Model, where the lift must be lower than the previous one, and repeat until we time out.

Dev

Run vagrant up to build the development environment. Enter it with vagrant ssh. Code is synced to the /vagrant folder. You can run tests and the server inside this development environment.

To rebuild the development environment, run vagrant destroy -f && vagrant up outside the VM.

Tests

  • make test: runs unit tests and functional test for both the StaffJoy module and the Manager module. (make scheduler-test && make manager-test)
  • make test-unit: runs unit tests for the StaffJoy module and the Manager module. Skips the (very slow, resource-intensive) functional tests. (make scheduler-test-light && make manager-test)
  • make test-functional: runs unit tests for the StaffJoy module and the Manager module.
  • make test-scheduler-unit: runs unit tests for the StaffJoy module
  • make test-manager-unit: runs unit tests for the Manager module
  • make test-scheduler-functional: runs functional tests for the StaffJoy module. Very slow - probably requires four cores and 45 min to pass.
  • make test-manager-functional: runs unit tests for the Manager module.

Modules

StaffJoy Module

The StaffJoy module includes the core logic for the day scheduler and the week scheduler. Consider this application "Dumb" - it should not be aware of environment, continuous time, task queue, etc.

Manager Module

The Manager module translates requests from the App for calculation using the StaffJoy module. This includes:

  • Environment (dev / stage / prod) awareness
  • Tasking - retrieving data from the App server
  • Server - set up a service that runs on a server, and perhaps in a Docker container.
  • Response - send back completed schedules to the App

Request format

This is what the JSON for the Manager should look like when it does a POST request to the API:

POST
{
    "schedule_id": 1,
    "role_id": 1,
    "location_id": 1,
    "organization_id": 1,
    "api_token": "abc123"
}

Org Options

These org options are consumed by scheduler Others are disregarded.

{
    data: {
        "no_shifts_after": 17, // Optional - stop shifts after time 17 (exclusive) only in pure unassigned shift mode
        "min_shifts_per_week": 4,
        "max_hours_per_week": 29,
        "max_shift_length": 8,
        "max_shifts_per_week": 5,
        "min_hours_per_week": 20,
        "id": 3,
        "hours_between_shifts": 12,
        "day_week_starts": "monday",
        "min_shift_length": 4,
    }
}

Response Format

This is what the JSON callback from the Manager to the App API looks like:

DELETE
{
    "solver_hash": "12lfls3lf" // Git hash of solver version used.
}

Environment Variables

The system defaults to a development environment where no environment variables are necessary.

  • ENV - either 'dev', 'stage', or 'prod'
  • API_KEY - a persistent api key associated with a Sudo-level user on Staffjoy Suite.
  • (optional) SLEEP - seconds between fetches to the tasking api. Defaults to 60 seconds in stage/prod.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].