Commit 0ce0ec48 authored by root's avatar root

Some cleaning up and small changes

parent 62390f46
......@@ -8,3 +8,4 @@ modules/Structure_Stochastic_asdsdsds/
*.lx64fsl
*.wx32fsl
*.wx64fsl
phys-test-models/Test_Data
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -207,7 +207,7 @@
for reference in references
for arousal in arousals
do (progn
(let ((arous-mid (/ (AA-max-arousal (get-module Affective-Associations)) 2)))
(let ((arous-mid (/ (AA-max-arous (get-module Affective-Associations)) 2)))
(incf value
(expt-coerced (max .05 (ms->seconds (- (mp-time-ms) reference)))
(* minus-decay (- 1 (/ arousal arous-mid)))))
......@@ -899,7 +899,7 @@
(nom-util-noise 0.01)
;Max utility noise a model can have
(max-util-noise 1)
(max-util-noise 0.4)
(util-noise-scalar 1)
......@@ -1059,12 +1059,14 @@
(setf (AA-nom-dm-noise AA) (cdr param)))
(:AA-dm-noise-switch
(setf (AA-dm-noise-switch AA) (cdr param)))
(:AA-util-noise-switch
(:AA-util-noise-switch
(setf (AA-util-noise-switch AA) (cdr param)))
(:AA-util-thresh-scalar
(:AA-util-thresh-scalar
(setf (AA-util-thresh-scalar AA) (cdr param)))
(:AA-util-noise-scalar
(:AA-util-noise-scalar
(setf (AA-util-noise-scalar AA) (cdr param)))
(:AA-max-arous
(setf (AA-max-arous AA) (cdr param)))
(:AA-enabled
(setf (AA-enabled AA) (cdr param))))
(case param
......@@ -1096,6 +1098,8 @@
(AA-util-thresh-scalar AA))
(:AA-util-noise-scalar
(AA-util-thresh-scalar AA))
(:AA-max-arous
(AA-max-arous AA))
(:AA-enabled
(AA-enabled AA)))))
......@@ -1157,6 +1161,10 @@
(define-parameter
:AA-util-noise-scalar
:default-value 1
:valid-test (lambda (x) (numberp x)))
(define-parameter
:AA-max-arous
:default-value 2
:valid-test (lambda (x) (numberp x))))
:version "0.1"
:documentation "Affective Associations Module"
......
<ini>
<windowtop> 0 </windowtop>
<windowleft> 0 </windowleft>
<windowtop> 47 </windowtop>
<windowleft> 13 </windowleft>
<windowhigh> 240 </windowhigh>
<windowwide> 366 </windowwide>
<windowstate> 0 </windowstate>
......
......@@ -62,11 +62,11 @@
;;;clear out any unwanted files
(defun clear-phys-files ()
(sleep 0.005)
(dolist (fileName (directory (concatenate 'string *HumModDir* "SolverOut*")))
(dolist (fileName (directory (concatenate 'string *HumModDir* "SolverOut" (phys-module-pipeID (get-module physio)))))
(handler-case (delete-file fileName) (error () nil)))
(dolist (fileName (directory (concatenate 'string *HumModDir* "SolverIn*")))
(dolist (fileName (directory (concatenate 'string *HumModDir* "SolverIn" (phys-module-pipeID (get-module physio)))))
(handler-case (delete-file fileName) (error () nil)))
(dolist (fileName (directory (concatenate 'string *HumModDir* "*.tem")))
(dolist (fileName (directory (concatenate 'string *HumModDir* (phys-module-pipeID (get-module physio)) ".tem")))
(handler-case (delete-file fileName) (error () nil))))
;;;Initialize Variable and Variable Order Hash-Table for physiological variable order
......@@ -88,19 +88,27 @@ t)
"Advance the modelsolver forward in time
timeSlice - The time in minutes"
(let* ((advanceMessage
(concatenate 'string
(concatenate 'string
"\"<solverin><gofor><solutionint>"
(format nil "~10,$" timeSlice)
"</solutionint><displayint>"
(format nil "~10,$" timeSlice)
"</displayint></gofor></solverin>\""))
(phys (get-module physio))
(solverInputFile
(phys (get-module physio))
(solverInputFile
(concatenate 'string
*HumModDir* "SolverIn" (phys-module-pipeID phys)))
(solverOutputFile
(solverOutputFile
(concatenate 'string
*HumModDir* "SolverOut" (phys-module-pipeID phys))))
*HumModDir* "SolverOut" (phys-module-pipeID phys)))
(max-wait
(cond
((<= timeSlice 2) 1)
((< timeSlice 10) 6)
((< timeSlice 60) 12)
((< timeSlice 600) 24)
((< timeSlice 3600) 48)
(t 480))))
(clear-phys-files) ;;Make sure we don't have any files left over for some reason
(tagbody resetAdvance
......@@ -121,7 +129,7 @@ t)
;;Wait for ModelSolver to advance and output data from advancing specified time
(let ((currTime (get-universal-time)))
(handler-case
(while (and (not (probe-file solverOutputFile)) (< (- (get-universal-time) currTime) 480)))
(while (and (not (probe-file solverOutputFile)) (< (- (get-universal-time) currTime) max-wait)))
(error (e) (print (concatenate 'string "124 phys" (write-to-string e))))))
;;If we didn't get the output file, go back and do this all over again
(when (not (probe-file solverOutputFile)) (go resetAdvance)))
......@@ -162,7 +170,7 @@ t)
(tagbody resetSetVal
(clear-phys-files)
(model-output "Changing the following physiology: ~a~&" varValList)
(format t "Changing the following physiology: ~a~&" varValList)
;(format t "Changing the following physiology: ~a~&" varValList)
(let ((phys (get-module physio))
(setPhysMessage "\"<solverin>")
(timeOut 6))
......@@ -177,7 +185,7 @@ t)
(concatenate 'string
setPhysMessage
"<setvalue><var>" k "</var><val>"
(write-to-string (cadr v)) "</val></setvalue>")))))
(format nil "~10,$" (cadr v)) "</val></setvalue>")))))
(setf setPhysMessage (concatenate 'string setPhysMessage "</solverin>\""))
(let ((solverOutputFile (concatenate 'string *HumModDir* "SolverOut" (phys-module-pipeID phys)))
(solverInputFile (concatenate 'string *HumModDir* "SolverIn" (phys-module-pipeID phys))))
......@@ -335,25 +343,26 @@ t)
(setf (phys-module-init phys) t)
;;Set Physiology Substrate periodic communication time (HumMod)
(let* ((pipeID (phys-module-pipeID phys))
;;Set the name of the files used to input to model solver stream and to which solver outputs results
(solverInputFile (concatenate 'string *HumModDir* "SolverIn" pipeID))
(solverOutputFile (concatenate 'string *HumModDir* "SolverOut" pipeID))
;;Set the name of the files used to input to model solver stream and to which solver outputs results
(solverInputFile (concatenate 'string *HumModDir* "SolverIn" pipeID))
(solverOutputFile (concatenate 'string *HumModDir* "SolverOut" pipeID))
(initial-advance-time (format nil "~10,$" (phys-module-initial-advance phys)))
;Reset/Restart Utility Message (needed to start getting values from HumMod model solver)
(resetMessage "\"<solverin><restart/></solverin>\"")
;Reset/Restart Utility Message (needed to start getting values from HumMod model solver)
(resetMessage "\"<solverin><restart/></solverin>\"")
;Get Variables Message
(getVarsMessage "\"<solverin><requestvarroster/></solverin>\"")
;Get Variables Message
(getVarsMessage "\"<solverin><requestvarroster/></solverin>\"")
;We have the simulation go for X mins to stabilize some
; -variables in HumMod (e.g. osmoreceptors), this also returns values
(getValsMessage
;We have the simulation go for X mins to stabilize some
; -variables in HumMod (e.g. osmoreceptors), this also returns values
(getValsMessage
(concatenate 'string
"\"<solverin><gofor><solutionint>" (write-to-string (phys-module-initial-advance phys))
"</solutionint><displayint>" (write-to-string (phys-module-initial-advance phys))
"\"<solverin><gofor><solutionint>" initial-advance-time
"</solutionint><displayint>" initial-advance-time
"</displayint></gofor></solverin>\""))
(physVarList nil)
(physValueList nil))
(physVarList nil)
(physValueList nil))
;;Send reset & restart message to solver
;; *This is needed for solver to correctly process messages sent*
(handler-case
......@@ -431,7 +440,7 @@ t)
(error () nil))
;;Advance Simulator X mins (done to get level osmo-receptor values at a steady state)
(let ((timeOut 10))
(let ((timeOut 120))
(tagbody startGetVals
(handler-case
(delete-file solverOutputFile)
......@@ -637,8 +646,7 @@ t)
(incf (phys-module-timeSliceCount phys)))
;;Record update-phys to internal event trace
(push (list #'update-phys-vars '()) (phys-module-solverActionTrace phys))
))
)
)))
;;;Generate chunks from list of physiological variables
;;; and corresponding values
......@@ -650,8 +658,7 @@ t)
(setf newList (append newList (list (read-from-string
(string-upcase (remove #\space (car currSlot))))))))
;make a chunk from our list
(define-chunks-fct (list newList)))
)
(define-chunks-fct (list newList))))
(defun schedule-phys-events ()
(let ((phys (get-module physio)))
......@@ -675,8 +682,8 @@ t)
(defvar *stress-on* nil)
(defun create-stress ()
"Simulate the physiology side of stress"
(defun create-high-stress ()
"Simulate the physiology side of (high) stress"
(setf *stress-on* t)
(set-phys-vals
(list (list "Sympathetics-General.EssentialEffect" 1.1)
......@@ -684,6 +691,15 @@ t)
(list "Sympathetics-Adrenal.ClampLevel" 2)
(list "Sympathetics-Adrenal.ClampSwitch" 1))))
(defun create-mid-stress ()
"Simulate the physiology side of (medium) stress"
(setf *stress-on* t)
(set-phys-vals
(list (list "Sympathetics-General.EssentialEffect" 0.5)
(list "CorticotropinReleasingFactor.Stress" 3)
(list "Sympathetics-Adrenal.ClampSwitch" 1)
(list "Sympathetics-Adrenal.ClampLevel" 1.5))))
(defun create-graded-symp-stress (&optional (length 20) (perc-inc 100) (num-steps 10))
"Function to allowed a graded increase in sympathetic activity
(presumably due to stress)
......@@ -716,10 +732,11 @@ t)
(set-phys-vals
(list (list " ControlledBreathing.RespRate" 6)
(list "ControlledBreathing.TidalVolumeMax" 3000)
(list "ControlledBreathing.TidalVolumeMin" 1200)
(list "ControlledBreathing.ControlledBreathing" 1)))
(de-stress))
(defun stop-slow-breathing ()
(defun stop-controlled-breathing ()
"Move to spontaneous breath"
(set-phys-vals (list (list "ControlledBreathing.ControlledBreathing" 0))))
......@@ -817,8 +834,9 @@ t)
;;Compute cortisol factor
(defun compute-cort (&optional test)
"cort(t_n)/cort(t_0)
cort(t_n) == cort.gain(t_n)/cort.loss(t_n)"
"cort(t_n)/cort(t_0) + cortisol[uG/dL](t_n)/cortisol[uG/dL](t_0)
cort(t_n) == (cort.gain(t_n)/cort.loss(t_n)
That is, the average of the Cortisol circulating and the more rapid change in cortisol"
(let* ((cort (read-from-string (cadar (car (get-phys-vals nil (list '("Cortisol.[Conc(uG/dL)]")))))))
(cort-base (read-from-string (cadar (car (get-phys-vals t (list '("Cortisol.[Conc(uG/dL)]")))))))
(cort-gain (read-from-string (cadar (car (get-phys-vals nil (list '("Cortisol.Gain")))))))
......@@ -828,8 +846,8 @@ t)
(cort-ratio (if (and cort-gain cort-loss) (/ cort-gain cort-loss) nil))
(cort-ratio-base (if (and cort-gain-base cort-loss-base) (/ cort-gain-base cort-loss-base) nil)))
(setf cort-norm
(if (and cort-ratio cort-ratio-base)
(/ cort-ratio cort-ratio-base) 0))
(if (and cort-ratio cort-ratio-base cort cort-base)
(/ (+ (/ cort-ratio cort-ratio-base) (/ cort cort-base)) 2) 0))
;Write to output file if we are testing things
(if test
(with-open-file
......@@ -1024,8 +1042,8 @@ t)
(progn
;;Schedule periodic updating of ans parameter (eventually I need to make this only happen if call to phys-substrate buffer is made)
(if (phys-module-epi-ans phys)
(schedule-periodic-event (phys-module-delay phys) 'do-epi-ans2
:priority :max :initial-delay 1 :module :none :output nil :maintenance t))
(schedule-periodic-event (phys-module-delay phys) 'do-epi-ans2
:priority :max :initial-delay 1 :module :none :output nil :maintenance t))
;;Make it so cognition controlls eating (as opposed to HumMod)
(set-food-intake 0)))
......@@ -1052,7 +1070,7 @@ t)
(define-module-fct 'physio
'(phys-substrate efferent output)
'(phys-substrate efferent output)
(list
(define-parameter
:phys-delay
......
......@@ -35,6 +35,7 @@ Provides a nice (albeit older) primer on relations between volume
-->
<parm><name> TidalVolumeMax </name><val> 3500 </val></parm>
<parm><name> TidalVolumeMin </name><val> 0 </val></parm>
<parm><name> TidalPhaseShift </name><val> 1.5707963267948966192313216916398 </val></parm>
<!-- Parameter to set respiration rate (breaths/min) -->
<parm><name> RespRate </name><val> 12 </val></parm>
......@@ -84,13 +85,13 @@ Provides a nice (albeit older) primer on relations between volume
<!-- Chris Dancy
Full EQN:
TidalVolume = ( TidalVolumeMin / 2) + (TidalVolumeMax * ((0.5 + (((Sin((PI * 2 * RespRate * Time) + (PI/2))) / 2) / TidalVolumeRatio))))
TidalVolume = ( TidalVolumeMin / 2) + (TidalVolumeMax * ((0.5 + (((Sin((PI * 2 * RespRate * Time) + TidalPhaseShift)) / 2) / TidalVolumeRatio))))
Dividing by 2 and adding by 0.5 will make values 0 to 1 instead of -1 to 1
& Adding by Pi/2 shifts the phase so that we start at TidalMax
& Adding by TidalPhaseShift (Pi/2 by default) shifts the phase so that we start at TidalMax (by default)
-->
<def>
<name> TidalVolume </name>
<val> ( TidalVolumeMin / 2 ) + ( TidalVolumeMax * ( 0.5 + ( ( SIN ( ( 3.1415926535897932384626433832795 * 2 * RespRate * System.X ) + ( 3.1415926535897932384626433832795 / 2 ) ) / 2 ) / TidalVolumeRatio ) ) ) </val>
<val> ( TidalVolumeMin / 2 ) + ( TidalVolumeMax * ( 0.5 + ( ( SIN ( ( 3.1415926535897932384626433832795 * 2 * RespRate * System.X ) + TidalPhaseShift ) / 2 ) / TidalVolumeRatio ) ) ) </val>
</def>
<def>
......
This diff is collapsed.
HumMod / Control
Created : 16-Aug-96
Revised : 2012-07-18
Author : Tom Coleman
Copyright : 1996-2012
By : University of Mississippi Medical Center
<control>
<?include Control\GoFor.DES ?>
<?include Control\GoTo.DES ?>
<?include Control\SettlingTime.DES ?>
<?include Control\Scramble.DES ?>
</control>
End
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.