(defun demo-search3 () (best 'AG) (best 'AG2) (best 'HY) (best 'PB)) (defun best (type) (let ((parameters (list 'DYNAMISIM 'CRITICALITY 'CULTURE 'TEAMSIZE 'SIZE 'TEAM-ALPHA)) (valuesOfEach 10) (valuesToKeep 10) (listOfTrials (list)) (nextListOfTrials (list)) (level 0)) (push (list (list) (copy-list parameters) 0 0) nextListOfTrials) (format t "~%==================~%This is Beam Search with a beam of ~A for ~A~%====================~%" valuesToKeep type) (while (not (null nextListOfTrials)) (format t "~%On level ~A. Trying treatments:~%" (incf level)) (setf nextListOfTrials (mapcar #'(lambda(x) (list (first x) (second x) (runPom2 type (first x)) (fourth x))) nextListOfTrials)) (setf nextListOfTrials (sort nextListOfTrials #'> :key #'third)) (setf nextListOfTrials (ldiff nextListOfTrials (nthcdr valuesToKeep nextListOfTrials))) (mapcar #'(lambda (x) (format t " ~A, ~A~%" (first x) (third x))) nextListOfTrials) (setf listOfTrials nextListOfTrials) (setf nextListOfTrials nil) (dolist (trial listOfTrials) (if (> (third trial) (fourth trial)) (progn (format t "-~A better than parent (~A vs ~A)~%" (first trial) (third trial) (fourth trial)) (dotimes (x valuesOfEach) (dolist (parameter (second trial)) (push (list (append (list (list parameter (our-sample parameter))) (first trial)) (remove-if #'(lambda (x) (equal x parameter)) (copy-list (second trial))) 0 (third trial)) nextListOfTrials))))))) (let ((best (first (sort listOfTrials #'> :key #'third)))) (format t "~%The best solution found is ~A with a score of ~A" (first best) (third best)) (format t "~%====================~%Begnning back select~%~%") (backselect (first best) type))))