Skip to content

Commit

Permalink
Merge pull request #199 from SwissTPH/name-cleanup
Browse files Browse the repository at this point in the history
Name cleanup
  • Loading branch information
dhardy authored Apr 16, 2018
2 parents a46eaab + 942492b commit 051d2a0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ set (Model_CPP
#Transmission/Anopheles/LCEmergence.cpp
#Transmission/Anopheles/LifeCycle.cpp
#Transmission/Anopheles/ResourceFitter.cpp
Transmission/Anopheles/PerHost.cpp
Transmission/Anopheles/PerHostAnoph.cpp

WithinHost/WHInterface.cpp
WithinHost/WHFalciparum.cpp
Expand Down
6 changes: 3 additions & 3 deletions model/Transmission/Anopheles/AnophelesModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define Hmod_AnophelesModel

#include "Global.h"
#include "Transmission/Anopheles/PerHost.h"
#include "Transmission/Anopheles/PerHostAnoph.h"
#include "Transmission/PerHost.h"
#include "Transmission/Anopheles/MosqTransmission.h"
#include "Transmission/Anopheles/FixedEmergence.h"
Expand Down Expand Up @@ -126,7 +126,7 @@ class AnophelesModel
void initVectorTrap( const scnXml::Description1& desc, size_t instance );

/** Return base-line human parameters for the mosquito. */
inline const Anopheles::PerHostBase& getHumanBaseParams () {
inline const PerHostAnophParams& getHumanBaseParams () {
return humanBase;
}

Expand Down Expand Up @@ -261,7 +261,7 @@ class AnophelesModel
* descriptions.
*
* Read from XML by initialise; no need to checkpoint. */
Anopheles::PerHostBase humanBase;
PerHostAnophParams humanBase;


/** Duration of host-seeking per day; the maximum fraction of a day that a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "Transmission/Anopheles/PerHost.h"
#include "Transmission/Anopheles/PerHostAnoph.h"
#include "util/errors.h"

namespace OM {
Expand All @@ -27,14 +27,14 @@ namespace Anopheles {

// ----- Per host, per species, non-static -----

void PerHost::initialise (const PerHostBase& base, double availabilityFactor)
void PerHostAnoph::initialise (const PerHostAnophParams& base, double availabilityFactor)
{
entoAvailability = base.entoAvailability.sample() * availabilityFactor;
probMosqBiting = base.probMosqBiting.sample();
probMosqRest = base.probMosqFindRestSite.sample() * base.probMosqSurvivalResting.sample();
}

void PerHostBase::operator =(const scnXml::Mosq& mosq)
void PerHostAnophParams::operator =(const scnXml::Mosq& mosq)
{
entoAvailability.setParams( numeric_limits<double>::quiet_NaN(),
mosq.getAvailabilityVariance().getValue() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Anopheles {
* mosquito species: intervention descriptions and model parameters.
*
* Parameters are read from XML, and the availability rate is adjusted. */
class PerHostBase {
class PerHostAnophParams {
public:
/** Set parameters from an XML element. */
void operator= (const scnXml::Mosq& mosq);
Expand Down Expand Up @@ -68,12 +68,12 @@ class PerHostBase {
};

/** Data needed for each human which is per-mosquito species. */
class PerHost
class PerHostAnoph
{
public:
/** In lieu of a constructor initialises elements, using the passed base to
* get baseline parameters. */
void initialise (const PerHostBase& base, double availabilityFactor);
void initialise (const PerHostAnophParams& base, double availabilityFactor);

/// Checkpointing
template<class S>
Expand Down
9 changes: 5 additions & 4 deletions model/Transmission/PerHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

#include "Transmission/PerHost.h"
#include "Transmission/VectorModel.h"
#include "Transmission/Anopheles/PerHost.h"
#include "Transmission/Anopheles/PerHostAnoph.h"
#include "interventions/InterventionManager.hpp"
#include "util/errors.h"
#include "util/checkpoint.h"

namespace OM {
namespace Transmission {
using namespace OM::util;
using Anopheles::PerHostAnophParams;

// ----- PerHost static -----

Expand Down Expand Up @@ -80,22 +81,22 @@ void PerHost::deployComponent( const HumanVectorInterventionComponent& params ){
// (easily large enough for conceivable Weibull params that the value is 0.0 when
// rounded to a double. Performance-wise it's perhaps slightly slower than using
// an if() when interventions aren't present.
double PerHost::entoAvailabilityHetVecItv (const Anopheles::PerHostBase& base,
double PerHost::entoAvailabilityHetVecItv (const PerHostAnophParams& base,
size_t speciesIndex) const {
double alpha_i = species[speciesIndex].getEntoAvailability();
for( ListActiveComponents::const_iterator it = activeComponents.begin(); it != activeComponents.end(); ++it ){
alpha_i *= it->relativeAttractiveness( speciesIndex );
}
return alpha_i;
}
double PerHost::probMosqBiting (const Anopheles::PerHostBase& base, size_t speciesIndex) const {
double PerHost::probMosqBiting (const PerHostAnophParams& base, size_t speciesIndex) const {
double P_B_i = species[speciesIndex].getProbMosqBiting();
for( ListActiveComponents::const_iterator it = activeComponents.begin(); it != activeComponents.end(); ++it ){
P_B_i *= it->preprandialSurvivalFactor( speciesIndex );
}
return P_B_i;
}
double PerHost::probMosqResting (const Anopheles::PerHostBase& base, size_t speciesIndex) const {
double PerHost::probMosqResting (const PerHostAnophParams& base, size_t speciesIndex) const {
double pRest = species[speciesIndex].getProbMosqRest();
for( ListActiveComponents::const_iterator it = activeComponents.begin(); it != activeComponents.end(); ++it ){
pRest *= it->postprandialSurvivalFactor( speciesIndex );
Expand Down
16 changes: 9 additions & 7 deletions model/Transmission/PerHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define Hmod_PerHost

#include "Global.h"
#include "Transmission/Anopheles/PerHost.h"
#include "Transmission/Anopheles/PerHostAnoph.h"
#include "interventions/Interfaces.hpp"
#include "util/AgeGroupInterpolation.h"
#include "util/DecayFunction.h"
Expand All @@ -33,6 +33,8 @@
namespace OM {
namespace Transmission {

using Anopheles::PerHostAnophParams;
using Anopheles::PerHostAnoph;
using util::AgeGroupInterpolator;
using util::DecayFunction;
using util::DecayFuncHet;
Expand Down Expand Up @@ -200,7 +202,7 @@ class PerHost
* rate factors.)
*
* Assume mean is human-to-vector availability rate factor. */
double entoAvailabilityHetVecItv( const Anopheles::PerHostBase& base, size_t speciesIndex ) const;
double entoAvailabilityHetVecItv( const PerHostAnophParams& base, size_t speciesIndex ) const;

/** Availability rate of human to mosquitoes (α_i). Equals
* entoAvailabilityHetVecItv()*getRelativeAvailability().
Expand All @@ -210,7 +212,7 @@ class PerHost
* by the average availability of the population, which was incorrectly done
* in the past. */
inline double entoAvailabilityFull (
const Anopheles::PerHostBase& base,
const PerHostAnophParams& base,
size_t speciesIndex,
double ageYears
) const {
Expand All @@ -222,10 +224,10 @@ class PerHost
///@brief Get effects of interventions pre/post biting
//@{
/** Probability of a mosquito succesfully biting a host (P_B_i). */
double probMosqBiting (const Anopheles::PerHostBase& base, size_t speciesIndex) const;
double probMosqBiting (const PerHostAnophParams& base, size_t speciesIndex) const;
/** Probability of a mosquito succesfully finding a resting
* place after biting and then resting (P_C_i * P_D_i). */
double probMosqResting (const Anopheles::PerHostBase& base, size_t speciesIndex) const;
double probMosqResting (const PerHostAnophParams& base, size_t speciesIndex) const;
/** Multiplicative factor for the number of fertile eggs laid by mosquitoes
* after feeding on this host. Should be 1 normally, less than 1 to reduce
* fertility, greater than 1 to increase. */
Expand All @@ -235,7 +237,7 @@ class PerHost
///@brief Convenience wrappers around several functions
//@{
/// entoAvailabilityHetVecItv * probMosqBiting
inline double availBite (const Anopheles::PerHostBase& base, size_t speciesIndex) const{
inline double availBite (const PerHostAnophParams& base, size_t speciesIndex) const{
return entoAvailabilityHetVecItv(base, speciesIndex) *
probMosqBiting(base, speciesIndex);
}
Expand Down Expand Up @@ -269,7 +271,7 @@ class PerHost
void checkpointIntervs( ostream& stream );
void checkpointIntervs( istream& stream );

vector<Anopheles::PerHost> species;
vector<PerHostAnoph> species;

// Determines whether human is outside transmission
bool outsideTransmission;
Expand Down
11 changes: 6 additions & 5 deletions model/Transmission/VectorModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
namespace OM {
namespace Transmission {
using namespace OM::util;
using Anopheles::PerHostAnophParams;

void VectorModel::ctsCbN_v0 (ostream& stream) {
for(size_t i = 0; i < numSpecies; ++i)
Expand Down Expand Up @@ -67,7 +68,7 @@ void VectorModel::ctsCbS_v (ostream& stream) {
}
void VectorModel::ctsCbAlpha (const Population& population, ostream& stream){
for( size_t i = 0; i < numSpecies; ++i){
const Anopheles::PerHostBase& params = species[i].getHumanBaseParams();
const PerHostAnophParams& params = species[i].getHumanBaseParams();
double total = 0.0;
for(Population::ConstIter iter = population.cbegin(); iter != population.cend(); ++iter) {
total += iter->perHostTransmission.entoAvailabilityFull( params, i, iter->age(sim::now()).inYears() );
Expand All @@ -77,7 +78,7 @@ void VectorModel::ctsCbAlpha (const Population& population, ostream& stream){
}
void VectorModel::ctsCbP_B (const Population& population, ostream& stream){
for( size_t i = 0; i < numSpecies; ++i){
const Anopheles::PerHostBase& params = species[i].getHumanBaseParams();
const PerHostAnophParams& params = species[i].getHumanBaseParams();
double total = 0.0;
for(Population::ConstIter iter = population.cbegin(); iter != population.cend(); ++iter) {
total += iter->perHostTransmission.probMosqBiting( params, i );
Expand All @@ -87,7 +88,7 @@ void VectorModel::ctsCbP_B (const Population& population, ostream& stream){
}
void VectorModel::ctsCbP_CD (const Population& population, ostream& stream){
for( size_t i = 0; i < numSpecies; ++i){
const Anopheles::PerHostBase& params = species[i].getHumanBaseParams();
const PerHostAnophParams& params = species[i].getHumanBaseParams();
double total = 0.0;
for(Population::ConstIter iter = population.cbegin(); iter != population.cend(); ++iter) {
total += iter->perHostTransmission.probMosqResting( params, i );
Expand Down Expand Up @@ -270,7 +271,7 @@ void VectorModel::init2 () {
double sigma_df = 0.0;
double sigma_dff = 0.0;

const Anopheles::PerHostBase& humanBase = species[i].getHumanBaseParams();
const PerHostAnophParams& humanBase = species[i].getHumanBaseParams();
foreach(const Host::Human& human, sim::humanPop().crange()) {
const OM::Transmission::PerHost& host = human.perHostTransmission;
double prod = host.entoAvailabilityFull (humanBase, i, human.age(sim::now()).inYears());
Expand Down Expand Up @@ -458,7 +459,7 @@ void VectorModel::vectorUpdate () {
saved_sigma_dif.assign_at1(popDataInd, 0.0);
vector<double> sigma_dff(numSpecies, 0.0);

vector<const Anopheles::PerHostBase*> humanBases;
vector<const PerHostAnophParams*> humanBases;
humanBases.reserve( numSpecies );
for(size_t s = 0; s < numSpecies; ++s){
humanBases.push_back( &species[s].getHumanBaseParams() );
Expand Down

0 comments on commit 051d2a0

Please sign in to comment.