autoschedule.org 3.3 KB

Automatic Scheduling of Appointments with Block-Based Timing

Many modern applications revolve around scheduling. However, many times, the scheduling should be automatic.

Introduction

System Definition

To achieve the use of this software, I define an ASDF package, and a couple of CL packages to avoid cluttering the main namespace.

DefSystem

The application is designed to be used mostly for the purposes of demonstration, but could be used alongside others as a library. To allow for this, I use ASDF to define a loadable system.

  (asdf:defsystem #:autoschedule
    :serial t
    :description "Automatic Scheduling"
    :author "Samuel W. Flint <swflint@flintfam.org>"
    :license "GNU General Public License"
    :depends-on (#:sxql
                 #:cl-postgres)
    :components ((:file "package")
                 (:file "autoschedule")
                 (:file "test")))

Package Definition

This system has two packages, a primary package, and a test package. For this, there are two defpackage forms.

  (defpackage #:autoschedule
    (:use #:cl
          #:sxql
          #:cl-postgres)
    (:documentation "The autoscheduling system."))

  (defpackage #:autoschedule.test
    (:use #:cl
          #:autoschedule)
    (:documentation "Autoschedule test suite"))

A Base Database

To allow this system to be as flexible as possible, the table must be as simple as possible. It also should be fairly simple.

  (defvar *generate-scheduling-table*
    (create-table :schedule
        ((artist-id :type 'integer
                    :primary-key t
                    :not-null t)
         (start-block :type '(integer 0 47)
                      :not-null t)
         (end-block :type '(integer 0 47)
                    :not-null t)
         (julian-date :type 'integer
                      :not-null t)
         (type :type '(integer 1 3)
               :not-null t)
         (project :type 'integer
                  :not-null nil))))

The Manual Scheduler

An important part of the scheduler is to be able to schedule things manually, partly because of the ability to schedule leave, and the need to schedule things in off hours.

  (defun schedule-manually (artist start-block end-block julian type &optional project)
    "Manually schedules an appointment or time entry."
    (declare (unsigned-int artist)
             (type (integer 0 47) start-block end-block)
             (integer julian type))
    )

The Auto Scheduler

A Test

Putting it Together