Commit 6b255044 authored by CD's avatar CD
Browse files

Some trys at updating for ACT-R7, problem with find-last-event-time

parent cdf0cc86
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Error during dialog loading of C:/Users/SightH/ACT-R_Phi/environment/GUI/dialogs/25-event-queue.tcl: window name "event_queue_button" already exists in parent
Error during dialog loading of C:/Users/Phys-Cog/ACT-R_Phi/environment/GUI/dialogs/25-event-queue.tcl: window name "event_queue_button" already exists in parent
communication error result:
\ No newline at end of file
# Port settings for ACT-R server started at 21:18:46 6/18/2019
set actr_port 2650
set actr_address "192.168.1.78"
# Port settings for ACT-R server started at 14:43:05 8/02/2019
set actr_port 2652
set actr_address "130.203.161.104"
......@@ -4,7 +4,7 @@
wm deiconify .
update
wm withdraw .
if {[winfo screenwidth .] != 3440 || [winfo screenheight .] != 1440 || [lindex [wm maxsize .] 0] != 3444 || [lindex [wm maxsize .] 1] != 1421} {
if {[winfo screenwidth .] != 1920 || [winfo screenheight .] != 1080 || [lindex [wm maxsize .] 0] != 1924 || [lindex [wm maxsize .] 1] != 1055} {
set size_mismatch 1
} else {
set size_mismatch 0
......@@ -15,14 +15,12 @@ if $size_mismatch {
-message "The screen resolution is not the same as it was the last time the Environment was used. Should the window positions reset to the defaults?"]
} else { set reset_window_sizes 0}
if {$reset_window_sizes != "yes"} {
set window_config(.audicon) 870x150+525+440
set changed_window_list(.audicon) 1
set window_config(.visicon) 1920x1001+610+440
set changed_window_list(.visicon) 1
set window_config(.control_panel) 235x700+1665+190
set changed_window_list(.control_panel) 1
set window_config(.buffers) 350x240+785+420
set changed_window_list(.buffers) 1
set window_config(.options) 450x274+735+403
set changed_window_list(.options) 1
set window_config(.copyright) 400x290+760+395
set changed_window_list(.copyright) 1
}
set gui_options(p_selected) #44DA22
set gui_options(p_matched) #FCA31D
......
# this file generated from saving the options
set options_array(show_copyrights) 1
set options_array(use_env_window) true
set options_array(use_smart_load) false
set options_array(show_copyrights) 0
set options_array(kill_model_windows) 1
set options_array(save_backups) 1
set options_array(use_smart_load) false
set options_array(save_before_reload) 1
set options_array(save_backups) 1
......@@ -2635,7 +2635,6 @@ Goes to 'active' listener:
(add-act-r-command "act-r-version" 'act-r-version-string "Returns the current ACT-R version string. No params." nil)
;;; Actually echo the output by default now if it's not the standalone.
#-:standalone (echo-act-r-output)
......
require(ggplot2)
require(reshape2)
get_arousal_noise = function(id)
{
theme_update(plot.title = element_text(hjust = 0.5))
ArousalANS.mat = read.csv(paste0("C:/Users/Phys-Cog/ACT-R_Phi/arous-ans-log", id, ".txt"), header=FALSE)
CECArousal.mat = read.csv(paste0("C:/Users/Phys-Cog/ACT-R_Phi/CEC-Arous", id, ".txt"))
CECArousal.mat = cbind(matrix(1:1798, 1798, 1), CECArousal.mat)
CECArousalANS.mat = CECArousal.mat
colnames(CECArousalANS.mat)[1] = "Time"
CECArousalANS.mat = cbind(CECArousalANS.mat, ArousalANS.mat[1:1798,3])
colnames(CECArousalANS.mat)[6] = "Noise"
CECArousalANSLong.mat = melt(CECArousalANS.mat, id="Time")
CECArousalANSLong.plot = ggplot(as.data.frame(CECArousalANSLong.mat))
fac_names = c(
`f.Cortisol.` = "f(cortisol)",
`g.Epinephrine.` = "g(epinephrine)",
`h.CRH.` = "h(crh)",
`Arousal` = "arousal",
`Noise` = "noise"
)
CECArousalANSLong.plot + geom_line(aes(x=Time, y=value, color=variable), size=0.5) +
labs(y="Normalized Effect (1 is a \"normal\" level)", x="Time (s)", title="Effects of stress physiology on arousal") +
facet_grid(variable~., scales = "free_y", labeller = as_labeller(fac_names))
}
\ No newline at end of file
(clear-all)
(defun run-test-model (run-time)
;;Schedule event to change physiology
;(schedule-event 0.022 'set-phys-vals :module 'physio :params (list (list (list "IVDrip.Switch" 1) (list "IVDrip.H2OSetting" 25) (list "IVDrip.ClinicalSaline" 860))) :priority :max :details "Start hypertonic saline IV")
(schedule-periodic-event 1 'test-record-arousal
:initial-delay 2 :module :physio :output nil)
(sgp :phys-ics-exp-file "ICS/Racinais-2008_Hot.ICS")
(run run-time))
(defun run-graded-stress1 (&optional (length 20) (perc-inc 100) (num-steps 20))
"Runs stress in a graded manner w/ instant CRF stress reaction
(i.e., slowly increases, the decreases, activation of physiological systems)
Inputs:
length - time to run incerase and decrease in minutes (int)
perc-inc - percent of maximum to increase (double 0-100)
num-steps - number of steps to increase from base to percentage of max"
(let* ((num-steps-side (ceiling (/ num-steps 2)))
(perc-per (/ (/ perc-inc num-steps-side) 100))
(time-per (/ length num-steps))
(END-SYMP-ACT 1))
(sgp :AA-max-arous 3)
(schedule-periodic-event 1 'test-record-arousal
:module :physio :output nil :initial-delay 2)
;Affect epinephrine/adrenaline & CRF
(schedule-event-relative 0.020 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-Adrenal.ClampLevel" 2)
(list "Sympathetics-Adrenal.ClampSwitch" 1)
(list "CorticotropinReleasingFactor.Stress" 4)))
:priority :max :details "Graded stress increase adrenal & CRF")
(dotimes (i num-steps-side)
(let* ((step (+ i 1))
(symp-act (* perc-per step END-SYMP-ACT)))
;General sympathetic arousal
(schedule-event-relative 0.021 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-General.EssentialEffect" symp-act)))
:priority :max :details "Graded stress increase Symp Essential")
(run (* time-per 60))))
;;Now move stress back towards normal (adrenaline & CRF)
(schedule-event-relative 0.020 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-Adrenal.ClampSwitch" 0)
(list "CorticotropinReleasingFactor.Stress" 2)))
:priority :max :details "Graded stress reduction adrenal & CRF")
(dotimes (i num-steps-side)
(let* ((step (+ i 1))
(symp-act (* perc-per step END-SYMP-ACT)))
(if (> symp-act END-SYMP-ACT) (setf symp-act END-SYMP-ACT))
(format t "Sleep ~a ~a ~a~%" perc-per step symp-act)
;General sympathetic arousal
(schedule-event-relative 0.021 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-General.EssentialEffect" (- END-SYMP-ACT symp-act))))
:priority :max :details "Graded stress reduction symp essential")
(run (* time-per 60))))))
(defun run-graded-stress2 (&optional (length 20) (perc-inc 100) (num-steps 20))
"Runs stress in a graded manner w/ graded CRF stress reaction
(i.e., slowly increases, the decreases, activation of physiological systems)
Inputs:
length - time to run incerase and decrease in minutes (int)
perc-inc - percent of maximum to increase (double 0-100)
num-steps - number of steps to increase from base to percentage of max"
(let* ((num-steps-side (ceiling (/ num-steps 2)))
(perc-per (/ (/ perc-inc num-steps-side) 100))
(time-per (/ length num-steps))
(END-SYMP-ACT 1)
(crh2 nil)
(crh4 nil))
(schedule-periodic-event 1 'test-record-arousal
:module :physio :output nil :initial-delay 2)
;Affect epinephrine/adrenaline
(schedule-event-relative 0.020 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-Adrenal.ClampLevel" 2)
(list "Sympathetics-Adrenal.ClampSwitch" 1)))
:priority :max :details "Graded stress")
(dotimes (i num-steps-side)
(let* ((step (+ i 1))
(symp-act (* perc-per step END-SYMP-ACT)))
;General sympathetic arousal
(schedule-event-relative 0.021 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-General.EssentialEffect" symp-act)))
:priority :max :details "Graded stress")
;Increase CRH-based stress
(if (and (not crh2) (> (* step time-per) (* length 0.375)))
(progn
(setf crh2 t)
(schedule-event-relative 0.022 'set-phys-vals :module 'physio
:params (list (list (list "CorticotropinReleasingFactor.Stress" 4)))
:priority :max :details "Graded stress"))
(if (and (not crh4) (> (* step time-per) (* length 0.125)))
(progn
(setf crh4 t)
(schedule-event-relative 0.022 'set-phys-vals :module 'physio
:params (list (list (list "CorticotropinReleasingFactor.Stress" 3)))
:priority :max :details "Graded stress"))))
(run (* time-per 60))))
;;Now move stress back towards normal
(schedule-event-relative 0.020 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-Adrenal.ClampSwitch" 0)))
:priority :max :details "Graded stress reduction Adrenal")
(setf crh2 nil)
(setf crh4 nil)
(dotimes (i num-steps-side)
(let* ((step (+ i 1))
(symp-act (* perc-per step END-SYMP-ACT)))
(if (> symp-act END-SYMP-ACT) (setf symp-act END-SYMP-ACT))
;General sympathetic arousal
(schedule-event-relative 0.021 'set-phys-vals :module 'physio
:params (list (list (list "Sympathetics-General.EssentialEffect" (- END-SYMP-ACT symp-act))))
:priority :max :details "Graded stress reduction Symp Essential")
;Increase CRH-based stress
(if (and (not crh2) (> (* step time-per) (* length 0.375)))
(progn
(setf crh2 t)
(schedule-event-relative 0.022 'set-phys-vals :module 'physio
:params (list (list (list "CorticotropinReleasingFactor.Stress" 2)))
:priority :max :details "Graded stress reduction CRF"))
(if (and (not crh4) (> (* step time-per) (* length 0.125)))
(progn
(setf crh4 t)
(schedule-event-relative 0.022 'set-phys-vals :module 'physio
:params (list (list (list "CorticotropinReleasingFactor.Stress" 3)))
:priority :max :details "Graded stress reduction"))))
(run (* time-per 60))))))
(defun test-record-arousal ()
(let* ((aa (get-module Affective-Associations))
(arous-dm-noise (compute-arousal-factor (AA-pred-error-factor aa) t))
(arous-mid (/ (AA-max-arous aa) 2))
(noise-val 0))
(when (= arous-dm-noise 0) (incf arous-dm-noise 0.000001))
(if (<= arous-dm-noise arous-mid)
(setf noise-val (/ (+ (* arous-dm-noise (AA-nom-dm-noise aa)) (* (- arous-mid arous-dm-noise) (AA-max-dm-noise aa))) arous-mid))
(setf noise-val (/ (+ (* (- (AA-max-arous aa) arous-dm-noise) (AA-nom-dm-noise aa)) (* (- arous-dm-noise arous-mid) (AA-max-dm-noise aa))) arous-mid)))
(with-open-file
(n-stream (concatenate 'string "arous-ans-log" *START-TIME* ".txt") :direction :output :if-exists :append :if-does-not-exist :create)
(format n-stream "~0$,~5$,~5$~&" (mp-time) arous-dm-noise noise-val))))
(define-model ACT-Phi2_Test1
(sgp :esc t :lf .05 :trace-detail high)
(sgp :phys-delay 2 :phys-enabled t);:recorded-phys ("OsmBody.[Osm(mOsm/L)]-CellWall"))
(sgp :AA-enabled t)
(sgp :AA-dm-noise-switch t)
(sgp :AA-util-noise-switch nil)
;(sgp :AA-chunk-arousal-switch nil)
(sgp :AA-max-dm-noise 1)
(chunk-type chunk1 myslot1)
(chunk-type chunk2 myslot2)
(chunk-type goal-chunk goal-slot)
(add-dm (blah1 isa chunk1 myslot1 2) (blah2 isa chunk2 myslot2 1) (goal1 isa goal-chunk goal-slot 1) (goal2 isa goal-chunk goal-slot 2))
(p rule1
=goal>
isa goal-chunk
goal-slot =num
?imaginal>
state free
==>
=goal>
goal-slot 2
+imaginal>
isa chunk1
myslot1 =num)
(p rule2
=goal>
isa goal-chunk
goal-slot 2
=imaginal>
isa chunk1
==>
=goal>
goal-slot 1)
(goal-focus goal1))
This diff is collapsed.
This diff is collapsed.
......@@ -644,18 +644,23 @@ t)
;;;find the time (in seconds) of the last event within the specified modules
(defun find-last-event-time (moduleList)
(verify-current-mp
"mp-show-queue called with no current meta-process."
(let ((events (meta-p-events (current-mp)))
(lastTime nil))
(dolist (event events (length events))
(dolist (mod moduleList (length moduleList))
(if (or (eq (evt-module event) mod)
(eq (evt-module event) 'NONE))
(if (or (eq lastTime nil)
(> (evt-time event) lastTime))
(setf lastTime (evt-time event))
))))
(verify-current-mp
"mp-show-queue called with no current meta-process."
(let ((events (meta-p-events (current-mp)))
(lastTime nil))
(dolist (event events (length events))
(print "ERERERERERERRRRR~&~&")
(dolist (module moduleList (length moduleList))
(print "2222222222~&~&")
(print (evt-module event))
(print "444")
(when (or (eq (evt-module event) module)
(eq (evt-module event) 'NONE))
(print "33333333~&~&")
(if (or (eq lastTime nil)
(> (evt-time event) lastTime))
(setf lastTime (evt-time event))
))))
(if lastTime
lastTime
0))))
......@@ -675,11 +680,11 @@ t)
(not (phys-module-updateSwitch (get-module physio)))
(> (+ (phys-module-lastUpdate (get-module physio)) delay) (find-last-event-time (list 'procedural 'declarative :fatigue 'vision 'audio 'blending 'temporal 'goal 'imaginal 'motor 'speech))))
(progn
(setf *nextUpdateEvent* (schedule-event-after-change 'update-phys-vars :module 'physio :delay t :output t :maintenance t))
(if (phys-module-physValList (get-module physio))
(return-from schedule-update-phys nil)
(return-from schedule-update-phys t))
(setf (phys-module-updateSwitch (get-module physio)) t))
(setf *nextUpdateEvent* (schedule-event-after-change 'update-phys-vars :module 'physio :delay t :output t :maintenance t))
(if (phys-module-physValList (get-module physio))
(return-from schedule-update-phys nil)
(return-from schedule-update-phys t))
(setf (phys-module-updateSwitch (get-module physio)) t))
(progn
(setf *nextUpdateEvent* (schedule-event-relative delay 'update-phys-vars :module 'physio :priority :max :output t :maintenance t))
(setf (phys-module-updateSwitch (get-module physio)) nil)
......@@ -1251,6 +1256,9 @@ t)
(:phys-ics-exp-file
(phys-module-ics-exp-file phys)))))
;;;Deprecated, keeping for now for records
#|
;Define query function for module (b = buffer)
(defun phys-module-query (phys b slot value)
(case slot
......@@ -1263,12 +1271,14 @@ t)
"Bad state query to ~s buffer" b))))
(t (print-warning
"Invalid slot ~s in query to buffer ~s" slot b)))
)
|#
(defun free-phys-module (phys)
(setf (phys-module-busy phys) nil)
)
;;;Deprecated, keeping for now for records
#|
;;;Define request function for module (slides 53-54 in extending-actr.ppt)
(defun phys-module-requests (phys buffer spec)
;;start underlying substrate
......@@ -1283,8 +1293,10 @@ t)
(set-food-intake 0)))
(if (eq buffer 'efferent)
(phys-create-chunk phys spec))
)
)|#
;;;Deprecated, keeping for now for records
#|
;;;;For now only explicit changes of the value will be parsed, later we will add relative changes (i.e. original value +- chunk slot value)
(defun phys-create-chunk (phys spec)
(progn (if (or (eq (chunk-spec-chunk-type spec) 'phys-var)
......@@ -1301,10 +1313,10 @@ t)
:module 'physio :priority :min))
(progn (print (chunk-spec-chunk-type spec))
(print "Warning - invalid chunk-type in efferent buffer")))))
|#
(define-module-fct 'physio
'(phys-substrate efferent output)
'();'(phys-substrate efferent output)
(list
(define-parameter
:phys-delay
......@@ -1357,6 +1369,6 @@ t)
:reset 'reset-phys-module
:delete 'delete-phys-module
:params 'phys-module-params
:query 'phys-module-query
:request 'phys-module-requests
:query nil;'phys-module-query
:request nil;'phys-module-requests
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment