;; -*- Mode: Lisp; -*- ;;;; Measurement Interpretation system ;;;; File name: mi.lsp ;;;; modified: Thursday, February 14, 2008 at 11:26:35 by Ken Forbus ;;; Copyright (c) 1991-1992, Kenneth D. Forbus, Northwestern University, ;;; and Johan de Kleer, the Xerox Corporation. ;;; All Rights Reserved. ;;; See the file legal.txt for a paragraph stating scope of permission ;;; and disclaimer of warranty. The above copyright notice and that ;;; paragraph must be included in any separate copy of this file. (in-package :cl-user) (defun mi (scenario measurements &key (debugging nil) (debugging-dds nil) (title nil) (domain *tgizmo-domain-file*)) (with-tgizmo (setq *tgizmo* (create-tgizmo (if title title (format nil "MI of ~A" scenario)) :debugging debugging :scenario scenario :measurements measurements)) (with-ltre (tgizmo-ltre *tgizmo*) (bps-load-file *ltre-path* *set-rule-file*) (setq *debug-dds* debugging-dds) (bps-load-file *tgizmo-path* *tgizmo-laws-file*) (bps-load-file *tgizmo-path* domain) (load-scenario scenario) (dolist (d measurements) (assume! d :measured)) (find-states *tgizmo*)) (values *tgizmo* (length (tgizmo-states *tgizmo*))))) (defun find-states (&optional (*tgizmo* *tgizmo*)) (setf (tgizmo-nstates *tgizmo*) 0) (setf (tgizmo-states *tgizmo*) nil) (search-psvs `(resolve-completely '(push (snapshot (incf (tgizmo-nstates *tgizmo*))) (tgizmo-states *tgizmo*))))) (defun debug-find-states (&optional (thunk '(progn (push (snapshot (incf (tgizmo-nstates *tgizmo*))) (tgizmo-states *tgizmo*)) (print (tgizmo-nstates *tgizmo*)) (when (tg-fetch '(active ?x) :unknown) (show-state (car (tgizmo-states *tgizmo*))) (break "~% Some status assignments unknow at state ~D" (tgizmo-nstates *tgizmo*))))) (*tgizmo* *tgizmo*)) (search-psvs `(resolve-completely ',thunk)))