#+Title: Automatic Scheduling of Appointments with Block-Based Timing #+AUTHOR: Sam Flint #+EMAIL: swflint@flintfam.org #+DATE: \today #+INFOJS_OPT: view:info toc:nil path:http://flintfam.org/org-info.js #+OPTIONS: toc:nil H:5 ':t *:t #+PROPERTY: noweb tangle #+PROPERTY: comments noweb #+LATEX_HEADER: \usepackage[color]{showkeys} #+LATEX_HEADER: \parskip=5pt #+LATEX_HEADER: \lstset{texcl=true,breaklines=true,columns=fullflexible,frame=lines,literate={lambda}{$\lambda$}{1} {set}{$\gets$}1 {setq}{$\gets$}1 {setf}{$\gets$}1 {<=}{$\leq$}1 {>=}{$\geq$}1} #+BEGIN_ABSTRACT Many modern applications revolve around scheduling. However, many times, the scheduling should be automatic. #+END_ABSTRACT #+TOC: headlines 3 #+TOC: listings * 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. #+CAPTION: ASDF System Definition #+Name: asdf-definition #+BEGIN_SRC lisp (asdf:defsystem #:autoschedule :serial t :description "Automatic Scheduling" :author "Samuel W. Flint " :license "GNU General Public License" :depends-on (#:sxql #:cl-postgres) :components ((:file "package") (:file "autoschedule") (:file "test"))) #+END_SRC ** Package Definition This system has two packages, a primary package, and a test package. For this, there are two =defpackage= forms. #+CAPTION: Package Definitions #+Name: package-definitions #+BEGIN_SRC lisp (defpackage #:autoschedule (:use #:cl #:sxql #:cl-postgres) (:documentation "The autoscheduling system.")) (defpackage #:autoschedule.test (:use #:cl #:autoschedule) (:documentation "Autoschedule test suite")) #+END_SRC * 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. #+CAPTION: Schedule Table #+Name: Schedule #+BEGIN_SRC lisp (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)))) #+END_SRC * 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. #+CAPTION: Manual Scheduler #+Name: manual-scheduler #+BEGIN_SRC lisp (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)) ) #+END_SRC * The Auto Scheduler * A Test * Putting it Together