Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrehmann committed Feb 20, 2025
1 parent 255b857 commit 365ff6d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/matsim/episim/InfectionEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,15 @@ public void reset(int iteration) {
// Sum of antibodies
Object2DoubleMap<VirusStrain> antibodies = new Object2DoubleOpenHashMap<>();

boolean fakeAgentsPossible = contactModel instanceof SymmetricContactModelWithOdeCoupling;

for (EpisimPerson person : personMap.values()) {

if (fakeAgentsPossible && person.getPersonId().toString().startsWith("fake_")) {
progressionModel.removeAgent(person.getPersonId());
}


progressionModel.updateState(person, iteration);
antibodyModel.updateAntibodies(person, iteration);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ private static long compoundLong(int x, int y) {
@Override
public void updateState(EpisimPerson person, int day) {

// // This is useful for fake agents in SymmetricContactModelWithOdeCoupling.
// if (person.isExcludeFromDiseaseStateProgression()) {
// return;
// }

EpisimPerson.DiseaseStatus status = person.getDiseaseStatus();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void resetOdeDiseaseImportCount() {
// unknownCnt = 0L;
// }

private EpisimPerson borrowPerson(Attributes sharedAttributes, EpisimReporting reporting) {
private EpisimPerson borrowPerson(Attributes sharedAttributes, EpisimReporting reporting, double now, int dayCounter) {
Deque<EpisimPerson> pool = personPool.get();
EpisimPerson person = pool.poll();
if (person == null) {
Expand All @@ -157,6 +157,19 @@ private EpisimPerson borrowPerson(Attributes sharedAttributes, EpisimReporting r
person.setDiseaseStatus(0, DiseaseStatus.susceptible);
// person.getActivities().clear(); // Clear any leftover activities
}

// if (person.getDiseaseStatus().equals(DiseaseStatus.contagious)) {
// return person;
// }

// this do-while loop will add a person, check if they are actually contagious; if not, they'll add another person.
do {
progressionModel.removeAgent(person.getPersonId());
person.setDiseaseStatus(now, DiseaseStatus.infectedButNotContagious);
//todo: talk to kai: should we this be a distribution of when they become infectious, because infectivity depends on how long they've been infectious.
progressionModel.updateState(person, dayCounter);
} while (!person.getDiseaseStatus().equals(DiseaseStatus.contagious));

return person;
}

Expand Down Expand Up @@ -330,21 +343,11 @@ private void infectionDynamicsGeneralized(EpisimPerson personLeavingContainer, E


// Id<Person> personId = Id.createPersonId("fake_task" + taskId + "_" + i);
EpisimPerson person = borrowPerson(sharedAttributes, reporting);
EpisimPerson person = borrowPerson(sharedAttributes, reporting, now, dayCounter);
//
// EpisimPerson person = new EpisimPerson(personId, sharedAttributes, reporting);

containerFake.addPerson(person, 0, new EpisimPerson.PerformedActivity(0, episimConfig.getOrAddContainerParams(actType), null));

// this do-while loop will add a person, check if they are actually contagious; if not, they'll add another person.
do {
progressionModel.removeAgent(person.getPersonId());
person.setDiseaseStatus(now, DiseaseStatus.infectedButNotContagious);
//todo: talk to kai: should we this be a distribution of when they become infectious, because infectivity depends on how long they've been infectious.
progressionModel.updateState(person, dayCounter);
} while (!person.getDiseaseStatus().equals(DiseaseStatus.contagious));


}
}
}
Expand Down Expand Up @@ -544,7 +547,10 @@ private void infectionDynamicsGeneralized(EpisimPerson personLeavingContainer, E
EpisimPerson person = iterator.next();
if (person.getPersonId().toString().startsWith("fake")) {
returnPerson(person);

// remove from progression model
((AbstractProgressionModel) progressionModel).removeAgent(person.getPersonId());

iterator.remove(); // Properly remove from the list
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/matsim/run/CreateBatteryForCluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
)
@SuppressWarnings("unchecked, rawtypes")
public class CreateBatteryForCluster<T> implements Callable<Integer> {
private static final String CLASS_NAME = "newC_berlin_brand";
private static final String CLASS_NAME = "newA_berlin";

private static final Logger log = LogManager.getLogger(CreateBatteryForCluster.class);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/matsim/run/batch/newA_berlin.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public static final class Params {
@Parameter({1.0})
public double thetaFactor;

// @Parameter({-1.0, 0.5, 0.75, 1.0, 1.25, 1.5})
@Parameter({1.})
@Parameter({0.5, 0.75, 1.0, 1.25, 1.5})
// @Parameter({1.})
public double ode;

}
Expand All @@ -133,7 +133,7 @@ public static void main(String[] args) {
String[] args2 = {
RunParallel.OPTION_SETUP, newA_berlin.class.getName(),
RunParallel.OPTION_PARAMS, Params.class.getName(),
RunParallel.OPTION_TASKS, Integer.toString(2),
RunParallel.OPTION_TASKS, Integer.toString(1),
RunParallel.OPTION_ITERATIONS, Integer.toString(50),
RunParallel.OPTION_METADATA
};
Expand Down

0 comments on commit 365ff6d

Please sign in to comment.