(load "globals.lisp") (reset-seed) (load "structs.lisp") (load "macros.lisp") (load "utils.lisp") (load "utils2.lisp") (load "dist.lisp") (defun retrieve-initial-requirements (allrequirments) (split-list (random-between-int (* (globdef-initial_bound_lower gv) (globdef-num_reqs gv)) (* (globdef-initial_bound_upper gv) (glob-def-num_reqs gv))) allrequirements) ) ;this function is wrong. needs to update req_heap somehow so we dont keep re-adding the same requirements ;(defun ag-additional-requirements (currentrequirements remainingrequirements) ;(let ((numreqstoadd (pRandom (globdef-ave_unimpl_req_per_iter gv))) ;) ;(if (< 1 (floor numreqstoadd)) ;currentrequirments ;(append currentrequirements (justinsfunction remainingrequirements numreqstoadd)) ;) ;currentrequirements ;) ;) ;run simulations (defun runSimulation() (do* ((requirements (generate-value-cost)) ;generate VALUE and COST list like((1 2)(2 3)) (retrieve-initial-requirements requirements) (current_iter 1) (AG2_COMPLETED nil) (trial 1) (end_development nil)) ((or (> trial 1000))) (progn (do* () ((or (> current_iter (globdef-num_iters gv)) end_development)) (progn (setf PLAN (sort PLAN #'> :key #' value_div_cost)) ;sort PLAN by value/cost (setf num_completed (floor (* 0.8 (length PLAN)))) ;requirements number to take off form PLAN (setf PLAN (last PLAN (- (length PLAN) num_completed))) ;renew PLAN by removing 80% (setf TAKEOFF (subseq PLAN 0 num_completed)) ;save the completed requirements (setf randp_num (floor (randp 1.4))) (setf PLAN (append PLAN (last HEAP randp_num))) ;update the plan by adding new reqs from heap (setf HEAP (subseq HEAP 0 randp_num)) ;updat the HEAP (do ((i 0 (+ i 1))) ;renew the value of plan by adding randnorm ((> i (- (length PLAN) 1))) (progn (setf (car (nth i PLAN)) (+ (car (nth i PLAN)) (randnorm 0 req_value_sigma))))) (setf PLAN (remove-if #'first0 PLAN)) ;remove the reqs that value<=0 (if (> current_iter (globdef-min_iters gv)) (setf end_development (randbin1 (globdef-end_dev_prob gv)))) (setf AG_COMPLETED (append AG2_COMPLETED TAKEOFF)) (print "iter:") (print current_iter) (print "AG2_COMPLETED") (print AG2_COMPLETED) (incf current_iter))))))