(let ((TEAMS '()) (NPERSONS 0) (NTEAMS 0) (TOTALBUDGET) (NUMOFITERATIONS 6) (CURRENTITERATION 1) (COMPLETED '())) (defstruct (team (:print-function print-team)) (number 0);index (budget 0);acc budget (runningCost 0) (size 0) (alphas 0);these three are percents (betas 0) (omegas 0) (completed) (possible) ) (defun print-team (team stream depth) (format stream "Team number: ~A,Budget: ~A, Running cost: ~A, Size: ~A, Alphas: ~A, Beatas: ~A, Omegas: ~A, Comp: ~A, Pos: ~A" (team-number team) (team-budget team) (team-runningCost team) (team-size team) (team-alphas team) (team-betas team) (team-omegas team) (team-completed team) (team-possible team))) (defun generateTeams ();use this value to calculate the possible budgets for each team. ;create a function to reset budget for all teams, and another function to incriment the team budget for all teams ;commented out for testing (let ((persons (floor (get-static 'size)))) (setf NPERSONS persons TEAMS '() Nteams 0) (while (> persons 0) (incf NTEAMS) (push (make-new-team persons NTEAMS) TEAMS) (incf persons (- (team-size (first TEAMS)))))) (setf TEAMS (reverse TEAMS)) NIL) (defun generateTeamsPost (totalCost) (setf TOTALBUDGET totalCost)) (defun get-number-of-teams () NTEAMS) (defun get-teams () TEAMS) (defun get-team-indexes () (mapcar #'team-number TEAMS)) ;Retruns the team (defun get-team (teamnumber) (nth (- teamnumber 1) TEAMS)) ;Calculates the budget correction factor (defun getEffectiveBudget (team iteration endIteration) (let ((activeBetas 0) (activeOmegas 0) (activeAlphas (team-alphas team)) (activeTeam (activePart iteration endIteration)) (activeTeamPart 0) (norm 1)) (setf activeTeamPart (max activeTeam activeAlphas) activeTeam (max 0 (- activeTeam activeAlphas)) activeBetas (min activeTeam (team-betas team)) activeTeam (max 0 (- activeTeam activeBetas)) activeOmegas (min activeTeam (team-omegas team)) norm (+ activeAlphas activeBetas activeOmegas) ) (/ norm (+ activeAlphas (* 1.22 activeBetas) (* 1.6 activeOmegas))))) ;Increases the team budget for the current iteration ;Assigns the buget according to the team size , and the uses the correction factor (defun assignBudget () (dolist (team TEAMS) (incf (team-budget team) (* (/ (team-size team) NPERSONS) (/ TOTALBUDGET NUMOFITERATIONS) ;(getEffectiveBudget team CURRENTITERATION NUMOFITERATIONS) ))) (incf CURRENTITERATION)) ;Reset all actions for all teams, prepeare them for next iteration (defun resetTeams () (dolist (team TEAMS) (setf (team-runningCost team) 0) (setf (team-budget team) 0 ) (setf (team-possible team) NIL) (setf (team-completed team) NIL)) (setf CURRENTITERATION 1) (setf COMPLETED '())) ;Gets the possible tasks from the task tree ;type is which sorting function to use 'AG, 'AG2, 'PB or 'HY (defun getPossibleFromTree (type) (dolist (team TEAMS) (setf (team-possible team) (getTasksForTeam (team-number team) type)))) ;complets the tasks among the possible tasks up til current budget limit. (defun completeTasks() (dolist (team TEAMS) (while (and (team-possible team) (< (getTaskCost (first (team-possible team))) (- (team-budget team) (team-runningCost team)))) (push (pop (team-possible team)) (team-completed team)) (incf (team-runningCost team) (getTaskCost (first (team-completed team)))) (finishTask (first (team-completed team))) (push (first (team-completed team)) COMPLETED)) ;Non spend money getswaisted if there are no more thing to do (if (eql (length (team-possible team)) 0) (setf (team-runningCost team) (team-budget team))) )) (defun getAllCompleted () (reverse COMPLETED)) ;Closing Let, leixcal inclosure )