Skip to content

Commit

Permalink
Documentation edits (#186)
Browse files Browse the repository at this point in the history
* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

* Edits supporting the modeling quide

---------

Co-authored-by: Shawn <[email protected]>
  • Loading branch information
shawnhatch and humbledaisy authored Sep 5, 2023
1 parent 951f4eb commit 1b53827
Show file tree
Hide file tree
Showing 57 changed files with 2,092 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,30 @@
*/
public enum PartitionError implements ContractError {

PAST_LABEL_FAILURE("A labeler has failed to properly identify a person's past label from an event"),
DUPLICATE_PARTITION("Duplicate partition key"), NON_DEGENERATE_PARTITION("Requires a degenerate partition"),
PAST_LABEL_FAILURE("A labeler has failed to properly identify a person's past label from an event"),//
DUPLICATE_PARTITION("Duplicate partition key"),//
NON_DEGENERATE_PARTITION("Requires a degenerate partition"),//
INCOMPATIBLE_LABEL_SET("The label set is incompatible with the selected population partition definition"),
MALFORMED_PARTITION_SAMPLE_WEIGHTING_FUNCTION(
"Data used to form an enumerated distribution for partition sampling was malformed"),
"Data used to form an enumerated distribution for partition sampling was malformed"),//
NULL_LABEL_SET_FUNCTION("Null labelset function"),
RESERVED_PARTITION_TRIGGER(
"An event class is being used to trigger refreshes as part of a partition that is reserved for the partition resolver"),
NON_COMPARABLE_ATTRIBUTE("The attribute definition is not compatible with innequality comparisons"),
NULL_EQUALITY_OPERATOR("Null equality operator"), NULL_LABEL_SET("Null label set"),
NULL_PARTITION("Null partition"), NULL_PARTITION_PLUGIN("null partitions plugin"),
NULL_PARTITION_PLUGIN_DATA("null partitions plugin date"), NULL_PARTITION_LABEL("Null partition label"),
NULL_PARTITION_LABEL_DIMENSION("Null partition label dimension"), NULL_FILTER("Null filter"),
NULL_PARTITION_KEY("Null population partition key"), NULL_POPULATION_PARTITION("Null population partition"),
NULL_PARTITION_DATA_MANAGER("Null partition data manager"), NULL_PARTITION_SAMPLER("Null partition sampler"),

UNKNOWN_POPULATION_PARTITION_KEY("No population partition found"), NULL_PERSON_DATA_VIEW("Null person data view");
"An event class is being used to trigger refreshes as part of a partition that is reserved for the partition resolver"),//
NON_COMPARABLE_ATTRIBUTE("The attribute definition is not compatible with innequality comparisons"),//
NULL_EQUALITY_OPERATOR("Null equality operator"),//
NULL_LABEL_SET("Null label set"),//
NULL_PARTITION("Null partition"),//
NULL_PARTITION_PLUGIN("null partitions plugin"),//
NULL_PARTITION_PLUGIN_DATA("null partitions plugin data"),//
NULL_PARTITION_LABEL("Null partition label"),//
NULL_PARTITION_LABEL_DIMENSION("Null partition label dimension"),//
NULL_FILTER("Null filter"),//
NULL_PARTITION_KEY("Null population partition key"),//
NULL_POPULATION_PARTITION("Null population partition"),//
NULL_PARTITION_DATA_MANAGER("Null partition data manager"),//
NULL_PARTITION_SAMPLER("Null partition sampler"),//
UNKNOWN_POPULATION_PARTITION_KEY("No population partition found"),//
NULL_PERSON_DATA_VIEW("Null person data view");

private final String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ private void ensureImmutability() {

private Builder(Data data) {
this.data = data;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,11 @@ public double getPersonPropertyTime(final PersonId personId, final PersonPropert
validatePersonExists(personId);
validatePersonPropertyId(personPropertyId);
validatePersonPropertyAssignmentTimesTracked(personPropertyId);
return propertyTimes.get(personPropertyId).getValue(personId.getValue());
DoubleValueContainer doubleValueContainer = propertyTimes.get(personPropertyId);
if(doubleValueContainer == null) {
return propertyDefinitionTimes.get(personPropertyId);
}
return doubleValueContainer.getValue(personId.getValue());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package gov.hhs.aspr.ms.gcm.plugins.personproperties.support;

import java.util.function.Function;

/**
*
* A function-based implementor of PersonPropertyLabeler.
*
*/
public class FunctionalPersonPropertyLabeler extends PersonPropertyLabeler {
private final Function<Object, Object> labelingFunction;

public FunctionalPersonPropertyLabeler(PersonPropertyId personPropertyId,
Function<Object, Object> labelingFunction) {
super(personPropertyId);
this.labelingFunction = labelingFunction;
}

@Override
protected Object getLabelFromValue(Object value) {
return labelingFunction.apply(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* start code_ref=actors_lesson_3_output|code_cap=Output from the single actor as it initializes.*/
plugin being initialized -- we will add one actor
actor being initialized
my id = ActorId [id=0]
time = 0.0
/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* start code_ref=data_managers_lesson_4_output|code_cap=Output from the example actor and example data manager showing the alpha property initialization and subsequent evolution.*/
ExampleDataManager is initialized
Example Actor is initialized and will plan to set Alpha
ExampleDataManager sets alpha = 8 at time = 0.0
ExampleDataManager sets alpha = 9 at time = 1.0
ExampleDataManager sets alpha = 10 at time = 2.0
ExampleDataManager sets alpha = 11 at time = 3.0
ExampleDataManager sets alpha = 12 at time = 4.0
ExampleDataManager sets alpha = 13 at time = 5.0
ExampleDataManager sets alpha = 14 at time = 6.0
ExampleDataManager sets alpha = 15 at time = 7.0
ExampleDataManager sets alpha = 16 at time = 8.0
ExampleDataManager sets alpha = 17 at time = 9.0
/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* start code_ref=events_lesson_5_output|code_cap=Output from Actors 2 and 3 as they observe changes to the alpha and beta properties.*/
Actor2 observes event AlphaChangeEvent [previousAlpha=7, currentAlpha=8] at time = 1.0
Actor2 observes event AlphaChangeEvent [previousAlpha=8, currentAlpha=9] at time = 2.0
Actor2 observes event AlphaChangeEvent [previousAlpha=9, currentAlpha=10] at time = 3.0
Actor3 observes event BetaChangeEvent [previousBeta=1.2345, currentBeta=2.469] at time = 3.5
Actor2 observes event AlphaChangeEvent [previousAlpha=10, currentAlpha=11] at time = 4.0
Actor2 observes event AlphaChangeEvent [previousAlpha=11, currentAlpha=12] at time = 5.0
Actor2 observes event AlphaChangeEvent [previousAlpha=12, currentAlpha=13] at time = 6.0
Actor2 observes event AlphaChangeEvent [previousAlpha=13, currentAlpha=14] at time = 7.0
Actor3 observes event BetaChangeEvent [previousBeta=2.469, currentBeta=4.938] at time = 7.0
Actor2 observes event AlphaChangeEvent [previousAlpha=14, currentAlpha=15] at time = 8.0
Actor2 observes event AlphaChangeEvent [previousAlpha=15, currentAlpha=16] at time = 9.0
Actor2 observes event AlphaChangeEvent [previousAlpha=16, currentAlpha=17] at time = 10.0
Actor3 observes event BetaChangeEvent [previousBeta=4.938, currentBeta=9.876] at time = 10.5
Actor3 observes event BetaChangeEvent [previousBeta=9.876, currentBeta=19.752] at time = 14.0
Actor3 observes event BetaChangeEvent [previousBeta=19.752, currentBeta=39.504] at time = 17.5
/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* start code_ref=plugin_dependencies_output|code_cap=The output shows the combined reporting from actors and data managers as they report vaccination progress.*/
Person 7 was vaccinated at time = 1.0
Person 2 was vaccinated at time = 2.0
Person 5 was vaccinated at time = 3.0
Vaccination Data Manager is removing person 2 at time = 3.0
Family Data Manager is removing person 2 at time = 3.0
Person 6 was vaccinated at time = 4.0
Vaccination Data Manager is removing person 1 at time = 4.0
Family Data Manager is removing person 1 at time = 4.0
Person 3 was vaccinated at time = 5.0
Vaccination Data Manager is removing person 8 at time = 5.0
Family Data Manager is removing person 8 at time = 5.0
Failed to vaccinate Person 1 at time = 6.0
Vaccination Data Manager is removing person 6 at time = 6.0
Family Data Manager is removing person 6 at time = 6.0
Person 0 was vaccinated at time = 7.0
Vaccination Data Manager is removing person 7 at time = 7.0
Family Data Manager is removing person 7 at time = 7.0
Person 9 was vaccinated at time = 8.0
Vaccination Data Manager is removing person 5 at time = 8.0
Family Data Manager is removing person 5 at time = 8.0
Failed to vaccinate Person 8 at time = 9.0
Vaccination Data Manager is removing person 3 at time = 9.0
Family Data Manager is removing person 3 at time = 9.0
Person 4 was vaccinated at time = 10.0
Vaccination Data Manager is removing person 4 at time = 10.0
Family Data Manager is removing person 4 at time = 10.0
Vaccination Data Manager is removing person 0 at time = 11.0
Family Data Manager is removing person 0 at time = 11.0
Vaccination Data Manager is removing person 9 at time = 12.0
Family Data Manager is removing person 9 at time = 12.0
/* end */
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public double getSymptomaticDays() {
}
/* end */

/* start code_ref=plugin_data_clone_builder|code_cap=The disease plugin data creates a copy of its data an places it in the returned plugin data builder.*/
/* start code_ref=plugin_data_clone_builder|code_cap=The disease plugin data creates a copy of its data and places it in the returned plugin data builder.*/
@Override
public PluginDataBuilder getCloneBuilder() {
return new Builder(new Data(data));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gov.hhs.aspr.ms.gcm.lessons.plugins.policy.PolicyPlugin;
import gov.hhs.aspr.ms.gcm.lessons.plugins.policy.PolicyPluginData;
import gov.hhs.aspr.ms.gcm.nucleus.Experiment;
import gov.hhs.aspr.ms.gcm.nucleus.ExperimentStatusConsole;
import gov.hhs.aspr.ms.gcm.nucleus.Plugin;

/* start code_ref=experiments_example_9_A|code_cap=Example 9 replaces Example 8's use of the simulation with an experiment.*/
Expand Down Expand Up @@ -43,7 +44,8 @@ public static void main(String[] args) {
.addPlugin(diseasePlugin)//
.addPlugin(modelPlugin)//
.addPlugin(policyPlugin)//
.build()//
.addExperimentContextConsumer(ExperimentStatusConsole.builder().build())//
.build()//
.execute();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* start code_ref=experiements_example_9_D_output_1|code_cap=The first two scenarios.*/
Model Actor initializing
r0 = 1.5
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = false

Model Actor initializing
r0 = 2.0
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = false

/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* start code_ref=experiements_example_9_D_output_2|code_cap=The last two scenarios.*/
Model Actor initializing
r0 = 2.0
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.1
distribute vaccine locally = true

Model Actor initializing
r0 = 2.5
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.1
distribute vaccine locally = true

/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* start code_ref=experiements_example_9_E_output|code_cap=The output from the four threads running the twelve scenarios is a bit jumbled and hard to follow. This will get resolved later with improved output handling.*/
Model Actor initializing
Model Actor initializing
r0 = 1.5
Model Actor initializing
Model Actor initializing
r0 = 1.5
asymptomatic days = 4.0
symptomatic days = 12.0
r0 = 2.5
school closing infection rate = 0.05
asymptomatic days = 4.0
asymptomatic days = 4.0
symptomatic days = 12.0
r0 = 2.0
school closing infection rate = 0.1
distribute vaccine locally = false

...

/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* start code_ref=experiments_example_9_A_output|code_cap=The output of the experiment version is the same as the simulation since the experiment contains exactly one scenario.*/
Model Actor initializing
r0 = 1.5
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = true

1 of 1 scenario, 100% complete. Expected experiment completion in 0:00:00
Experiment completion of 1 scenario in 0:00:00:
SUCCEDED : 1
end of experiment status console
/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* start code_ref=experiments_output|code_cap=The model actor writes output for each of the five scenarios corresponding to the five values of the R0 dimension.*/
Model Actor initializing
r0 = 0.5
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = true

Model Actor initializing
r0 = 0.75
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = true

Model Actor initializing
r0 = 1.0
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = true

Model Actor initializing
r0 = 1.5
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = true

Model Actor initializing
r0 = 2.0
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = true

Model Actor initializing
r0 = 2.5
asymptomatic days = 4.0
symptomatic days = 12.0
school closing infection rate = 0.05
distribute vaccine locally = true

/* end */
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package gov.hhs.aspr.ms.gcm.lessons;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import gov.hhs.aspr.ms.gcm.nucleus.ExperimentContext;

/* start code_ref=output_consumer_D|code_cap=Output consumer D demonstrates that the meta data collected from the dimensions is available from the experiment context. Thus output can be associated with the scenario's meta data.*/
/* start code_ref=output_consumer_D|code_cap=OutputConsumer_D demonstrates that the meta data collected from the dimensions is available from the experiment context. Thus output can be associated with the scenario's meta data.*/
public class OutputConsumer_D implements Consumer<ExperimentContext> {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* start code_ref=output_consumer_B_output|code_cap=The output is still a bit scrambled, but each row now has the relevant scenario id.*/
scenario 1: Model Actor initializing
scenario 2: Model Actor initializing
scenario 3: Model Actor initializing
scenario 0: Model Actor initializing
scenario 3: r0 = 1.5
scenario 0: r0 = 1.5
scenario 2: r0 = 2.5
scenario 2: asymptomatic days = 4.0
scenario 1: r0 = 2.0
scenario 2: symptomatic days = 12.0
scenario 1: asymptomatic days = 4.0
scenario 0: asymptomatic days = 4.0
scenario 2: school closing infection rate = 0.05
scenario 3: asymptomatic days = 4.0
scenario 2: distribute vaccine locally = false
scenario 0: symptomatic days = 12.0
scenario 1: symptomatic days = 12.0
scenario 0: school closing infection rate = 0.05
scenario 1: school closing infection rate = 0.05
scenario 3: symptomatic days = 12.0
scenario 3: school closing infection rate = 0.1
scenario 1: distribute vaccine locally = false
scenario 0: distribute vaccine locally = false
scenario 3: distribute vaccine locally = false
scenario 5: Model Actor initializing
scenario 4: Model Actor initializing
scenario 5: r0 = 2.5
scenario 4: r0 = 2.0

...

/* end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* start code_ref=output_consumer_C_output_1|code_cap=The first output lines for OutputConsumer_C.*/

the experiment is open
scenario 0 is open
scenario 1 is open
scenario 2 is open
scenario 3 is open
scenario 0: Model Actor initializing
scenario 2: Model Actor initializing
scenario 1: Model Actor initializing
scenario 2: r0 = 2.5
scenario 3: Model Actor initializing
scenario 2: asymptomatic days = 4.0
scenario 1: r0 = 2.0
scenario 0: r0 = 1.5
scenario 2: symptomatic days = 12.0

...

/* end */
Loading

0 comments on commit 1b53827

Please sign in to comment.