;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This file is part of "NOVA": NOVA = search + COCOMO tools ; Copyright, 2008, Tim Menzies tim@menzies.us ; ; NOVA is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; NOVA is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License ; a long with NOVA. If not, see . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defsearch seesaw2 () ;; start by moving all non-singleton treatments to the closed list ;; this simplifies the creation of singleton treatments (move-elts (non-singletons? open) open closed) (save-state) (if *debug-search* (print-state (first-state? path))) (loop ;; if the solution is fully constrained, return (if (= (constrained% (first-state? path)) 1) (return)) ;; generate min and max singleton treatments for each unconstrained feature (dolist (treatment (coalesce-treatments closed)) (let ((feature (car treatment)) (range (cdr treatment))) (unless (find feature open :key #'car) (with-new-path (move-elt (list feature (apply #'min range)) closed open) (save-state) (push path paths)) (with-new-path (move-elt (list feature (apply #'max range)) closed open) (save-state) (push path paths))))) ;; choose the best treatment (let* ((*monte-carlo-iterations* 100) ; adjust this to affect speed/min energy accuracy (best-e (energy? (min-energy? paths)))) (dolist (new-path paths) (when (= best-e (energy? (min-energy? new-path))) (let ((best (set-difference (state-open (first-state? new-path)) open :test #'equal))) (move-elt (car best) closed open) (return))))) (save-state) (energy? (first-state? path)) (if *debug-search* (print-state (first-state? path))) (setf paths nil)) (if *debug-search* (terpri)))