float Susceptibility::getModAcquire() const
    {
        float susceptibility_correction = 1.0f;

        if(SusceptibilityConfig::maternal_protection && SusceptibilityConfig::susceptibility_type == SusceptibilityType::FRACTIONAL)
        {
            if(SusceptibilityConfig::maternal_protection_type == MaternalProtectionType::LINEAR)
            {
                susceptibility_correction *= SusceptibilityConfig::matlin_slope*age+
                                             SusceptibilityConfig::matlin_suszero;
            }

            else if(SusceptibilityConfig::maternal_protection_type == MaternalProtectionType::SIGMOID)
            {
                susceptibility_correction *= SusceptibilityConfig::matsig_susinit +
                                             (1.0f - SusceptibilityConfig::matsig_susinit)/
                                             (1.0f + exp((SusceptibilityConfig::matsig_halfmax-age)/
                                                           SusceptibilityConfig::matsig_steepfac));
            }
        }

        // Reduces mod_acquire to zero if age is less than calculated immunity failure day.
        if(age < immune_failage)
        {
            susceptibility_correction = 0.0f;
        }

        BOUND_RANGE(susceptibility_correction, 0.0f, 1.0f);

        LOG_VALID_F("id = %d, age = %f, mod_acquire = %f, immune_failage = %f\n", parent->GetSuid().data, age, mod_acquire*susceptibility_correction, immune_failage);

        return mod_acquire * susceptibility_correction;
    }
    void
    ReportEnvironmental::LogIndividualData( IIndividualHuman * individual )
    {
        Report::LogIndividualData( individual );

        if( individual->IsInfected() )
        {
            // Get infection incidence by route
            NewInfectionState::_enum nis = individual->GetNewInfectionState(); 
            LOG_VALID_F( "nis = %d\n", ( nis ) );
            auto mcw = individual->GetMonteCarloWeight();
            if ( nis == NewInfectionState::NewAndDetected ||
                 nis == NewInfectionState::NewInfection /*||
                 nis == NewInfectionState::NewlyDetected*/ )
            {
                auto inf = individual->GetInfections().back();
                StrainIdentity strain;
                inf->GetInfectiousStrainID( &strain );
                if( strain.GetGeneticID() == 0 )
                {
                    enviro_infections_counter += mcw;
                }
                else if( strain.GetGeneticID() == 1 )
                {
                    contact_infections_counter += mcw;
                }
            }
        }
    }
Beispiel #3
0
void VectorSpeciesReport::LogNodeData( Kernel::INodeContext * pNC )
{
    LOG_DEBUG( "VectorSpeciesReport::LogNodeData.\n" );

    int   bin_index = 0;
    Kernel::INodeVector * pNV = nullptr;
    if( pNC->QueryInterface( GET_IID( Kernel::INodeVector ), (void**) &pNV ) != Kernel::s_OK )
    {
        throw Kernel::QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "pNC", "INodeVector", "INodeContext" );
    }

    // reverse order, since push_front is used in NodeVector::SetVectorPopulations(), why??
    const VectorPopulationReportingList_t& population_list = pNV->GetVectorPopulationReporting();
    for (auto iterator = population_list.rbegin(); iterator != population_list.rend(); iterator++)
    {
        const auto vectorpopulation = *iterator;
        LOG_VALID_F( "bin_index = %d \t species name = %s\n", bin_index, vectorpopulation->get_SpeciesID().c_str() );
        adult_vectors[bin_index]      += (float)( vectorpopulation->getAdultCount() + vectorpopulation->getInfectedCount() + vectorpopulation->getInfectiousCount() );
        infectious_vectors[bin_index] += (float)( vectorpopulation->getInfectiousCount() );
        daily_eir[bin_index]          +=          vectorpopulation->GetEIRByPool(Kernel::VectorPoolIdEnum::BOTH_VECTOR_POOLS);
        daily_hbr[bin_index]          +=          vectorpopulation->GetHBRByPool(Kernel::VectorPoolIdEnum::BOTH_VECTOR_POOLS);
        bin_index++;
    }
}
    void SusceptibilityTyphoid::Update(float dt)
    {
        age += dt; // tracks age for immune purposes
        // if cross N year age boundary

        //end of maternal antibodies at 6 months
        float age_boundary = 0.5f * DAYSPERYEAR;
        if( ( age >= age_boundary ) && ( ( age - dt ) < age_boundary ) && ( mod_acquire == 0 ) )
        {
            if( parent->GetRng()->SmartDraw( IndividualHumanTyphoidConfig::typhoid_6month_susceptible_fraction ) )
            {
                LOG_DEBUG_F("id %lu 6-month old being made susceptible.\n", parent->GetSuid().data);
                mod_acquire = 1.0f;
            }
        }

        float age_boundary_2 = 3 * DAYSPERYEAR;
        if( ( age >= age_boundary_2 ) && ( ( age - dt ) < age_boundary_2 ) && ( mod_acquire == 0 ) )
        {
            if( parent->GetRng()->SmartDraw( IndividualHumanTyphoidConfig::typhoid_3year_susceptible_fraction ) )
            {
                LOG_DEBUG_F("id %lu 3-yo being made susceptible.\n", parent->GetSuid().data);
                mod_acquire = 1.0f;
            }
        }

        float age_boundary_3 = 6 * DAYSPERYEAR;
        if( ( age >= age_boundary_3 ) && ( ( age - dt ) < age_boundary_3 ) && ( mod_acquire == 0 ) )
        {
            if( parent->GetRng()->SmartDraw( IndividualHumanTyphoidConfig::typhoid_6year_susceptible_fraction ) )
            {
                LOG_DEBUG_F("id %lu 6-yo being made susceptible.\n", parent->GetSuid().data);
                mod_acquire = 1.0f;
            }
        } 

#define SUSPCEPT_INTRO_YEAR (20)
#define LAMBDA_THRESHOLD (1000)
        if (IndividualHumanTyphoidConfig::typhoid_exposure_lambda < LAMBDA_THRESHOLD )
        {
            float twenty_years_old_days = SUSPCEPT_INTRO_YEAR*DAYSPERYEAR;
            if( ( age < twenty_years_old_days ) && mod_acquire == 0 )
            {
                double perc = 0.0f;
                double perc1 = 0.0f;
                double perc2 = 0.0f;
                double num = 0.0f;
                double denom = 0.0f;
                float lambda = IndividualHumanTyphoidConfig::typhoid_exposure_lambda; 

                perc2 = 1.0f - ((twenty_years_old_days - age) / (age*lambda + twenty_years_old_days ));
                perc1 = 1.0f - ((twenty_years_old_days - (age-1)) / ((age-1)*lambda + twenty_years_old_days ));
                perc = (perc2 - perc1) / (1 - perc1);

                if( parent->GetRng()->SmartDraw( perc ) )
                {
                    mod_acquire = 1.0f;
                    LOG_VALID_F("id %lu , age %f being made susceptible.\n", parent->GetSuid().data, age);
                    //LOG_INFO_F("SUSCEPTIBLE %f %f\n", perc, mod_acquire);
                }
            } 
        }

        float intro_year = 10; // magic number?
        if (IndividualHumanTyphoidConfig::typhoid_exposure_lambda < LAMBDA_THRESHOLD )
        {
            intro_year = SUSPCEPT_INTRO_YEAR;
        }
        float age_boundary_4 = intro_year * DAYSPERYEAR;
        if (age >= age_boundary_4 && age - dt < age_boundary_4 && mod_acquire == 0)
        {
            LOG_DEBUG_F("id %lu Schoolkids being made susceptible.\n", parent->GetSuid().data);
            mod_acquire = 1.0f;
        } 

        if( ( age > age_boundary_4 + dt ) && ( mod_acquire == 0 ) )
        {
            LOG_INFO_F("SOMEONE WAS MISSED AGE %f CUTOFF DAY %f MODACQUIRE %f\n", age, age_boundary_4 + dt, mod_acquire);
        }
    }