Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workplace bubbles #38

Merged
merged 96 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
3afc4ef
Created a test suite for the infectious behaviour nodes
RobertManningSmith Feb 7, 2024
61d8514
set up to try and build again
RobertManningSmith Feb 9, 2024
e088d1a
Set simulation up S.T. tests happen every day to all that have them.
RobertManningSmith Feb 14, 2024
d07904f
limited the number of tests to the number available that day
RobertManningSmith Feb 15, 2024
47c5d60
Create spurious symptom managers
RobertManningSmith Feb 16, 2024
e211ba0
Merge branch 'create_demography_tests' into create_epidemiology_tests
RobertManningSmith Feb 27, 2024
b7445e5
Merge demography tests in to redo the infectiour behaviour framework …
RobertManningSmith Feb 27, 2024
3214868
merged demography tests here
RobertManningSmith Feb 27, 2024
3ecd5e6
Update CoronavirusInfectiousBehaviourTesting.java
RobertManningSmith Feb 27, 2024
c570fd7
Merge branch 'create_epidemiology_tests' into redo_testing_from_scratch
RobertManningSmith Feb 27, 2024
9d1aacb
Created a test suite for spurious symptoms of covid
RobertManningSmith Feb 27, 2024
8d0701f
Created test suit for setting and removing covid spurious symptoms
RobertManningSmith Feb 28, 2024
6ed9ddf
created one passing test and spurious symptom object
RobertManningSmith Feb 28, 2024
e91c26a
initial set up of spurious symptom object
RobertManningSmith Mar 1, 2024
a54f9bf
removed unused imports in project
RobertManningSmith Mar 4, 2024
651247b
created a working framework that creates spurious symptom objects, an…
RobertManningSmith Mar 4, 2024
7eb03b8
Spurious symptoms are created as objects by a simple script, test su…
RobertManningSmith Mar 6, 2024
9df1730
Created Logging of the positive tests, not currently working. Also be…
RobertManningSmith Mar 7, 2024
296c0f0
Store all changes to split up the PR into two.
RobertManningSmith Mar 7, 2024
d0d505e
Merge branch 'create_demography_tests' into create_epidemiology_tests
RobertManningSmith Mar 7, 2024
6fd3737
merge demography PR to make it easier to get into main
RobertManningSmith Mar 7, 2024
c21793c
Merge branch 'create_demography_tests' into redo_testing_from_scratch
RobertManningSmith Mar 7, 2024
021ffe8
merged demography PR for easier merging of multiple PRs
RobertManningSmith Mar 7, 2024
56f3090
Merge branch 'create_epidemiology_tests' into robbie_bubbles
RobertManningSmith Apr 15, 2024
dda9ec5
Merge branch 'redo_testing_from_scratch' into robbie_bubbles
RobertManningSmith Apr 15, 2024
e82057b
Workplace objects are being created and read into from the census csv…
RobertManningSmith Apr 15, 2024
75c908d
altered existing census files in code base to avoid errors when loadi…
RobertManningSmith Apr 15, 2024
406d599
started sending people to their workplace nodes. Next step is to addr…
RobertManningSmith Apr 16, 2024
912aafc
Workplaces are now created as locations, workplace bubbles are loaded…
RobertManningSmith Apr 17, 2024
490ca6d
Fixed issue where people were being transfered to their district rath…
RobertManningSmith Apr 18, 2024
a3e58a5
Created a function that reads in workplace contact data and a test to…
RobertManningSmith Apr 19, 2024
4eab29b
updated params files used in testing to include workplace contacts
RobertManningSmith Apr 19, 2024
5844d4b
Managed to get workplace contact counts generated based on a person's…
RobertManningSmith Apr 19, 2024
7a7b46f
moved all testing resource files into the test/resources folder
RobertManningSmith Apr 19, 2024
f2b9726
got things working again...
RobertManningSmith Apr 19, 2024
f5b1e0f
Updated economic status names
RobertManningSmith Apr 23, 2024
c6d5737
had to move all testing files into main/resources as for some unknown…
RobertManningSmith Apr 26, 2024
ad59ae0
changed tests to run from main/resources
RobertManningSmith Apr 26, 2024
082ff1c
Merge branch 'main' into robbie_bubbles
RobertManningSmith May 3, 2024
19a222e
merged main
RobertManningSmith May 3, 2024
1bb4610
ignoring files bought over
RobertManningSmith Jun 4, 2024
0451903
Created a new parameter file to handle loading of workplace constrain…
RobertManningSmith Jun 6, 2024
735946a
Created ability to constrain people to their home based on their occu…
RobertManningSmith Jun 6, 2024
011103f
Constraining movement to community for certain occupations is now wor…
RobertManningSmith Jun 6, 2024
aee24c2
removed unnecessary parameter in main
RobertManningSmith Jun 10, 2024
7d87b45
changed number of community interactions per tick to 5. Can always be…
RobertManningSmith Jun 14, 2024
2eb5343
removed linelist weighting from appearing in parameter files
RobertManningSmith Jun 14, 2024
95c29d3
changed default model version to NOT include bubble based mixing as m…
RobertManningSmith Jun 14, 2024
3cd60ed
removed file from the model. Previous version had perfect mixing work…
RobertManningSmith Jun 14, 2024
be7ca09
commented out/removed old version of workplace bubbles
RobertManningSmith Jun 14, 2024
c3f1c6b
uploaded workplace bubble and census files
RobertManningSmith Jun 17, 2024
f3cc8f0
standardised the loading of population from census files. loaded in w…
RobertManningSmith Jun 17, 2024
2309c25
Backtracked. people inactive or unemployed not ag go to community
RobertManningSmith Jun 17, 2024
8115fdc
fixed test
RobertManningSmith Jun 17, 2024
9660511
.
RobertManningSmith Jun 18, 2024
d46442c
Made people actually interact in the community
RobertManningSmith Jun 19, 2024
924fa82
Create create_averaged_out_csvs_from_output.py
RobertManningSmith Jun 19, 2024
0b0cffd
Updated plot covid cases by age gender to include error bars. Also wo…
RobertManningSmith Jun 20, 2024
b722892
Removed hard coding of occupations
RobertManningSmith Jun 20, 2024
289a234
Removed duplicate output file
RobertManningSmith Jun 21, 2024
892f5d3
Fixed analysis script of csv output script
RobertManningSmith Jun 21, 2024
b47a93e
Merge branch 'main' into robbie_bubbles
RobertManningSmith Jun 24, 2024
5df8528
fixed an issue with interaction between di=ecision to go to work or t…
RobertManningSmith Jun 25, 2024
9858c8d
removed spurious symptoms from this branch
RobertManningSmith Jul 12, 2024
b59f06c
Merge branch 'main' into robbie_bubbles
RobertManningSmith Jul 12, 2024
f11f5ba
Removed references to testing.
RobertManningSmith Jul 12, 2024
5251f00
Mapped new occupations to enums
RobertManningSmith Jul 15, 2024
4d84b83
debug
RobertManningSmith Jul 19, 2024
482fea4
Edited names of variables for more clarity, edited logging to only ou…
RobertManningSmith Aug 5, 2024
8842ef9
clean up
RobertManningSmith Aug 5, 2024
5855ede
Revert "clean up"
RobertManningSmith Aug 5, 2024
33ade74
Merge branch 'main' into robbie_bubbles
RobertManningSmith Aug 5, 2024
bfba097
missed commit
RobertManningSmith Aug 5, 2024
ef65955
First pass at code
RobertManningSmith Aug 6, 2024
a98fb5f
Got params.txt to run
RobertManningSmith Aug 6, 2024
13a8bb4
Got mobility tests back working
RobertManningSmith Aug 6, 2024
2e193b0
Got covid behaviour tests working
RobertManningSmith Aug 6, 2024
57a6ffd
test suite back passing
RobertManningSmith Aug 6, 2024
daa4f2a
built up to successful myriad run
RobertManningSmith Aug 6, 2024
c689757
Changed the trigger for lockdowns to work with days rather than ticks…
RobertManningSmith Aug 29, 2024
d8c0845
Small change to show when lockdowns are triggered
RobertManningSmith Sep 13, 2024
98d1753
merge commit and deleted unused filename suffix
RobertManningSmith Sep 18, 2024
8abed1a
Merge branch 'main' into robbie_bubbles
RobertManningSmith Oct 3, 2024
6f41c93
Fixed testing issues
RobertManningSmith Oct 3, 2024
4c95886
Merge branch 'main' into robbie_bubbles
RobertManningSmith Oct 3, 2024
f151463
Update helperFunctions.java
RobertManningSmith Oct 3, 2024
71c8e93
Merge with main and complete set up to merge
RobertManningSmith Oct 3, 2024
591b437
Delete model_output_analysis_scripts/create_averaged_out_csvs_from_ou…
RobertManningSmith Oct 4, 2024
2dcfb34
Delete model_output_analysis_scripts/plot_covid_cases_by_age_gender.py
RobertManningSmith Oct 4, 2024
73ab347
Update MobilityTesting.java
RobertManningSmith Oct 4, 2024
8c19417
Merge branch 'robbie_bubbles' of https://github.com/dime-worldbank/Di…
RobertManningSmith Oct 4, 2024
8417446
Changed helper function to only set infections as a certain behaviour…
RobertManningSmith Oct 7, 2024
492c0b9
deleted dev related variables
RobertManningSmith Oct 7, 2024
e3fcc13
Changed initialisationnof varialbles to default to null. Workplace te…
RobertManningSmith Oct 7, 2024
a33babb
Update WorkplaceTesting.java
RobertManningSmith Oct 7, 2024
35e33a3
typo
RobertManningSmith Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ Protecs/src/main/resources/census_ipums.csv
Protecs/src/main/resources/province_line_list.txt
Protecs/src/main/resources/census_ipums_5perc.csv
Protecs/src/main/resources/ipums_radiation_formatted.csv

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sim.engine.SimState;
import sim.engine.Steppable;
import uk.ac.ucl.protecs.objects.Household;
import uk.ac.ucl.protecs.objects.Workplace;
import uk.ac.ucl.protecs.objects.Location;
import uk.ac.ucl.protecs.objects.Person;
import uk.ac.ucl.protecs.objects.Person.OCCUPATION;
Expand Down Expand Up @@ -208,6 +209,7 @@ private void createBirth(SimState arg0, boolean isAlive) {
SEX sexAssigned = sexList.get(world.random.nextInt(sexList.size()));
OCCUPATION babiesJob = OCCUPATION.UNEMPLOYED;
Household babyHousehold = target.getHouseholdAsType();
Workplace babyWorkplace = null;
Location babyAdminZone = target.getLocation();
boolean babySchooling = false;
int birthday = time;
Expand All @@ -218,6 +220,7 @@ private void createBirth(SimState arg0, boolean isAlive) {
babiesJob, // lower case all of the job titles
babySchooling,
babyHousehold, // household
babyWorkplace,
world
);
// update the household and location to include the baby
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sim.engine.Steppable;
import swise.behaviours.BehaviourFramework;
import swise.behaviours.BehaviourNode;
import uk.ac.ucl.protecs.objects.Workplace;

/**
* The MovementBehaviourFramework is an extension on the basis of the BehaviourFramework which
Expand Down Expand Up @@ -50,9 +51,8 @@ public MovementBehaviourFramework(WorldBankCovid19Sim model){

@Override
public double next(Steppable s, double time) {

Person p = (Person) s;

// the Person may have been sent home immobilised: update everything and don't schedule
// to run again until it has been un-immobilised!
if(p.isImmobilised()) {
Expand All @@ -72,49 +72,112 @@ public double next(Steppable s, double time) {
if(myWorld.random.nextDouble() > myEconStatProb)
return myWorld.params.ticks_per_day; // rest until tomorrow


// if it's morning, go out for the day
// if it's morning, go out for the day, reset the number of contacts they will have
if(hour >= myWorld.params.hour_start_day_weekday){
// reset occurs at hour 2
p.resetWorkplaceContacts();

Location target;
target = myWorld.params.getTargetMoveAdminZone(p, day, myWorld.random.nextDouble(), myWorld.lockedDown);
// define workday
boolean goToWork = (p.isSchoolGoer() || target == p.getCommunityLocation()) // schoolgoer or going to own admin zone
&& myWorld.params.isWeekday(day);
return determineDailyRoutine(p, hour, day);
}

return 1; // otherwise it's not the morning - stay home for now, but check in again later!
}

private double determineDailyRoutine(Person p, int hour, int day) {
Location target;
target = myWorld.params.getTargetMoveAdminZone(p, day, myWorld.random.nextDouble(), myWorld.lockedDown);
// then check if they are supposed to leave the admin zone they are currently in. If so, then they cannot go to work.
boolean stayingInHomeDistrict = target.getId().equals(p.getHousehold().getRootSuperLocation().getId());
// First check if they are visiting another district
if (!stayingInHomeDistrict) p.setVisiting(true);
if (p.visitingNow() & !stayingInHomeDistrict) {
// travelling to another district!
p.transferTo(target);
p.setActivityNode(communityNode);
p.setAtWork(false);
assert ! p.getHousehold().getSuper().equals(target) :
"set to travel to a different district but didn't, home/target " + p.getHousehold().getSuper().getId() + " " + target.getId();
// stay out until time to go home!
return myWorld.params.hour_end_day_otherday - hour;
}
// if they aren't visiting, are they at work or the community?
else {
// Check they are going to work
boolean goToWork = myWorld.random.nextDouble() < myWorld.params.prob_go_to_work;

// if unemployed or homemaker don't go to work
if (p.isUnemployed()) {
goToWork = false;
}
// first check if there is any constraints to this occupations movements. Note that if the model is using this code block then
// this person has not been immobilised and if their movement is constrained it will mean that they only go to the community and not to work
boolean movementConstrained = myWorld.params.OccupationConstraintList.containsKey(p.getEconStatus());

if(myWorld.params.setting_perfectMixing) // in perfect mixing, just go to the community!
goToWork = false;

if (goToWork & !movementConstrained) target = p.getWorkLocation();


p.transferTo(target);
assert (p.getLocation().equals(target)) : "Transfer to target didn't work";
RobertManningSmith marked this conversation as resolved.
Show resolved Hide resolved

// update appropriately
if(goToWork){ // working
p.setActivityNode(workNode);
p.setAtWork(true);
p.setVisiting(false);
return myWorld.params.hours_at_work_weekday;
}

else if(target == p.getCommunityLocation()) { // in home admin zone, not working
}
else { // in home district, not working
p.setActivityNode(communityNode);
p.setAtWork(false);
p.setVisiting(false);
assert p.getHousehold().getSuper().getId().equals(target.getId()) :
"set to travel to a within admin zone but didn't, home/target " + p.getHousehold().getSuper().getId() + " " + target.getId();
return myWorld.params.hour_end_day_otherday - hour; // stay out until time to go home!
}

else{ // travelling to another admin zone!
p.setActivityNode(communityNode);
p.setAtWork(false);
p.setVisiting(true);
assert ! p.getHousehold().getSuper().equals(target) :
"set to travel to a different admin zone but didn't, home/target " + p.getHousehold().getSuper().getId() + " " + target.getId();
return myWorld.params.hour_end_day_otherday - hour; // stay out until time to go home!
}
}
return 1; // otherwise it's not the morning - stay home for now, but check in again later!
}
}

// private double oldDetermineDailyRoutine(Person p, int hour, int day) {
// Location target;
// target = myWorld.params.getTargetMoveDistrict(p, day, myWorld.random.nextDouble(), myWorld.lockedDown);
// assert target.getId().startsWith("d_"): "target is a null location";
// // define workday
// boolean goToWork = (p.isSchoolGoer() || target == p.getCommunityLocation()) // schoolgoer or going to own district
// && myWorld.params.isWeekday(day);
//
// if(myWorld.params.setting_perfectMixing) // in perfect mixing, just go to the community!
// goToWork = false;
//
// p.transferTo(target);
// assert (p.getLocation().equals(target)) : "Transfer to target didn't work";
//
// // update appropriately
// if(goToWork){// working
// p.setActivityNode(workNode);
// p.setAtWork(true);
// p.setVisiting(false);
// return myWorld.params.hours_at_work_weekday;
// }
//
// else if(target == p.getCommunityLocation()) { // in home district, not working
// p.setActivityNode(communityNode);
// p.setAtWork(false);
// assert p.getHousehold().getSuper().getId().equals(target.getId()) :
// "set to travel to a within district but didn't, home/target " + p.getHousehold().getSuper().getId() + " " + target.getId();
// return myWorld.params.hour_end_day_otherday - hour; // stay out until time to go home!
// }
//
// else{ // travelling to another district!
// p.setActivityNode(communityNode);
// p.setAtWork(false);
// p.setVisiting(true);
// assert ! p.getHousehold().getSuper().equals(target) :
// "set to travel to a different district but didn't, home/target " + p.getHousehold().getSuper().getId() + " " + target.getId();
// return myWorld.params.hour_end_day_otherday - hour; // stay out until time to go home!
// }
// }

@Override
public boolean isEndpoint() {
Expand All @@ -131,10 +194,9 @@ public boolean isEndpoint() {
public double next(Steppable s, double time) {

Person p = (Person) s;

// extract time info
int hour = ((int)time) % Params.ticks_per_day;


// if it's too late, go straight home
if(hour > myWorld.params.hour_end_day_weekday){
Expand Down Expand Up @@ -171,7 +233,7 @@ public boolean isEndpoint() {
public double next(Steppable s, double time) {

Person p = (Person) s;

// extract time info
int hour = ((int)time) % Params.ticks_per_day;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public Household(String id, Location l){
super();
myId = "HH_" + id;
mySuperLocation = l;
category = LocationCategory.HOME;
setLocationType(LocationCategory.HOME);
}

/**
Expand Down
21 changes: 12 additions & 9 deletions Protecs/src/main/java/uk/ac/ucl/protecs/objects/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashSet;


/**
* A generic holder for spatial data. Locations keep track of the spatial location within which they exist.
* TODO add relationships between/among locations.
Expand All @@ -14,6 +15,7 @@ public class Location {
Location mySuperLocation; // the Location within which this Location exists
HashSet <Person> personsHere;
Object [] personsHere_list;
LocationCategory myType;
boolean active = false;

public int metric_died_count;
Expand All @@ -24,29 +26,28 @@ public class Location {
public int metric_new_deaths;
public int metric_new_recovered;
public int metric_currently_infected;

public enum LocationCategory{
HOME("home"), WORK("work"), COMMUNITY("community");
HOME("home"), WORKPLACE("workplace"), COMMUNITY("community");

public String key;

LocationCategory(String key) { this.key = key; }

static LocationCategory getValue(String x) {
public static LocationCategory getValue(String x) {

switch (x) {
case "home":
return HOME;
case "work":
return WORK;
return WORKPLACE;
case "community":
return COMMUNITY;
default:
throw new IllegalArgumentException();
}
}
}
LocationCategory category;

// CONSTRUCTORS

public Location(String id, Location mySuper){
Expand Down Expand Up @@ -76,7 +77,6 @@ public Location(String id){
public Location(){
this("", null);
}


/**
* Add a person to the Location. Returns false if the Person is already there.
Expand Down Expand Up @@ -157,7 +157,10 @@ public void setActive(boolean b) {
active = b;
}
public boolean getActive() { return active; }

public void setLocationType(LocationCategory locationCategory) {this.category = locationCategory;}
public LocationCategory getLocationType() {return this.category;}

public void setLocationType(LocationCategory type) {
myType = type;
}
public LocationCategory getLocationType() {return this.myType;}

}
Loading