;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 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 isamp ((num-tries 25)) (let ((max-energy 0)) (dotimes (i num-tries) (if *debug-search* (format t "Try #~a~%" (1+ i))) (with-new-path (save-state) (if *debug-search* (print-state (first-state? path))) (loop (cond ;; if the solution is fully constrained, halve max-energy and retry ((= (constrained% (first-state? path)) 1) (setf max-energy (* max-energy 0.5)) (return)) ;; if max-energy has been exceeded, save the new max-energy and retry ((> (energy? (max-energy? path)) max-energy) (setf max-energy (energy? (max-energy? path))) (return))) ;; randomly move a treatment from open to closed (let ((treatment (?elt (non-singletons? open)))) (move-elt treatment open closed)) (save-state) (if *debug-search* (print-state (first-state? path)))) (push path paths))) ;; switch to the best path (switch-path (find (min-energy? paths) paths :key #'min-energy? :test #'equal)) (if *debug-search* (terpri))))