scheduler

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

Meeting Scheduler

GoDoc

Imagine you want to have a meeting with someone, but it's not urgent and can wait until next week. You open up a web interface where you enter "I want to have a meeting with Eric for 30 minutes". At Sunday night a meeting scheduler will take all queued meeting requests and schedule the events

  • as early as possible in the week to allow the people to be productive for the rest of the week.
  • as close as possible to other meetings to avoid the attendees to have fragmented days where time by an actual computer is only for 30 minutes of which they are getting nothing done.

meeting-scheduler is a library that will do the scheduling of the above. The scheduling is an NP-complete problem, so this library uses a heuristical approach to finding an optimal schedule - a genetic algorithm backed by the excellent eaopt library.

This library was initially developed during a Tink hackathon.

Documentation

Overview

Package scheduler is a meeting scheduler that tries to schedule meetings as early and as packed as possible in the workweek.

Imagine you want to have a meeting with someone, but it's not urgent and can wait until next week. You open up a web interface where you enter "I want to have a meeting with Eric for 30 minutes". At Sunday night a meeting scheduler will take all queued meeting requests and schedule the events 1) as early as possible in the week to allow the people to be productive for the rest of the week and 2) as close as possible to other meetings to avoid the attendees to have fragmented days where time by an actual computer is only for 30 minutes of which they are getting nothing done.

`meeting-scheduler` is a library that will do the scheduling of the above. The scheduling is an NP-complete problem, so this library uses a heuristical approach to finding an optimal schedule - a genetic algorithm backed by the excellent `eaopt` (https://www.github.com/MaxHalford/eaopt) library.

This library was initially developed during a Tink (https://www.tink.se) hackathon.

Index

Constants

View Source
const MaxIterations = 1000

MaxIterations is the number of iterations we allow before we consider we are stuck in a loop trying to schedule a ScheduleRequest. The code is complex. This avoids deadlock.

Variables

View Source
var DefaultNGenerations uint = 500

DefaultNGenerations is the number of generations that the genetic algorithm should execute before it's done. Increase this if your scheduling problem hasn't converged.

Functions

This section is empty.

Types

type Attendee

type Attendee struct {
	// Id is the unique identifier for an attendee.
	ID AttendeeID
	// Calendar is an instance of the attendee's calendar containing previously
	// scheduled meetings.
	Calendar Calendar
}

Attendee is an attendee that attends a meeting.

type AttendeeID

type AttendeeID string

AttendeeID is a unique identifier for a meeting attendee.

type Calendar

type Calendar interface {
	// Overlap checks if a TimeInterval overlaps with a preexisting event in a
	// Calendar.
	Overlap(TimeInterval) (*CalendarEvent, bool, error)
}

Calendar is an external calendar source.

type CalendarEvent

type CalendarEvent struct {
	TimeInterval
}

CalendarEvent is an event stored in a calendar.

type Config

type Config func(*Scheduler)

Config is an optional configuration to a Scheduler.

func NGenerations

func NGenerations(ngenerations uint) Config

NGenerations is an optional configuration option which changes the number of iterations that the genetic algorithm does.

type Room

type Room struct {
	// Is is a unique id for a room. It is mostly needed to be able to work
	// around the fact that Room isn't hashable and can't be stored in a map.
	ID RoomID
	// Calendar is the calendar of the room.
	Calendar Calendar
}

Room is a meeting room that can be booked.

type RoomID

type RoomID string

RoomID is a unique id for a room.

type ScheduleRequest

type ScheduleRequest struct {
	// Length is the requested length of the meeting.
	Length time.Duration
	// Attendees is a list of the attendees of the meeting.
	Attendees []Attendee
	// PossibleRooms is a list of the possible rooms in which the meetings can
	// take place. If you have multiple offices you might want to limit which
	// rooms a meeting can take place in.
	PossibleRooms []Room
}

ScheduleRequest is the input the scheduling. It's a request to schedule a meeting.

type ScheduledEvent

type ScheduledEvent struct {
	// TimeInterval is the time over which this event has been scheduled.
	TimeInterval
	// Attendees is a list of the attendees for this meeting.
	Attendees []Attendee
	// Room is the room in which the event will take place.
	Room Room
	// Request is the equivalent ScheduleRequest that generated this
	// ScheduledEvent.
	Request *ScheduleRequest
}

ScheduledEvent is an event which has been scheduled with a fixed time and rooms. It is the scheduled equivalent of a ScheduleRequest.

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler is a meeting scheduler that schedules meetings.

func New

func New(earliest time.Time, reqs []*ScheduleRequest, options ...Config) (*Scheduler, error)

New instantiates a new meeting scheduler that tries to schedule meeting requests, reqs, as close as possible to earliest which also minimizing attendee calendar fragmentation (that is, an attendee has a break of 45 minutes between meetings).

If you'd like your attendees to have pauses between their meetings, simulate that in Calendar.Overlap.

func (*Scheduler) Run

func (s *Scheduler) Run() ([]ScheduledEvent, error)

Run executes scheduling of meetings.

type TimeInterval

type TimeInterval struct {
	// Inclusive. Must be strictly before End.
	Start time.Time
	// Exclusive. Must be strictly after Start.
	End time.Time
}

TimeInterval holds an interval of time.

func (TimeInterval) Overlaps

func (ti TimeInterval) Overlaps(ti2 TimeInterval) bool

Overlaps checks if this interval overlaps with another interval.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL