;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 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 seesaw ((smart% 0.95)) (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)) ;; constrain a random feature to its min or max value (let* ((treatment (?elt (coalesce-treatments (non-singletons? open)))) (feature (car treatment)) (range (cdr treatment))) ;; create new states with the min and max ranges (with-new-path (move-elts (separate-treatments (list treatment)) open closed) (move-elt (list feature (apply #'min range)) closed open) (save-state) (push path paths)) (with-new-path (move-elts (separate-treatments (list treatment)) open closed) (move-elt (list feature (apply #'max range)) closed open) (save-state) (push path paths)) ;; choose the better of the two states ;; possibly stay at the current state if better than the two new states (let ((path2 (pop paths)) (path1 (pop paths))) (when (or (< smart% (my-random 1)) (< (min (energy? (first-state? path1)) (energy? (first-state? path2))) (energy? (first-state? path)))) (if (< (energy? (first-state? path1)) (energy? (first-state? path2))) (switch-path path1) (switch-path path2)) (if *debug-search* (print-state (first-state? path))))))) (if *debug-search* (terpri)))