;;;;;;;;;;;;;;;;;;;;
If your browser supports JAVA, you can display the data in a graph by checking the Graphic output box on the interface page.;;; ;;; ACT-R model of the Building Sticks Task ;;; ;;; This model works with ACT-R version 4.0 (2/6/97 or newer) ;;; ;;; inteface coded by: Dan Bothell ;;; ;;; This file contains an ACT-R model that ;;; can perform the Building Sticks Task (BST). ;;; The BST is a problem solving task ;;; isomorphic to the water jug task. ;;; In the BST the subject is presented ;;; (on a computer screen) with four ;;; sticks of different lengths. One stick ;;; is a goal stick, and the other three are ;;; the building sticks. The objective is to ;;; create a stick of the same length as ;;; the goal using the other three, by either ;;; adding, or subtracting lengths. ;;; ;;; There are two methods for solving BST ;;; problems, either overshoot - starting with ;;; a stick larger than the goal and subtracting down, ;;; or undershoot - starting with a stick smaller ;;; than the goal and building up. This model ;;; demonstrates the change in frequency in the ;;; method used over the course of 15 trials. ;;; ;;; The model is designed to solve one instance ;;; of the BST, and the LISP functions provided ;;; allow simulation of one 15 trial experiment, ;;; and multiple runs through the experiment ;;; (reseting between runs). ;;; ;;; For more information about the experiment and ;;; the theory see: ;;; ;;; http://act.psy.cmu.edu/ACT/abstracts/Lovett_Anderson95b-abs.html ;;; http://act.psy.cmu.edu/ACT/abstracts/Lovett_Anderson95-abs.html ;;; ;;; A simple function call and a WWW interface ;;; are included. ;;; ;;; To run the model through the experiment, call ;;; (do-bst n). That will report the number of ;;; times the overshoot method was chosen first ;;; to solve each of the problems, for the n ;;; runs through the experiment. The parameters ;;; to use can be set with setf. ;;; ;;; ;;; To use the WWW interface, you need to run ;;; the ACT-R on the Web application (follow the ;;; instructions provided with it), or use a ;;; web browser to connect to a site that has ;;; the model installed. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Global variables ;;; ACT-R parameters set by the interfaces (defvar *r-alpha-choose*) (defvar *r-beta-choose*) (defvar *r-alpha-force*) (defvar *r-beta-force*) (defvar *egn*) (defvar *v*) (defvar *s-per*) ;; s parameter for the noise in ;; determination of stick length (defvar *runs*) (defvar *text*) (defvar *graphic*) (defvar *overlay*) ;;; variables used for the interface, and ;;; for parameter optimization (defvar *dialog*) (defvar *number-of-tries*) ;;; the stimuli used in the experiment ;;; represented as (stick-a stick-b stick-c goal-stick) (defparameter *bst-stimuli* '((15 250 55 125)(10 155 22 101) (14 200 37 112)(22 200 32 114) (10 243 37 159)(22 175 40 73) (15 250 49 137)(10 179 32 105) (20 213 42 104)(14 237 51 116) (12 149 30 72) (14 237 51 121)(22 200 32 114) (14 200 37 112)(15 250 55 125))) ;;; the strategy chosen by the model to use first ;;; on a given trial (set by the model) ;;; 0 for undershoot, 1 for overshoot (defvar *strategy* nil) ;;; data from the experiment (defparameter *bst-exper-data* #(20.0 67.0 20.0 47.0 87.0 20.0 80.0 93.0 83.0 13.0 29.0 27.0 80.0 73.0 53.0)) (defparameter *bst-about* "This file contains an ACT-R model that can perform the Building Sticks Task (BST). The BST is a problem solving task isomorphic to the water jug task. In the BST the subject is presented (on a computer screen) with four sticks of different lengths. One stick is a goal stick, and the other three are the building sticks. The objective is to create a stick of the same length as the goal using the other three, by either adding, or subtracting lengths. There are two methods for solving BST problems, either overshoot - starting with a stick larger than the goal and subtracting down, or undershoot - starting with a stick smaller than the goal and building up. This model demonstrates the change in frequency in the method used over the course of 15 trials. Each run of the model simulates one 15 trial experiment. The model is reset before each run for multiple runs. For abstracts of papers on the experiment and the theory see: Abstract 1 Abstract 2 ") (setf *r-alpha-choose* 14.61) (setf *r-beta-choose* .5) (setf *r-alpha-force* .5) (setf *r-beta-force* .5) (setf *egn* 1.3) (setf *v* nil) (setf *s-per* 18.2) ;; s parameter for the noise in ;; determination of stick length (setf *runs* 10) (setf *text* t) (setf *graphic* nil) (setf *overlay* nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; 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 "Building-Sticks Task" 2) (:table) (:table) "Perceptual Noise (s): " (:string :sy *s-per* 18.2) (:new-row) "R-alpha choose: " (:string :sy *r-alpha-choose* 14.61) (:new-row) "R-beta choose: " (:string :sy *r-beta-choose* .5) (:new-row) "R-alpha force: " (:string :sy *r-alpha-force* .5) (:new-row) "R-beta force: " (:string :sy *r-beta-force* .5) (:new-row) "Evaluation Standard Deviation: " (:string :sy *egn* 1.3) (:new-row) "Number of runs (1-250): " (:string :sy *runs* 10) (:table-end) (:table) (:checkbox "Trace" :sy *v* nil) (:new-row) (: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" "(display-bst-results *bst-exper-data* nil 1)") (:new-para) (:button "Run model" "(if (and (numberp *s-per*) (numberp *r-alpha-choose*) (numberp *r-beta-choose*) (numberp *r-alpha-force*) (numberp *r-beta-force*) (numberp *egn*) (numberp *runs*)) (do-bst (min 250 (max 1 *runs*))) (format *standard-output* \"All 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)") (:button "About Model" "(format *standard-output* \"~%~A~%\" *bst-about*)") (:new-para) "TIME and SIZE:" (:new-para) "- It usually takes less than 1 minute for 10 runs of the model" (:new-line) "- The trace of 10 runs is approximatly 300k (200 pages) in size" (:new-para))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Functions to run the simulation ;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; bst-noise-per takes one parameter q, the length of a stick ;;; and returns a value representing the lenght of the stick ;;; with the addition of noise, where the noise is a ;;; normal distribution with s defined by *s-per* (defun bst-noise-per (q) (let* ((p (random 1.0)) (r (- 1.0 p))) (if (or (zerop p) (zerop r)) (bst-noise-per q) (+ q (* *s-per* (log (/ p r))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; set-bst-params sets the parameters for the ;;; ACT-R model based on the values of the ;;; global variables (defun set-bst-params () (sgp-fct (list :pl t :era t :cst t :ct t :g 20.0 :dat 0.0 :egn *egn* :v *v*)) (parameters-fct 'decide-over (list :r-alpha *r-alpha-choose* :r-beta *r-beta-choose* :b-b 0.0)) (parameters-fct 'decide-under (list :r-alpha *r-alpha-choose* :r-beta *r-beta-choose* :b-b 0.0)) (parameters-fct 'force-over (list :r-alpha *r-alpha-force* :r-beta *r-beta-force* :b-b 0.0)) (parameters-fct 'force-under (list :r-alpha *r-alpha-force* :r-beta *r-beta-force* :b-b 0.0))) ;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; do-bst takes one parameter n, and ;;; then runs n ACT-R simulations of the ;;; BST experiment (15 trials each run) ;;; and reports the number of times the ;;; overshoot strategy was used for each ;;; stimuli. (defun do-bst (n) (setf *strategy* nil) (let ((data (make-array '(15) :initial-element 0))) (dotimes (count n) (reset) (set-bst-params) (do* ((temp *bst-stimuli* (cdr temp)) (i 0 (1+ i)) (bst-trial (car temp) (car temp))) ((null temp) nil) (do-bst-trial (first bst-trial) (second bst-trial) (third bst-trial) (fourth bst-trial)) (when *strategy* (incf (aref data i) *strategy*)) (setf *strategy* nil))) (dotimes (i 15) (setf (aref data i) (* 100 (/ (aref data i) n)))) (display-bst-results data t n))) (defun display-bst-results (data simulation runs) (when simulation (format *standard-output* "~%~%Parameters for run: (~S ~S ~S ~S ~S ~S ~S)~%" *s-per* *r-alpha-choose* *r-beta-choose* *r-alpha-force* *r-beta-force* *egn* runs)) (when *text* (format *standard-output* "~%~%~a percentage overshoot strategy used:~%" (if simulation "Simulation" "Experimental")) (format *standard-output* "~%Trial Percent overshoot~%") (dotimes (i 15) (format *standard-output* "~3s~13,1f~%" i (aref data i))) (format *standard-output* "~%") (when (and simulation *overlay*) (format *standard-output* "~%~%Experimental percentage overshoot strategy used:~%" ) (format *standard-output* "~%Trial Percent overshoot~%") (dotimes (i 15) (format *standard-output* "~3s~13,1f~%" i (aref *bst-exper-data* i))) (format *standard-output* "~%")) (unless *graphic* (format *standard-output* "~%
~%~%")))
(when *graphic*
(format *standard-output* "
")))
;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; do-bst-trial takes 4 parameters a,b,c, and g
;;; it sets the goal of the model to solve a
;;; BST problem with sticks of length a, b, and c
;;; and a goal length of g, and runs the model
(defun do-bst-trial (a b c g)
(modwme-fct 'goal (list 'a a 'b b 'c c 'goal g 'current 0 'over nil 'under nil))
(goal-focus goal)
(run))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; The ACT-R model
(clearall)
; default parameters
(sgp :era t :egn 1.3 :pl t :v nil :g 20.0 :dat 0.0 :cst t )
(chunk-type waterjug
"
a chunk type to specify a goal to
solve a waterjug type problem (the bst)
slots:
a,b,c,goal - lengths of the sticks
current - length of the stick being constructed
over - holds the estimated length difference between
the longest stick and the goal or
t once the overshoot strategy has been tried
under - holds the estimated length difference between
the longest stick shorter than the goal and the goal or
t once the overshoot strategy has been tried
"
a b c goal current over under)
(chunk-type try-strategy
"
a chunk type to specify a goal of
trying a particular strategy in solving a
bst task
slots:
strategy - contains the strategy being used (OVER or UNDER)
current - length of the stick being constructed
over - holds the estimated length difference between
the longest stick and the goal or
t once the overshoot strategy has been tried
under - holds the estimated length difference between
the longest stick shorter than the goal and the goal or
t once the overshoot strategy has been tried
"
strategy a b c goal current over under)
(set-dm (goal isa waterjug a 15 b 250 c 55 goal 125 current 0))
(goal-focus goal)
(p ENCODE
"
IF the goal is to solve a waterjug problem and the distances to the
goal have not been determined
THEN estimate the distances to the goal
and push a subgoal to try a strategy for the current problem
configuration
"
=GOAL>
isa WATERJUG
a =A
b =B
c =C
goal =G
under nil
over nil
==>
=NEWGOAL>
isa TRY-STRATEGY
strategy nil
a =A
b =B
c =C
goal =G
current 0
under (!eval! (bst-noise-per (- =g =c)))
over (!eval! (bst-noise-per (- =b =g)))
current =NEWCURRENT
over =NEWOVER
under =NEWUNDER
=GOAL>
current =NEWCURRENT
over =NEWOVER
under =NEWUNDER
!push! =NEWGOAL)
(parameters encode :r-alpha 900 :r-beta 100 :b-b 0.0)
(p FORCE-OVER
"
IF the goal is to try a strategy
and no strategy has been chosen
and the over shoot strategy has not been chosen before
THEN mark the current strategy as over shoot in the goal
"
=GOAL>
isa TRY-STRATEGY
strategy nil
a =A1
b =B1
c =C1
goal =G1
current 0
- over t
==>
!eval! (when (null *strategy*) (setf *strategy* 1))
=GOAL>
strategy OVER
over t
current nil
!output! ("~%force over~%"))
(parameters force-over :r-alpha 0.5 :r-beta 0.5 :b-b 0.0)
(p FORCE-UNDER
"
IF the goal is to try a strategy
and no strategy has been chosen
and the under shoot strategy has not been chosen before
THEN mark the current strategy as under shoot in the goal
"
=GOAL>
isa TRY-STRATEGY
a =A1
b =B1
c =C1
goal =G1
current 0
- under t
==>
!eval! (when (null *strategy*) (setf *strategy* 0))
=GOAL>
strategy UNDER
current nil
under t
!output! ("~%force under~%"))
(parameters force-under :r-alpha 0.5 :r-beta 0.5 :b-b 0.0)
(p DECIDE-UNDER
"
IF the goal is to try a strategy
and no strategy has been chosen before
and the under shoot strategy gets closer to the goal
THEN mark the current strategy as under shoot in the goal
"
=GOAL>
isa TRY-STRATEGY
a =A1
b =B1
c =C1
goal =G1
current 0
- under t
- over t
over =O
under =U
!eval! (>= =O =U)
==>
!eval! (when (null *strategy*) (setf *strategy* 0))
=GOAL>
strategy UNDER
current nil
under t
!output! ("~%decide under~%"))
(parameters decide-under :r-alpha 14.61 :r-beta 0.5 :b-b 0.0)
(p DECIDE-OVER
"
IF the goal is to try a strategy
and no strategy has been chosen before
and the over shoot strategy gets closer to the goal
THEN mark the current strategy as over shoot in the goal
"
=GOAL>
isa TRY-STRATEGY
a =A1
b =B1
c =C1
goal =G1
current 0
- over t
- under t
under =U
over =O
!eval! (>= =U =O)
==>
!eval! (when (null *strategy*) (setf *strategy* 1))
=GOAL>
strategy OVER
current nil
over t
!output! ("~%decide over~%"))
(parameters decide-over :r-alpha 14.61 :r-beta 0.5 :b-b 0.0)
(p encode-OVER
"
IF the goal is to try a strategy
and the current strategy is over shoot
THEN mark the starting stick length as the longest stick
"
=GOAL>
isa TRY-STRATEGY
strategy OVER
current nil
b =B
==>
=GOAL>
current =B)
(parameters encode-over :b-b 0.0)
(p encode-UNDER
"
IF the goal is to try a strategy
and the current strategy is under shoot
THEN mark the starting stick length as the longest stick
shorter than the goal
"
=GOAL>
isa TRY-STRATEGY
strategy UNDER
current nil
c =C
==>
=GOAL>
current =C)
(parameters encode-under :b-b 0.0)
(p SUBTRACT-A
"
IF the goal is to try a strategy
and the strategy is over shoot
and the current stick length is greater than the goal
and stick c takes away too much
THEN subtract stick a from the current stick
"
=GOAL>
isa TRY-STRATEGY
strategy OVER
current =CUR
- current nil
goal =G
a =A
c =C
!eval! (> =C (- =CUR =G))
!eval! (< =G =CUR)
==>
=GOAL>
current (!eval! (- =CUR =A)))
(parameters subtract-a :b-b 0.0)
(p SUBTRACT-C
"
IF the goal is to try a strategy
and the strategy is over shoot
and the current stick length is greater than the goal
and stick c is less than or equal to the difference
THEN subtract stick c from the current stick
"
=GOAL>
isa TRY-STRATEGY
strategy OVER
current =CUR
- current nil
goal =G
c =C
!eval! (<= =C (- =CUR =G))
!eval! (< =G =CUR)
==>
=GOAL>
current (!eval! (- =CUR =C)))
(parameters subtract-c :b-b 0.0)
(p ADD-A
"
IF the goal is to try a strategy
and the strategy is under shoot
and the current stick length is less than the goal
and stick c adds too much
THEN add stick a to the current stick
"
=GOAL>
isa TRY-STRATEGY
strategy UNDER
current =CUR
- current nil
goal =G
a =A
c =C
!eval! (> =C (- =G =CUR))
!eval! (> =G =CUR)
==>
=GOAL>
current (!eval! (+ =CUR =A)))
(parameters add-a :b-b 0.0)
(p ADD-C
"
IF the goal is to try a strategy
and the strategy is under shoot
and the current stick length is less than the goal
and stick c is less than or equal to the difference
THEN add stick c to the current stick
"
=GOAL>
isa TRY-STRATEGY
strategy UNDER
current =CUR
- current nil
goal =G
c =C
!eval! (<= =C (- =G =CUR))
!eval! (> =G =CUR)
==>
=GOAL>
current (!eval! (+ =CUR =C)))
(parameters add-c :b-b 0.0)
(p FAIL-UNDER
"
IF the goal is to try a strategy
and the strategy is under shoot
and the current stick is larger than the goal
THEN mark the current length as nil to signify failure
and pop the current goal
"
=GOAL>
isa TRY-STRATEGY
strategy UNDER
current =CUR
- current nil
goal =G
!eval! (< =G =CUR)
==>
=GOAL>
current nil
!pop!)
(parameters fail-under :b-b 0.0 :failure t)
(p FAIL-OVER
"
IF the goal is to try a strategy
and the strategy is over shoot
and the current stick is shorter than the goal
THEN mark the current length as nil to signify failure
and pop the current goal
"
=GOAL>
isa TRY-STRATEGY
strategy OVER
current =CUR
- current nil
goal =G
!eval! (> =G =CUR)
==>
=GOAL>
current nil
!pop!)
(parameters fail-over :b-b 0.0 :failure t)
(p SUCCEED
"
IF the goal is to try a strategy
and the current stick is the same length as the goal
THEN pop the current goal to signify the end of
this strategy
"
=GOAL>
isa TRY-STRATEGY
current =CUR
strategy =S
- current nil
goal =G
!eval! (equal =G =CUR)
==>
!pop!)
(parameters succeed :b-b 0.0 :success t)
(p TRY-AGAIN
"
IF the current goal is to solve a waterjug problem
and there is no current length
and the distances to the goal have been measured
THEN create and push a subgoal to try a strategy
using the current set of sticks, and goal
distance calculations
"
=GOAL>
isa WATERJUG
a =A
b =B
c =C
goal =G
under =U
over =O
current nil
==>
=NEWGOAL>
isa TRY-STRATEGY
strategy nil
a =A
b =B
c =C
goal =G
current 0
under =U
over =O
current =NEWCURRENT
=GOAL>
current =NEWCURRENT
!push! =NEWGOAL)
(parameters try-again :failure t :r-alpha 100 :r-beta 0 :b-b 0.0)
(p SUCCEED-WATERJUG
"
IF the goal is to solve a waterjug problem
and the current stick is the same length as the goal stick
THEN pop the goal to signify the end of this problem
"
=GOAL>
isa WATERJUG
current =CUR
goal =CUR
==>
!pop!)
(parameters succeed-waterjug :r-alpha 100 :r-beta 0 :b-b 0.0)
(p FAIL-WATERJUG
"
IF the goal is to solve a waterjug problem
and the current stick is not the same length as the goal stick
and both under shoot and over shoot have been tried
THEN pop the goal to signify the end of this problem
"
=GOAL>
isa WATERJUG
current =CUR
- current nil
- goal =CUR
over t
under t
==>
!pop!)
(parameters fail-waterjug :b-b 0.0)
(spp :chance 1.0)