;;;
If your browser supports JAVA, you can display the data in a graph by checking the Graphic output box on the interface page.(defparameter *counts-mal-sh* '( ((NVN AG0 AI 1) 848) ((VNN AG0 AI 1) 839) ((VNN AG0 II 1) 424) ((NVN AG0 AA 2) 422) ((NVN AG0 II 2) 421) ((VNN AG0 AA 1) 421) ((NVN AG2- AI 2) 289) ((NVN AG2* AI 2) 265) ((VNN AG1* AI 1) 254) ((VNN AG1- AI 1) 233) ((VNN AG0 IA 2) 223) ((NVN AG2- II 2) 207) ((NVN AG0 IA 2) 193) ((NVN AG2* AA 2) 189) ((NVN AG2- AA 2) 187) ((VNN AG1* II 1) 183) ((NVN AG2* II 2) 180) ((VNN AG1- II 1) 173) ((VNN AG1* AA 1) 170) ((VNN AG1- AA 1) 163) ((VNN AG1+ AI 1) 140) ((NVN AG1- IA 1) 137) ((VNN AG2- IA 2) 122) ((VNN AG2* IA 2) 115) ((NVN AG1+ IA 1) 109) ((VNN AG2+ IA 2) 102) ((NVN AG2+ AI 2) 98) ((NVN AG1* IA 1) 97) ((VNN AG1+ AA 1) 82) ((VNN AG1+ IA 1) 80) ((VNN AG1- IA 1) 75) ((VNN AG1+ II 1) 73) ((NVN AG2+ IA 2) 73) ((NVN AG2* IA 2) 67) ((NVN AG1- II 1) 61) ((VNN AG1* IA 1) 57) ((VNN AG2- II 2) 53) ((NVN AG1- AA 1) 52) ((NVN AG2- IA 2) 51) ((VNN AG2* II 2) 50) ((NVN AG1* II 1) 48) ((NVN AG1* AA 1) 48) ((NVN AG2+ AA 2) 46) ((VNN AG2- AA 2) 44) ((VNN AG2* AI 2) 37) ((NVN AG1- AI 1) 36) ((NVN AG2+ II 2) 36) ((VNN AG2- AI 2) 33) ((VNN AG2* AA 2) 31) ((NVN AG1* AI 1) 30) ((VNN AG2+ AI 2) 23) ((NVN AG1+ AI 1) 17) ((NVN AG1+ AA 1) 11) ((NVN AG1+ II 1) 11) ((VNN AG2+ AA 2) 10) ((VNN AG2+ II 2) 6) )) (defvar *responses* nil) (defvar *r-log* nil) (defvar *cells* nil) (defvar bigbest nil) (defvar *egn* 6.0) (defvar *v* nil) (defvar *text* t) (defvar *graphic* nil) (defvar *runs*) (defvar *overlay* nil) (defparameter *exp-results-mal-sh* '((0.22 0.56 0.20 ) (0.13 0.18 0.07 ))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; This section contains the interface for the WWW using the ;;; ACT-R on the Web application by Elmar Schwarz (defvar *WWW-interface*) (setf *WWW-interface* '((:heading "South Helvetica model" 2) (:new-para) (:table) (:table) "t: " (:string :sy *egn* 1.91) (:new-row) "Number of runs (10 - 100): " (:string :sy *runs* 10) (:table-end) (:table) (:checkbox "Text output" :sy *text* t) (:new-row) (:checkbox "Graphic output " :sy *graphic* nil) (:new-row) (:checkbox "Show simulation and experiment data on one graph" :sy *overlay* nil) (:table-end) (:table-end) (:new-para) (:button "Show Experiment Results" "(output-data-mal-sh *exp-results-mal-sh* nil)") (:new-para) (:button "Run model" " (if (and (numberp *runs*) (numberp *egn*) ) (progn (setf *egn* (* *egn* *egn* pi pi 1/6)) (doit-mal-sh (min 200 (max 10 *runs*)))) (format *standard-output* \"Parameters must be numbers.~%\")) " ) (:reset "Default values") (:button "Production Rules" "(let ((prods (no-output (pp)))) (dolist (x prods) (pp-fct (list x)) (spp-fct (list x)) (format *standard-output* \"~%\")))") (:button "Chunk types" "(chunk-type)") (:button "Chunks" "(dm)") (:new-para) "TIME:" (:new-para) "- It usually takes about 1 minute for 10 runs of the model" (:new-para))) (defun output-data-mal-sh (data sim) (when sim (format *standard-output* "~%~%Parameters for run: (~S ~S)~%~%" (sqrt (/ *egn* 1/6 pi pi)) *runs*)) (when *text* (format *standard-output* "~%~%~A Average Results:~%" (if sim "Simulation" "Experimental")) (format *standard-output* " Percent Cue Use Standard Error~%") (format *standard-output* "Word Order ~4,3F ~4,3F~%" (first (first data)) (first (second data))) (format *standard-output* "Agreement ~4,3F ~4,3F~%" (second (first data)) (second (second data))) (format *standard-output* "Animacy ~4,3F ~4,3F~%" (third (first data)) (third (second data))) (format *standard-output* "~%~%") (when (and sim *overlay*) (format *standard-output* "~%~%Experimental Average Results:~%" ) (format *standard-output* " Percent Cue Use Standard Error~%") (format *standard-output* "Word Order ~4,3F ~4,3F~%" (first (first *exp-results-mal-sh*)) (first (second *exp-results-mal-sh*))) (format *standard-output* "Agreement ~4,3F ~4,3F~%" (second (first *exp-results-mal-sh*)) (second (second *exp-results-mal-sh*))) (format *standard-output* "Animacy ~4,3F ~4,3F~%" (third (first *exp-results-mal-sh*)) (third (second *exp-results-mal-sh*))) (format *standard-output* "~%~%") ) (unless *graphic* (format *standard-output* "~%
~%~%")))
(when *graphic*
(format *standard-output* "
"))
)
(defun create-n-stim-mal-sh (n)
(let ((stim nil))
(loop
(setf stim (append stim (create-stim-mal-sh)))
(if (> (length stim) n) (return)))
(dotimes (i (- (length stim) n))
(setf stim (cdr stim)))
stim))
(defun create-stim-mal-sh ()
(let ((stim nil))
(dolist (i *counts-mal-sh*)
(if (> (cadr i) (random 1000))
(push (car i) stim)))
stim))
; sh1: 186 282 300
; (load "work:projects:mal:model:sh.actr")
(defun run-n-mal-sh (n)
(setf *responses* nil)
(dolist (i (create-n-stim-mal-sh n))
(eval `(addwm ,(list 'goal 'isa 'choose 'stim-list i 'real (nth 3 i))))
(wmfocus goal)
(run)))
(defun avg-mal-sh (lis)
(setf lis (remove nil lis))
(/ (apply '+ lis) (length lis)))
(defun transpose-mal-sh (lis)
(let ((ans nil))
(dotimes (i (length (car lis)))
(push (mapcar #'(lambda (x) (nth i x)) lis) ans))
(reverse ans)))
(defun log-avg-mal-sh (log)
(let ((ans nil))
(dolist (i (transpose-mal-sh log))
(push (mapcar 'avg-mal-sh (transpose-mal-sh i)) ans))
(reverse ans)))
(defun doit-mal-sh (n)
(let ((tmp nil))
(setf *r-log* nil)
(setf bigbest nil)
(dotimes (i n)
(setf *responses* nil)
;(format t ".~%")
;(load "work:projects:mal:model:sh.actr")
(reset)
(sgp-fct (list :egn *egn* ))
(setf tmp nil)
(run-n-mal-sh 186)
(push (no-output (spp :r)) tmp)
(run-n-mal-sh 282)
(push (no-output (spp :r)) tmp)
(run-n-mal-sh 300)
(push (no-output (spp :r)) tmp)
(push (reverse tmp) *r-log*)
(fill-cells-mal-sh nil nil)
(cells2cues-mal-sh)
)
(setf *r-log* (reverse *r-log*))
(setf tmp nil)
(dotimes (i (length (car *r-log*)))
(push (log-avg-mal-sh (mapcar #'(lambda (x) (nth i x)) *r-log*)) tmp))
(setf tmp (reverse tmp))
#|
(dotimes (i (length (car *r-log*)))
(format t "~%")
; (format t "CHOOSE-BY-FIRST: ~a~&" (nth 0 (nth i tmp)))
(format t "CHOOSE-BY-ORDER: ~a~&" (nth 0 (nth i tmp)))
(format t "CHOOSE-BY-AGREE: ~a~&" (nth 1 (nth i tmp)))
(format t "CHOOSE-BY-ANIM: ~a~&" (nth 2 (nth i tmp)))
)
(fill-cells-mal-sh nil nil)
|#
#|
(format t "order agree anim~&")
(format t "avg: ~a~&" (mapcar #'(lambda (x) (float (/ (floor (* x 100)) 100)))
(list (avg-mal-sh (mapcar 'first bigbest))
(avg-mal-sh (mapcar 'second bigbest))
(avg-mal-sh (mapcar 'third bigbest)))))
(format t "se: ~a~&" (mapcar #'(lambda (x) (float (/ (floor (* x 1000)) 1000)))
(list (se-mal-sh (mapcar 'first bigbest))
(se-mal-sh (mapcar 'second bigbest))
(se-mal-sh (mapcar 'third bigbest)))))
|#
(output-data-mal-sh (list (mapcar #'(lambda (x) (float (/ (floor (* x 100)) 100)))
(list (avg-mal-sh (mapcar 'first bigbest))
(avg-mal-sh (mapcar 'second bigbest))
(avg-mal-sh (mapcar 'third bigbest))))
(mapcar #'(lambda (x) (float (/ (floor (* x 1000)) 1000)))
(list (se-mal-sh (mapcar 'first bigbest))
(se-mal-sh (mapcar 'second bigbest))
(se-mal-sh (mapcar 'third bigbest))))) t)
))
(defun sd-mal-sh (lis)
(let ((m (/ (apply '+ lis) (length lis))))
(sqrt (/ (apply '+ (mapcar #'(lambda (x) (expt (- x m) 2)) lis))
(1- (length lis))))))
;standard error
(defun se-mal-sh (lis)
(/ (sd-mal-sh lis) (sqrt (length lis))))
(defun cue2choice-mal-sh (x)
(cond ((equal x 'nnv) 0)
((equal x 'nvn) 2)
((equal x 'vnn) 1)
((equal x 'ag0) 0)
((equal x 'ag1+) 1)
((equal x 'ag1*) 1)
((equal x 'ag1-) 1)
((equal x 'ag2+) 2)
((equal x 'ag2*) 2)
((equal x 'ag2-) 2)
((equal x 'ai) 1)
((equal x 'ia) 2)
((equal x 'ii) 0)
((equal x 'aa) 0)
(t
(print x)
(break))))
; over conf med
;(order-vote agree-vote anim-vote choice corr sess subj) ans
(defun fill-cells-mal-sh (sess subj)
(setf *cells* (copy-tree (make-list 9)))
(dolist (i *responses*)
; (if (equal (nth 7 i) 2)
(if (or (null sess)
(equal (nth 5 i) sess))
(if (or (null subj)
(equal (nth 6 i) subj))
(cond ((zerop (nth 1 i)) ;agreement=conflict
(if (zerop (nth 2 i)) ;animacy=medium
(push (nth 4 i) (nth 0 *cells*))
(if (equal (nth 2 i) (nth 0 i))
(push (nth 4 i) (nth 1 *cells*))
(push (nth 4 i) (nth 2 *cells*)))))
((equal (nth 1 i) (nth 0 i))
(if (zerop (nth 2 i)) ;animacy=medium
(push (nth 4 i) (nth 3 *cells*))
(if (equal (nth 2 i) (nth 0 i))
(push (nth 4 i) (nth 4 *cells*))
(push (nth 4 i) (nth 5 *cells*)))))
(t
(if (zerop (nth 2 i)) ;animacy=medium
(push (nth 4 i) (nth 6 *cells*))
(if (equal (nth 2 i) (nth 0 i))
(push (nth 4 i) (nth 7 *cells*))
(push (nth 4 i) (nth 8 *cells*))))))))
;)
)
#|
(dotimes (i 3)
(format t "~1,2f~c" (/ (count 0 (nth i *cells*)) (length (nth i *cells*))) #\tab))
(format t "~&")
(dotimes (i 3)
(format t "~1,2f~c" (/ (count 0 (nth (+ 3 i) *cells*)) (length (nth (+ 3 i) *cells*))) #\tab))
(format t "~&")
(dotimes (i 3)
(format t "~1,2f~c" (/ (count 0 (nth (+ 6 i) *cells*)) (length (nth (+ 6 i) *cells*))) #\tab))
(format t "~&")
|#
)
(compile (defun cells2cues-mal-sh ()
(let ((order .33)
(agree .33)
(anim .33)
(cue-err nil)
(subj-err (mapcar #'(lambda (x) (- 1 (avg-mal-sh x))) *cells*))
(diff nil)
; (cue nil)
(best 100)
(bestlis nil)
)
(setf best 100)
(dotimes (i 10000)
(setf order (random 1.0))
(setf agree (random (- 1 order)))
(setf anim (- 1 order agree))
(setf cue-err (list 0 0 (/ order (+ order anim))
0 0 (/ anim (+ order agree anim))
(/ order (+ order agree))
(/ (+ order anim) (+ order agree anim))
(/ order (+ order agree anim))))
(setf diff (apply '+ (mapcar #'(lambda (x y) (expt (- x y) 2)) cue-err subj-err)))
(when (< diff best)
(setf best diff)
(setf bestlis (list order agree anim))))
(push bestlis bigbest)
;(format t "~a~&" best)
;(format t "order agree anim~&")
;(format t "~a~&" (mapcar #'(lambda (x) (float (/ (floor (* x 100)) 100))) bestlis))
)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; This section contains the ACT-R model
;;;
;;;
(clearall)
(chunk-type choose stim-list real decision)
(sgp-fct (list :era t :ct nil :v nil :ot nil :egn *egn* :pl t))
;Panim Porder Pagree
;0.117 0.075 0
; .60 .40 0
; .80 .70 .50
(p choose-by-order
=goal>
isa choose
stim-list =list
decision nil
!eval! (intersection '(vnn nvn) =list)
==>
=goal>
decision (!eval! (if (member 'vnn =list) 1
(if (member 'nvn =list) 2)))
)
;(parameters choose-by-order :r-alpha 35 :r-beta 15)
;(parameters choose-by-order :r-alpha 7 :r-beta 3)
(parameters choose-by-order :r-alpha 1 :r-beta 1)
(p choose-by-agreement
=goal>
isa choose
stim-list =list
decision nil
!eval! (intersection '(ag1- ag1+ ag1* ag2- ag2+ ag2*) =list)
==>
=goal>
decision (!eval! (if (intersection '(ag1- ag1+ ag1*) =list) 1 2))
)
;(parameters choose-by-agreement :r-alpha 30 :r-beta 20)
;(parameters choose-by-agreement :r-alpha 6 :r-beta 4)
(parameters choose-by-agreement :r-alpha 1 :r-beta 1)
(p choose-by-animacy
=goal>
isa choose
stim-list =list
decision nil
!eval! (intersection '(ai ia) =list)
==>
=goal>
decision (!eval! (if (member 'ai =list) 1 2))
)
;(parameters choose-by-animacy :r-alpha 40 :r-beta 10)
;(parameters choose-by-animacy :r-alpha 8 :r-beta 2)
(parameters choose-by-animacy :r-alpha 1 :r-beta 1)
(p right-choice
=goal>
isa choose
stim-list =list
decision =n
real =n
==>
!eval! (push (list (cue2choice-mal-sh (first =list))
(cue2choice-mal-sh (second =list))
(cue2choice-mal-sh (third =list))
=n
1) *responses*)
!pop!
)
(parameters right-choice :success t)
(p wrong-choice
=goal>
isa choose
stim-list =list
decision =n
real =r
!eval! (not (equal =n =r))
==>
!eval! (push (list (cue2choice-mal-sh (first =list))
(cue2choice-mal-sh (second =list))
(cue2choice-mal-sh (third =list))
=n
0) *responses*)
!pop!
)
(parameters wrong-choice :failure t)