Coder Social home page Coder Social logo

d-scheduler's Introduction

Scheduler

A pair of python classes for generating a schedule for n teams from an activities file.

Usage

To use the scheduler in another python file, place scheduler.py in an adjacent directory (e.g. ../scheduler/), it can then be imported and used as follows.

from scheduler import scheduler

s = scheduler.Scheduler()

Create a set of schedules by passing a number of teams and the path to an activities text file to the scheduler method:

schedule_set = s.scheduler(5,'activities.txt')

The make_schedule method formats each schedule into a list of event strings whose formatting matches that of the case study.

For convenience, an output method is also provided which prints the properly-formatted set of schedules to the console.

s.output(schedule_set)

To test the Scheduler() class, run the test-scheduler.py file.

Quick Example

The test file, test-scheduler.py, will print a set of six schedules to the console - note that the activities.txt file must be in the same directory.

$ python test-scheduler.py

Discussion

The case-study stated that lunch is served at noon, however in the provided example lunch did not occur at noon exactly but rather it was served at or before noon and not thereafter. I decided to make use of this apparent flexibility.

The case-study did not stipulate the number of teams that would be participating; my scheduling function accepts a number of teams as a parameter.

The function will not schedule an event that overlaps with lunch or the end-of-day presentation, but this comes at a cost of gaps. A potential improvement would be to write a filler function which inserts shorter activities when 11am < schedule running total < 12pm or 4pm < schedule running total < 5pm.

With the activities provided in the case-study it is possible to create a rota for 14 teams or less; the code will throw an error if the user tries to create schedules for more than 14 teams using the provided acitivities.

Because of the random approach that I have taken, when scheduling for 14 teams, the function can make hundreds of attempts before it finds a set of schedules which don't overlap. Hence, I have inserted a catch to prevent the code from reaching python's recursion limit and crashing, although this comes at a cost of occasionally not providing the output sought by the user. Python's recursion limit can be altered - one potential addition to this script would be to offer a mechanism for the user to effect that.

d-scheduler's People

Contributors

willemveerman avatar

Watchers

James Cloos 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.