Пример #1
0
    bool
    CampaignEventByYear::Configure(
        const Configuration * inputJson
    )
    {
        if( !JsonConfigurable::_dryrun &&
#ifdef ENABLE_TYPHOID
            (GET_CONFIGURABLE( SimulationConfig )->sim_type != SimType::TYPHOID_SIM) &&
#endif
            (GET_CONFIGURABLE( SimulationConfig )->sim_type != SimType::STI_SIM) &&
            (GET_CONFIGURABLE( SimulationConfig )->sim_type != SimType::HIV_SIM) )
        {
            throw IllegalOperationException( __FILE__, __LINE__, __FUNCTION__, "CampainEventByYear can only be used in STI and HIV simulations." );
        }

        float start_year;
        initConfigTypeMap( "Start_Year", &start_year, Start_Year_DESC_TEXT, MIN_YEAR, MAX_YEAR, MIN_YEAR );
        initConfigComplexType( "Nodeset_Config", &nodeset_config, Nodeset_Config_DESC_TEXT );
        initConfigComplexType( "Event_Coordinator_Config", &event_coordinator_config, Event_Coordinator_Config_DESC_TEXT );

        // Bypasss CampaignEvent base class so that we don't break without Start_Day!
        bool ret = JsonConfigurable::Configure( inputJson );
        if( Simulation::base_year > 0 )
        { 
            start_day = (start_year - Simulation::base_year) * DAYSPERYEAR; 
        }
        return ret;
    }
Пример #2
0
    void
    SimulationSTI::Reports_CreateBuiltIn()
    {
        Simulation::Reports_CreateBuiltIn();

        // ---------------------------------------------------------------------------
        // --- We check the simulation type here because this method could be called
        // --- from a subclass like SimulationHIV.  SimulationHIV will only be calling
        // --- this if the simulation type is HIV_SIM
        // ---------------------------------------------------------------------------
        if (report_relationship_start && (GET_CONFIGURABLE( SimulationConfig )->sim_type == SimType::STI_SIM))
        {
            LOG_INFO( "Using STI RelationshipStartReporter.\n" );
            reports.push_back(StiObjectFactory::CreateRelationshipStartReporter(this));
        }

        if (report_relationship_end)
        {
            LOG_INFO( "Using STI RelationshipEndReporter.\n" );
            reports.push_back(StiObjectFactory::CreateRelationshipEndReporter(this));
        }

        if (report_relationship_consummated)
        {
            LOG_INFO( "Using STI RelationshipConsummatedReporter.\n" );
            reports.push_back(StiObjectFactory::CreateRelationshipConsummatedReporter(this));
        }

        if (report_transmission && (GET_CONFIGURABLE( SimulationConfig )->sim_type == SimType::STI_SIM))
        {
            LOG_INFO( "Using STI TransmissionReporter.\n" );
            reports.push_back(StiObjectFactory::CreateTransmissionReporter(this));
        }

    }
    bool
    ReferenceTrackingEventCoordinator::Configure(
        const Configuration * inputJson
    )
    {
        if( !JsonConfigurable::_dryrun &&
#ifdef ENABLE_TYPHOID
            (GET_CONFIGURABLE( SimulationConfig )->sim_type != SimType::TYPHOID_SIM) &&
#endif
            (GET_CONFIGURABLE( SimulationConfig )->sim_type != SimType::STI_SIM) &&
            (GET_CONFIGURABLE( SimulationConfig )->sim_type != SimType::HIV_SIM) )
        {
            throw IllegalOperationException( __FILE__, __LINE__, __FUNCTION__, "ReferenceTrackingEventCoordinator can only be used in STI, HIV, and TYPHOID simulations." );
        }

        float update_period = DAYSPERYEAR;
        initConfigComplexType("Time_Value_Map", &year2ValueMap, RTEC_Time_Value_Map_DESC_TEXT );
        initConfigTypeMap(    "Update_Period",  &update_period, RTEC_Update_Period_DESC_TEXT, 1.0,      10*DAYSPERYEAR, DAYSPERYEAR );
        initConfigTypeMap(    "End_Year",       &end_year,      RTEC_End_Year_DESC_TEXT,      MIN_YEAR, MAX_YEAR,       MAX_YEAR );

        auto ret = StandardInterventionDistributionEventCoordinator::Configure( inputJson );
        num_repetitions = -1; // unlimited
        if( JsonConfigurable::_dryrun == false )
        {
            float dt = GET_CONFIGURABLE(SimulationConfig)->Sim_Tstep;
            tsteps_between_reps = update_period/dt; // this won't be precise, depending on math.
            if( tsteps_between_reps <= 0.0 )
            {
                // don't let this be zero or it will only update one time
                tsteps_between_reps = 1;
            }
        }
        LOG_DEBUG_F( "ReferenceTrackingEventCoordinator configured with update_period = %f, end_year = %f, and tsteps_between_reps (derived) = %d.\n", update_period, end_year, tsteps_between_reps );
        return ret;
    }
Пример #4
0
 const SimulationConfig*
 IndividualHumanMalaria::params()
 const
 {
     return GET_CONFIGURABLE(SimulationConfig);
 }
Пример #5
0
 bool  IndividualHumanMalaria::HasFever() const
 {
     return malaria_susceptibility->get_fever() > GET_CONFIGURABLE(SimulationConfig)->feverDetectionThreshold;
 }
 const SimulationConfig* SusceptibilityVector::params()
 {
     return GET_CONFIGURABLE(SimulationConfig);
 }
 const SimulationConfig* Susceptibility::params()
 {
     return GET_CONFIGURABLE(SimulationConfig);
     //return base_flags_ptr;
 }
Пример #8
0
    void VectorInterventionsContainer::Update(float dt)
    {
        // TODO: Re-implement policy of 1 intervention of each type w/o
        // knowing a priori about any intervention types. Current favorite
        // idea is for interventions to enforce this in the Give by doing a
        // Get and Remove first via QI. 
        p_block_net = 0;
        p_kill_ITN = 0;
        p_penetrate_housingmod = 1.0;   // block probability of housing: screening, spatial repellent, IRS repellent-- starts at 1.0 because will do 1.0-p_block_housing below
        p_kill_IRSprefeed = 0;   // pre-feed kill probability of IRS (TODO: this is not hooked up!)
        p_kill_IRSpostfeed = 0;  // probability of IRS killing postfeed
        p_block_indrep = 0;      // probability of individual repellent blocking a feed
        p_kill_indrep = 0;       // probability of individual repellent killing post feed (not used yet)
        p_kill_PFH = 0;          // kill probability of house photonic fence
        p_attraction_ADIH = 0;   // probability of distraction by Artificial Diet--In House
        p_kill_ADIH = 0;         // kill probability of in-house artificial diet
        p_survive_insecticidal_drug = 1.0; // post-feed kill probability of insecticidal drug (e.g. Ivermectin)-- starts at 1.0 because will do 1.0-p_kill below

        float p_dieduringfeeding = GET_CONFIGURABLE(SimulationConfig)->vector_params->human_feeding_mortality;

        // call base level
        InterventionsContainer::Update(dt);

        // final adjustment to product of (1-prob) accumulated over potentially multiple instances
        float p_block_housing = 1.0f - p_penetrate_housingmod;
        float p_kill_insecticidal_drug = 1.0f - p_survive_insecticidal_drug;
        release_assert( GET_CONFIGURABLE(SimulationConfig) );
        release_assert( GET_CONFIGURABLE(SimulationConfig)->vector_params );
        if( GET_CONFIGURABLE(SimulationConfig)->vector_params->vector_species_names.size() == 0 )
        {
            return;
        }
        std::string species_name = (*GET_CONFIGURABLE(SimulationConfig)->vector_params->vector_species_names.begin());
        auto m_species_params = GET_CONFIGURABLE(SimulationConfig)->vector_params->vspMap.at( species_name );

        float nighttime_feeding = m_species_params->nighttime_feeding; //1.0f;  //@@@

        // range fix
        if(p_block_housing < 0) p_block_housing = 0;
        if(p_kill_insecticidal_drug < 0) p_kill_insecticidal_drug = 0;

        // adjust indoor post-feed kill to include combined probability of IRS & insectidical drug

        // Reach back into owning individual's owning node's event context to see if there's a node-wide IRS intervention
        IIndividualHumanContext* parent = GetParent();
        IIndividualHuman* human = nullptr;
        if (s_OK != parent->QueryInterface(GET_IID(IIndividualHuman), (void**)&human)) {
            throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent", "IIndividualHuman", "IIndividualHumanContext" );
        }
        INodeContext* node = human->GetParent();
        INodeEventContext* context = node->GetEventContext();
        INodeVectorInterventionEffects* effects = nullptr;
        if (s_OK != context->QueryInterface(GET_IID(INodeVectorInterventionEffects), (void**)&effects)) {
            throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "context", "INodeVectorInterventionEffects", "INodeEventContext" );
        }
        float p_kill_IRSpostfeed_node = effects->GetIndoorKilling();
        // Node-wide IRS intervention overrides individual intervention
        if ( (p_kill_IRSpostfeed > 0.0f) && (p_kill_IRSpostfeed_node > 0.0f) ) {
            LOG_WARN_F( "%s: Both node and individual have an IRS intervention. Node killing rate will be used.\n", __FUNCTION__ );
        }
        float p_kill_IRSpostfeed_effective = (p_kill_IRSpostfeed_node > 0) ? p_kill_IRSpostfeed_node : p_kill_IRSpostfeed;
#if 0
        // Someday
        effects->Release();
        effects = nullptr;
        human->Release();
        human = nullptr;
#endif

        p_kill_IRSpostfeed_effective = 1.0f - ((1.0f-p_kill_IRSpostfeed_effective)*(1.0f-p_kill_insecticidal_drug));

        // now get probabilities for indoor feeding outcomes
        pDieBeforeFeeding    = p_kill_PFH+(1-p_kill_PFH)*(1-p_block_housing)*(p_kill_IRSprefeed+(1-p_kill_IRSprefeed)*(p_attraction_ADIH*(p_kill_ADIH+(1-p_kill_ADIH)*(p_kill_IRSpostfeed_effective+(1-p_kill_IRSpostfeed_effective)*p_kill_PFH))+(1-p_attraction_ADIH)*(p_block_net*((1-p_kill_ITN*nighttime_feeding)*p_kill_PFH+p_kill_ITN*nighttime_feeding)+(1.0f-p_block_net)*p_block_indrep*p_kill_PFH)));
        pHostNotAvailable    = (1-p_kill_PFH)*(p_block_housing+(1-p_block_housing)*(1-p_kill_IRSprefeed)*(1-p_attraction_ADIH)*(p_block_net*(1-p_kill_ITN*nighttime_feeding)*(1-p_kill_PFH)+(1.0f-p_block_net)*p_block_indrep*(1.0f-p_kill_PFH)));
        pDieDuringFeeding    = (1-p_kill_PFH)*(1-p_block_housing)*(1-p_kill_IRSprefeed) *(1-p_attraction_ADIH)*(1-p_block_net)*(1-p_block_indrep)*p_dieduringfeeding;
        pDiePostFeeding      = (1-p_kill_PFH)*(1-p_block_housing)*(1-p_kill_IRSprefeed) *(1-p_attraction_ADIH) *(1-p_block_net)*(1-p_block_indrep)*(1-p_dieduringfeeding)*(p_kill_IRSpostfeed_effective+(1-p_kill_IRSpostfeed_effective)*p_kill_PFH);
        pSuccessfulFeedHuman = (1-p_kill_PFH)*(1-p_block_housing)*(1-p_kill_IRSprefeed) *(1-p_attraction_ADIH) *(1-p_block_net)*(1-p_block_indrep)* (1-p_dieduringfeeding)*(1-p_kill_IRSpostfeed_effective)*(1-p_kill_PFH);
        pSuccessfulFeedAD    = (1-p_kill_PFH)*(1-p_block_housing)*(1-p_kill_IRSprefeed)*p_attraction_ADIH*(1-p_kill_ADIH)*(1-p_kill_IRSpostfeed_effective)*(1-p_kill_PFH);

        //update intervention effect on acquisition and transmission of infection--NOTE that vector tendencies to bite an individual are already gathered into intervention_system_effects
        //gets infection for dies during feeding, dies post feeding, or successful feed, but NOT die before feeding or unable to find host
        blockIndoorVectorAcquire = pDieDuringFeeding + pDiePostFeeding + pSuccessfulFeedHuman;

        // transmission to mosquito only in case of survived feed
        blockIndoorVectorTransmit = pSuccessfulFeedHuman;

        // update probabilities for outdoor feeding outcomes
        pOutdoorDieBeforeFeeding    = 0;
        pOutdoorHostNotAvailable    = p_block_indrep;
        pOutdoorDieDuringFeeding    = ( 1.0f - p_block_indrep ) * p_dieduringfeeding;
        pOutdoorDiePostFeeding      = ( 1.0f - p_block_indrep ) * ( 1.0f - p_dieduringfeeding ) * p_kill_insecticidal_drug;
        pOutdoorSuccessfulFeedHuman = ( 1.0f - p_block_indrep ) * ( 1.0f - p_dieduringfeeding ) * ( 1.0f - p_kill_insecticidal_drug );
        blockOutdoorVectorAcquire   = pOutdoorDieDuringFeeding + pOutdoorDiePostFeeding + pOutdoorSuccessfulFeedHuman;
        blockOutdoorVectorTransmit  = pOutdoorSuccessfulFeedHuman;
    }
Пример #9
0
    bool NodeSTI::Configure( const Configuration* config )
    {
        // A PFA burnin of at least 1 day is required to ensure transmission
        initConfigTypeMap( "PFA_Burnin_Duration_In_Days", &pfa_burnin_duration, PFA_Burnin_Duration_In_Days_DESC_TEXT, 1, FLT_MAX, 1000 * DAYSPERYEAR );

        bool ret = society->Configure( config );
        if( ret )
        {
            ret = Node::Configure( config );
        }

        if( ret &&
            !JsonConfigurable::_dryrun &&
            (ind_sampling_type != IndSamplingType::TRACK_ALL     ) &&
            (ind_sampling_type != IndSamplingType::FIXED_SAMPLING) )
        {
            throw IncoherentConfigurationException( __FILE__, __LINE__, __FUNCTION__,
                                                    "Individual_Sampling_Type", IndSamplingType::pairs::lookup_key(ind_sampling_type),
                                                    "Simulation_Type", SimType::pairs::lookup_key( GET_CONFIGURABLE( SimulationConfig )->sim_type ),
                                                    "Relationship-based transmission network only works with 100% sampling."
                                                    );
        }

        return ret ;
    }
Пример #10
0
 void NodeSTI::SetMonteCarloParameters(float indsamplerate, int nummininf)
 {
     if( indsamplerate != 1.0f )
     {
         throw IncoherentConfigurationException( __FILE__, __LINE__, __FUNCTION__,
                                                "Base_Individual_Sampling_Rate", std::to_string( indsamplerate ).c_str(),
                                                "Simulation_Type", SimType::pairs::lookup_key( GET_CONFIGURABLE( SimulationConfig )->sim_type ),
                                                "Relationship-based transmission network only works with 100% sampling."
                                               );
     }
     return Node::SetMonteCarloParameters( indsamplerate, nummininf );
 }
Пример #11
0
 const SimulationConfig* Infection::params() { return GET_CONFIGURABLE(SimulationConfig); } // overridden in derived classes but with different return types to hide the casting operation