Skip to content

Commit 3ef0d72

Browse files
committed
docs(log): update log
1 parent 41cec21 commit 3ef0d72

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

docs/log.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class Model:
614614
self.env.run(until=run_length)
615615
```
616616

617-
## Tests
617+
## Tests and run time
618618

619619
We could add some basic tests now, e.g.
620620

@@ -628,6 +628,8 @@ Although as not actually doing warm-up logic yet, going down that path a bit pre
628628
629629
> 💡 Maybe don't need to be mentioning tests at this stage yet.
630630
631+
Hence, removed some of the tests and switched to just run time.
632+
631633
```
632634
class MockParam:
633635
"""
@@ -727,4 +729,60 @@ def test_run_time():
727729
model.run()
728730
assert model.env.now == 21
729731
assert len(model.patients) > 0
730-
```
732+
```
733+
734+
## Patient destination & model logic
735+
736+
In the model length of stay is determined not just by patient type, but also patient destination post ASU. For example Early Supported Discharge greatly reduces length of stay. As such the model is designed to sample destination as the patient arrives.
737+
738+
Restructured `ASURouting` and `RehabRouting` (and also the LOS classes) to be dictionaries for each patient, a more useable format, as we'll be searching for parameters by patient type.
739+
740+
Created sampling distributions for routing and length of stay, and sampled the post-ASU destination.
741+
742+
At this point, built rest of model logic basically.
743+
744+
* Removed the redundant distribution from Model.patient_generator() and add the patient routing type (dependent on post-ASU destination for stroke - stroke_esd or stroke_noesd).
745+
* Set up the ASU and rehab processes.
746+
747+
## Daily audit of occupancy
748+
749+
Figure 1 is the results from a daily audit of occupancy of the ASU (i.e. number of patients on the unit).
750+
751+
I add a variable recording occupancy, which is increased and decreased as patients come and go.
752+
753+
I then set up an auditor which checks and records the value of occupancy once per day.
754+
755+
## Logging
756+
757+
Soon, will want to run the model for longer time periods, and so want to be able to disable the printed messages if desired.
758+
759+
Hence, at this stage, I switched to using the logging module rather than simple print statements.
760+
761+
> 💡 Remember trace as simpler alternative if full logs are not desired.
762+
763+
I copied over the code from `rap_template_python_des` `logging.py`.
764+
765+
I then imported this class to `Param`, with `logger` now a parameter, tweaking it so you're just setting `log_to_console` and `log_to_file` rather than needing to provide the `SimLogger` class.
766+
767+
Within `Model`, I add information about model information to the log within `__init__`, and then replaced the `print()` statements elsewhere with `log()`.
768+
769+
## Occupancy plot
770+
771+
Now able to disable logging, I increased the run length and add code to generate the occupancy plot in `analysis.ipynb`.
772+
773+
This is similar but won't be quite right as have not yet add the warm-up period...
774+
775+
## Warm-up
776+
777+
Followed the template to add the warm-up period. Didn't include anything on choosing warm-up as that is already chosen in the paper. Steps to add warm-up were:
778+
779+
* Changing default warm-up parameter in `Param`.
780+
* Run time is warm-up + data collection (already done).
781+
* Add a warm-up method to `Model` which resets the results variables.
782+
* Schedule this method in `run()`.
783+
784+
The template has lots going on in this regard, with fixing for utilisation and so on. Just went simple, with it all done in `warm_up()` method, and just setting `patients` and `audit_list` to [].
785+
786+
## Probability of delay plot
787+
788+
Add code to generate Figure 3, and included explanation of how we can determine probability of delay based on the frequencies and cumulative frequencies.

0 commit comments

Comments
 (0)