Skip to content

Commit

Permalink
Merge pull request #238 from dhardy/output
Browse files Browse the repository at this point in the history
Output EIR by species
  • Loading branch information
dhardy authored Jun 26, 2019
2 parents dc93c57 + f075cce commit 5d0263e
Show file tree
Hide file tree
Showing 17 changed files with 528 additions and 49 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ before_install:

install:
- mkdir build && pushd build
- cmake -DCMAKE_BUILD_TYPE=Release -DOM_COPY_LIBS=1 ..
- cmake -DCMAKE_BUILD_TYPE=Release ..

script:
- make -j4
Expand All @@ -60,7 +60,6 @@ script:
- echo "Using schema ../schema/$SCHEMA"
- cp ../schema/$SCHEMA example/
- cp openMalaria example/
- cp *.so example/
- pushd example && strip openMalaria && ./run-example-scenario.sh && popd
- echo "Running test scenarios"
- ctest -j4
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ after_build:
- cmd: ECHO "build-log:" https://ci.appveyor.com/project/%APPVEYOR_ACCOUNT_NAME%/openmalaria/builds/%APPVEYOR_BUILD_ID% >> %APPVEYOR_BUILD_FOLDER%\OpenMalaria\appveyor.log
- cmd: ECHO "build-version:" %APPVEYOR_BUILD_VERSION% >> %APPVEYOR_BUILD_FOLDER%\OpenMalaria\appveyor.log
- cmd: ECHO "worker-image:" %APPVEYOR_BUILD_WORKER_IMAGE% >> %APPVEYOR_BUILD_FOLDER%\OpenMalaria\appveyor.log
- cmd: copy %APPVEYOR_BUILD_FOLDER%\version.txt %APPVEYOR_BUILD_FOLDER%\OpenMalaria
- cmd: copy %APPVEYOR_BUILD_FOLDER%\xsd\bin\xerces-c*.dll %APPVEYOR_BUILD_FOLDER%\OpenMalaria
- cmd: mkdir %APPVEYOR_BUILD_FOLDER%\OpenMalaria\schema
- cmd: copy %APPVEYOR_BUILD_FOLDER%\schema\scenario_*.xsd %APPVEYOR_BUILD_FOLDER%\OpenMalaria\schema
Expand Down
7 changes: 5 additions & 2 deletions model/Transmission/NonVectorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void NonVectorModel::update () {
}


double NonVectorModel::calculateEIR(Host::Human& human, double ageYears, vector<double>& EIR){
void NonVectorModel::calculateEIR(Host::Human& human, double ageYears, vector<double>& EIR){
EIR.resize( 1 ); // no support for per-genotype tracking in this model (possible, but we're lazy)
// where the full model, with estimates of human mosquito transmission is in use, use this:
switch (simulationMode) {
Expand Down Expand Up @@ -258,7 +258,10 @@ double NonVectorModel::calculateEIR(Host::Human& human, double ageYears, vector<
}
#endif
EIR[0] *= human.perHostTransmission.relativeAvailabilityHetAge (ageYears);
return EIR[0];

auto ag = human.monAgeGroup().i();
auto cs = human.cohortSet();
mon::reportStatMACGF( mon::MVF_INOCS, ag, cs, 0, EIR[0] );
}


Expand Down
2 changes: 1 addition & 1 deletion model/Transmission/NonVectorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class NonVectorModel : public TransmissionModel {

virtual void vectorUpdate () {}
virtual void update ();
virtual double calculateEIR(OM::Host::Human& human, double ageYears, vector< double >& EIR);
virtual void calculateEIR(OM::Host::Human& human, double ageYears, vector< double >& EIR);

private:

Expand Down
28 changes: 0 additions & 28 deletions model/Transmission/TransmissionModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@
namespace OM { namespace Transmission {
namespace vectors = util::vectors;

inline size_t survInocsSize(size_t nGenotypes){
return mon::AgeGroup::numGroups() * mon::numCohortSets() * nGenotypes; }
inline size_t survInocsIndex(size_t ageGroup, size_t cohortSet, size_t genotype){
return ageGroup + mon::AgeGroup::numGroups() *
(cohortSet + mon::numCohortSets() * genotype);
}

TransmissionModel* TransmissionModel::createTransmissionModel (const scnXml::Entomology& entoData, int populationSize) {
// Entomology contains either a list of at least one anopheles or a list of at
// least one EIRDaily.
Expand Down Expand Up @@ -125,7 +118,6 @@ TransmissionModel::TransmissionModel(const scnXml::Entomology& entoData,
tsNumAdults(0)
{
initialisationEIR.assign (SimTime::stepsPerYear(), 0.0);
surveyInoculations.assign(survInocsSize(nGenotypes), 0.0);

using Monitoring::Continuous;
Continuous.registerCallback( "input EIR", "\tinput EIR", MakeDelegate( this, &TransmissionModel::ctsCbInputEIR ) );
Expand Down Expand Up @@ -201,11 +193,6 @@ double TransmissionModel::getEIR( Host::Human& human, SimTime age,
calculateEIR( human, ageYears, EIR );
util::streamValidate( EIR );

for( size_t g = 0, nG = EIR.size(); g < nG; ++g ){
size_t index = survInocsIndex(human.monAgeGroup().i(), human.cohortSet(), g);
surveyInoculations[index] += EIR[g];
}

double allEIR = vectors::sum( EIR );
if( age >= adultAge ){
tsAdultEntoInocs += allEIR;
Expand All @@ -220,19 +207,6 @@ void TransmissionModel::summarize () {

if( !mon::isReported() ) return; // cannot use counters below when not reporting

for( size_t ag = 0, nAg = mon::AgeGroup::numGroups(), cs = 0,
nCS = mon::numCohortSets(), g = 0, nG = surveyInoculations.size() / (nAg * nCS);
ag < nAg; ++ag )
{
for( cs = 0; cs < nCS; ++cs ){
for( g = 0; g < nG; ++ g ){
size_t index = survInocsIndex(ag, cs, g);
mon::reportStatMACGF( mon::MVF_INOCS, ag, cs, g, surveyInoculations[index] );
}
}
}
surveyInoculations.assign( surveyInoculations.size(), 0.0 );

double duration = (sim::now() - lastSurveyTime).inSteps();
if( duration == 0.0 ){
assert( surveyInputEIR == 0.0 && surveySimulatedEIR == 0.0 );
Expand Down Expand Up @@ -265,7 +239,6 @@ void TransmissionModel::checkpoint (istream& stream) {
lastSurveyTime & stream;
numTransmittingHumans & stream;
tsNumAdults & stream;
surveyInoculations & stream;
}
void TransmissionModel::checkpoint (ostream& stream) {
simulationMode & stream;
Expand All @@ -283,7 +256,6 @@ void TransmissionModel::checkpoint (ostream& stream) {
lastSurveyTime & stream;
numTransmittingHumans & stream;
tsNumAdults & stream;
surveyInoculations & stream;
}

} }
Expand Down
6 changes: 1 addition & 5 deletions model/Transmission/TransmissionModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class TransmissionModel {
* @param EIR Out-vector. Set to the age- and heterogeneity-specific EIR an
* individual human is exposed to, per parasite genotype, in units of
* inoculations per day. Length set by callee. */
virtual double calculateEIR(Host::Human& human, double ageYears,
virtual void calculateEIR(Host::Human& human, double ageYears,
vector<double>& EIR ) = 0;

/** Needs to be called each time-step after Human::update() to update summary
Expand Down Expand Up @@ -307,10 +307,6 @@ class TransmissionModel {

/// accumulator for time step adults requesting EIR
int tsNumAdults;

/// Total inoculations since last survey (multidimensional).
/// See survInocsSize, survInocsIndex in cpp file.
vector<double> surveyInoculations;
};

} }
Expand Down
11 changes: 7 additions & 4 deletions model/Transmission/VectorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,18 @@ SimTime VectorModel::initIterate () {
}
}

double VectorModel::calculateEIR(Host::Human& human, double ageYears,
void VectorModel::calculateEIR(Host::Human& human, double ageYears,
vector<double>& EIR)
{
auto ag = human.monAgeGroup().i();
auto cs = human.cohortSet();
PerHost& host = human.perHostTransmission;
host.update( human );
if (simulationMode == forcedEIR){
double eir = initialisationEIR[sim::ts0().moduloYearSteps()] *
host.relativeAvailabilityHetAge (ageYears);
mon::reportStatMACGF( mon::MVF_INOCS, ag, cs, 0, eir );
EIR.assign( 1, eir );
return eir;
}else{
assert( simulationMode == dynamicEIR );
EIR.assign( WithinHost::Genotypes::N(), 0.0 );
Expand All @@ -441,10 +443,11 @@ double VectorModel::calculateEIR(Host::Human& human, double ageYears,
* See comment in AnophelesModel::advancePeriod for method. */
double entoFactor = ageFactor * host.availBite(species[i].getHumanBaseParams(), i);
for( size_t g = 0; g < EIR.size(); ++g ){
EIR[g] += partialEIR[g] * entoFactor;
auto eir = partialEIR[g] * entoFactor;
mon::reportStatMACSGF( mon::MVF_INOCS, ag, cs, i, g, eir );
EIR[g] += eir;
}
}
return vectors::sum( EIR );
}
}

Expand Down
2 changes: 1 addition & 1 deletion model/Transmission/VectorModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class VectorModel : public TransmissionModel {
virtual void vectorUpdate ();
virtual void update ();

virtual double calculateEIR( Host::Human& human, double ageYears,
virtual void calculateEIR( Host::Human& human, double ageYears,
vector<double>& EIR );

virtual const map<string,size_t>& getSpeciesIndexMap();
Expand Down
8 changes: 6 additions & 2 deletions model/mon/OutputMeasures.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ void defineOutMeasures(){
/// Kappa (human infectiousness) weighted by availability per day-of-year for the last year.
/// (Reporting removed.)
namedOutMeasures["kappaPerDayOfYear"] = OutMeasure::obsolete( 29 );
/** The total number of inoculations, by age group and cohort, summed over
* the reporting period. */
/** The total number of inoculations, by age group, cohort and parasite
* genotype, summed over the reporting period. */
namedOutMeasures["innoculationsPerAgeGroup"] =
OutMeasure::humanACG( 30, MVF_INOCS, true );
/// N_v0: emergence of feeding vectors during the last time step. Units: mosquitoes/day
Expand Down Expand Up @@ -450,6 +450,10 @@ void defineOutMeasures(){
*/
namedOutMeasures["expectedSevere"] =
OutMeasure::humanAC( 78, MHF_EXPECTED_SEVERE, true );
/** The total number of inoculations, by mosquito species, summed over
* the reporting period. */
namedOutMeasures["innoculationsPerVector"] =
OutMeasure::species( 79, MVF_INOCS, false );

// Now initialise valid condition measures:
foreach( const NamedMeasureMapT::value_type& v, namedOutMeasures ){
Expand Down
6 changes: 6 additions & 0 deletions model/mon/mon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,12 @@ void reportStatMACGF( Measure measure, size_t ageIndex, uint32_t cohortSet,
const size_t survey = impl::survNumStat;
storeF.report( val, measure, survey, ageIndex, cohortSet, 0, genotype, 0 );
}
void reportStatMACSGF( Measure measure, size_t ageIndex, uint32_t cohortSet,
size_t species, size_t genotype, double val )
{
const size_t survey = impl::survNumStat;
storeF.report( val, measure, survey, ageIndex, cohortSet, species, genotype, 0 );
}
void reportStatMHPF( Measure measure, const Host::Human& human, size_t drug, double val ){
const size_t survey = impl::survNumStat;
const size_t ageIndex = human.monAgeGroup().i();
Expand Down
6 changes: 5 additions & 1 deletion model/mon/reporting.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void reportStatMHF( Measure measure, const Host::Human& human, double val );
/// Report some value (floating point) for the current survey and some age
/// group and cohort set
void reportStatMACGF( Measure measure, size_t ageIndex, uint32_t cohortSet,
size_t genotpye, double val );
size_t genotype, double val );
/// Report some value (floating point) for some human and genotype to the current survey.
void reportStatMHGF( Measure measure, const Host::Human& human, size_t genotype,
double val );
Expand All @@ -237,6 +237,10 @@ void reportStatMHPF( Measure measure, const Host::Human& human, size_t drugIndex
void reportStatMSF( Measure measure, size_t species, double val );
/// Report some value (floating point) by genotype to the current survey.
void reportStatMSGF( Measure measure, size_t species, size_t genotype, double val );
/// Report some value (floating point) for the current survey and some age
/// group, cohort set, genotype and vector species
void reportStatMACSGF( Measure measure, size_t ageIndex, uint32_t cohortSet,
size_t species, size_t genotype, double val );

/// Query whether an output measure is used.
/// This function is not fast, so it is recommended to cache the result.
Expand Down
Loading

0 comments on commit 5d0263e

Please sign in to comment.