예제 #1
0
파일: Outbreak.cpp 프로젝트: clorton/EMOD
 Outbreak::Outbreak() : import_age(DAYSPERYEAR)
 {
     initSimTypes( 11, "GENERIC_SIM" , "VECTOR_SIM" , "MALARIA_SIM", "AIRBORNE_SIM", "POLIO_SIM", "TB_SIM", "TBHIV_SIM", "STI_SIM", "HIV_SIM", "PY_SIM", "TYPHOID_SIM" );
     initConfigTypeMap( "Antigen", &antigen, Antigen_DESC_TEXT, 0, 10, 0 );
     initConfigTypeMap( "Genome",  &genome,  Genome_DESC_TEXT, -1, 16777216, 0 );
     initConfigTypeMap( "Incubation_Period_Override", &incubation_period_override, Incubation_Period_Override_DESC_TEXT,-1, INT_MAX, -1);
 }
예제 #2
0
    bool ImportPressure::Configure( const Configuration * inputJson )
    {
        LOG_DEBUG_F( "%s\n", __FUNCTION__ );
        // TODO: specification for rate, seasonality, and age-biting function
        initConfigTypeMap( "Durations",              &durations,              IP_Durations_DESC_TEXT,               0, INT_MAX, 1 );
        initConfigTypeMap( "Daily_Import_Pressures", &daily_import_pressures, IP_Daily_Import_Pressures_DESC_TEXT , 0, FLT_MAX, 0 );

        bool configured = Outbreak::Configure( inputJson );

        if( configured && !JsonConfigurable::_dryrun )
        {
            if( durations.size() != (daily_import_pressures.size()) )
            {
                throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__,
                    "ImportPressure intervention requires Durations must be the same size as Daily_Import_Pressures" );
            }
            if( durations.size() <= 0 )
            {
                throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__,
                    "Empty Durations parameter in ImportPressure intervention." );
            }
            ConstructDistributionCalendar();
        }
        return configured;
    }
    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
파일: Drugs.cpp 프로젝트: clorton/EMOD
    bool
    GenericDrug::Configure(
        const Configuration * inputJson
    )
    {
        initConfigTypeMap("Primary_Decay_Time_Constant", &fast_decay_time_constant, DRUG_Primary_Decay_Time_Constant_DESC_TEXT, 0, 999999);
        initConfigTypeMap("Remaining_Doses", &remaining_doses, DRUG_Remaining_Doses_DESC_TEXT, -1, 999999);
        initConfigTypeMap("Dose_Interval", &time_between_doses, DRUG_Dose_Interval_DESC_TEXT, 0.0f, 99999.0f, 1.0f);
        initConfigTypeMap("Cost_To_Consumer", &cost_per_unit, DRUG_Cost_To_Consumer_DESC_TEXT, 0, 99999);
        initConfigTypeMap("Fraction_Defaulters", &fraction_defaulters, DRUG_Fraction_Defaulters_DESC_TEXT, 0.0f, 1.0f, 0.0f);

        initConfig( "Durability_Profile", durability_time_profile, inputJson, MetadataDescriptor::Enum("Durability_Profile", DRUG_Durability_Profile_DESC_TEXT, MDD_ENUM_ARGS(PKPDModel)) );
        if (durability_time_profile == PKPDModel::CONCENTRATION_VERSUS_TIME || JsonConfigurable::_dryrun)
        {
            initConfigTypeMap("Secondary_Decay_Time_Constant", &slow_decay_time_constant, DRUG_Secondary_Decay_Time_Constant_DESC_TEXT, 0, 999999);
            initConfigTypeMap("Drug_CMax", &Cmax, DRUG_Drug_CMax_DESC_TEXT, 0, 10000);
            initConfigTypeMap("Drug_Vd", &Vd, DRUG_Drug_Vd_DESC_TEXT, 0, 10000);
            initConfigTypeMap("Drug_PKPD_C50", &drug_c50, DRUG_Drug_PKPD_C50_DESC_TEXT, 0, 5000);
        }

        bool configured = BaseIntervention::Configure( inputJson );

        PkPdParameterValidation();

        return configured;
    }
예제 #5
0
    bool ConcurrencyByProperty::Configure( const ::Configuration *json )
    {
        initConfigTypeMap( "Prob_Extra_Relationship_Male",   &m_ProbExtraRelsMale,   STI_Prob_Extra_Relationship_Male_DESC_TEXT,   0.0, 1.0f, 0.0f );
        initConfigTypeMap( "Prob_Extra_Relationship_Female", &m_ProbExtraRelsFemale, STI_Prob_Extra_Relationship_Female_DESC_TEXT, 0.0, 1.0f, 0.0f );

        initConfigTypeMap( "Max_Simultaneous_Relationships_Male",   &m_MaxSimultaneiousRelsMale,   STI_Max_Simultaneous_Relationships_Male_DESC_TEXT,   0, MAX_SLOTS, 1 );
        initConfigTypeMap( "Max_Simultaneous_Relationships_Female", &m_MaxSimultaneiousRelsFemale, STI_Max_Simultaneous_Relationships_Female_DESC_TEXT, 0, MAX_SLOTS, 1 );

        bool ret = JsonConfigurable::Configure( json );
        return ret;
    }
예제 #6
0
파일: Outbreak.cpp 프로젝트: clorton/EMOD
 bool
 Outbreak::Configure(
     const Configuration * inputJson
 )
 {
     initConfigTypeMap( "Number_Cases_Per_Node",  &num_cases_per_node,  Num_Import_Cases_Per_Node_DESC_TEXT, 0, INT_MAX, 1 );
     initConfigTypeMap( "Import_Age", &import_age, Import_Age_DESC_TEXT, 0, MAX_INDIVIDUAL_AGE_IN_YRS*DAYSPERYEAR, DAYSPERYEAR );
     
     JsonConfigurable::Configure( inputJson );
     return true;
 }
예제 #7
0
    bool SocietyImpl::Configure(const Configuration *config)
    {
        // -------------------------------
        // --- Parameters from config.json
        // -------------------------------
        initConfigTypeMap( "Extra_Relational_Rate_Ratio_Male",      &extra_relational_rate_ratio_male, PFA_Extra_Relational_Rate_Ratio_Male_DESC_TEXT, 1.0, FLT_MAX, 1.0f );
        initConfigTypeMap( "Extra_Relational_Rate_Ratio_Female",    &extra_relational_rate_ratio_female, PFA_Extra_Relational_Rate_Ratio_Female_DESC_TEXT, 1.0, FLT_MAX, 1.0f );
        initConfigTypeMap( "PFA_Cum_Prob_Selection_Threshold",      &pfa_selection_threshold, PFA_Cum_Prob_Selection_Threshold_DESC_TEXT, 0.0f, 1.0f, 0.2f );

        bool ret = JsonConfigurable::Configure( config );
        return ret ;
    }
 bool
 ClimateByData::Configure(
     const Configuration* config
 )
 {
     LOG_DEBUG( "Configure\n" );
     initConfigTypeMap( "Air_Temperature_Offset", &airtemperature_offset, Air_Temperature_Offset_DESC_TEXT, -20.0f, 20.0f, 0.0f, "Climate_Model","CLIMATE_BY_DATA" );
     initConfigTypeMap( "Land_Temperature_Offset", &landtemperature_offset, Land_Temperature_Offset_DESC_TEXT, -20.0f, 20.0f, 0.0f,"Climate_Model","CLIMATE_BY_DATA" );
     initConfigTypeMap( "Rainfall_Scale_Factor", &rainfall_scale_factor, Rainfall_Scale_Factor_DESC_TEXT, 0.1f, 10.0f, 1.0f, "Climate_Model", "CLIMATE_BY_DATA" );
     initConfigTypeMap( "Relative_Humidity_Scale_Factor", &humidity_scale_factor, Relative_Humidity_Scale_Factor_DESC_TEXT, 0.1f, 10.0f, 1.0f, "Climate_Model", "CLIMATE_BY_DATA" );
     return Climate::Configure( config );
 }
    bool
    ClimateConstant::Configure(
        const Configuration* config
    )
    {
        LOG_DEBUG( "Configure\n" );

        initConfigTypeMap( "Base_Air_Temperature", &base_airtemperature, Base_Air_Temperature_DESC_TEXT, -55.0f, 45.0f, 22.0f );
        initConfigTypeMap( "Base_Land_Temperature", &base_landtemperature, Base_Land_Temperature_DESC_TEXT, -55.0f, 60.0f, 26.0f );
        initConfigTypeMap( "Base_Rainfall", &base_rainfall, Base_Rainfall_DESC_TEXT, 0.0f, 150.0f, 10.0f );
        initConfigTypeMap( "Base_Relative_Humidity", &base_humidity, Base_Relative_Humidity_DESC_TEXT, 0.0f, 1.0f, 0.75f );
        return Climate::Configure( config );
    }
    bool Action::Configure( const Configuration * inputJson )
    {
        initConfigTypeMap( "Threshold", &m_Threshold, ICE_Action_Threshold_DESC_TEXT, 0.0, FLT_MAX, 0.0 );
        initConfig("Event_Type", m_EventType, inputJson, MetadataDescriptor::Enum("Event_Type", ICE_Event_Type_DESC_TEXT, MDD_ENUM_ARGS( EventType )));
        initConfigTypeMap( "Event_To_Broadcast", &m_EventToBroadcast, ICE_Action_Event_To_Broadcast_DESC_TEXT );

        bool ret = JsonConfigurable::Configure( inputJson );

        if( ret && !JsonConfigurable::_dryrun )
        {
            CheckConfigurationTriggers();
        }
        return ret;
    }
    bool IncidenceEventCoordinator::Configure( const Configuration * inputJson )
    {
        initConfigTypeMap( "Incidence_Counter", m_pIncidenceCounter, ICE_Incidence_Counter_DESC_TEXT );
        initConfigTypeMap( "Responder", m_pResponder, ICE_Responder_DESC_TEXT );

        ConfigureRepetitions( inputJson );

        bool retValue = JsonConfigurable::Configure( inputJson );
        if( retValue && !JsonConfigurable::_dryrun )
        {
            CheckConfigureRepetitions();
        }
        return retValue;
    }
예제 #12
0
    bool WaningEffectMapAbstract::Configure( const Configuration * pInputJson )
    {
        initConfigTypeMap( "Initial_Effect",               &m_EffectCurrent,          WEE_Initial_Effect_DESC_TEXT,                0, 1, 1);
        initConfigTypeMap( "Expire_At_Durability_Map_End", &m_ExpireAtDurationMapEnd, WEM_Expire_At_Durability_Map_End_DESC_TEXT, false );

        initConfigComplexType( "Durability_Map", &m_DurationMap, WEM_Durability_Map_End_DESC_TEXT );

        bool ret = JsonConfigurable::Configure(pInputJson);
        if( ret )
        {
            m_EffectOriginal = m_EffectCurrent;
        }
        return ret;
    }
예제 #13
0
    SimulationSTI::SimulationSTI()
        : relationshipSuidGenerator(EnvPtr->MPI.Rank, EnvPtr->MPI.NumTasks)
        , report_relationship_start(false)
        , report_relationship_end(false)
        , report_transmission(false)
        , report_relationship_consummated(false)
    {
        initConfigTypeMap( "Report_Relationship_Start",     &report_relationship_start,      Report_Relationship_Start_DESC_TEXT, false);
        initConfigTypeMap( "Report_Relationship_End",       &report_relationship_end,        Report_Relationship_End_DESC_TEXT,   false);
        initConfigTypeMap( "Report_Transmission",           &report_transmission,            Report_Transmission_DESC_TEXT,      false);
        initConfigTypeMap( "Report_Coital_Acts",            &report_relationship_consummated,Report_Coital_Acts_DESC_TEXT,         false);

        reportClassCreator = ReportSTI::CreateReport;
    }
예제 #14
0
    bool
    StandardInterventionDistributionEventCoordinator::Configure(
        const Configuration * inputJson
    )
    {
        initializeInterventionConfig( inputJson );

        //initConfigTypeMap("Number_Distributions", &num_distributions, Number_Distributions_DESC_TEXT, -1, 1e6, -1 ); // by convention, -1 means no limit

        initConfigTypeMap("Number_Repetitions", &num_repetitions, Number_Repetitions_DESC_TEXT, -1, 1000, -1 );
        //if( num_repetitions > 1 ) // -1 = repeat without end, 0 is meaningless. want to think this one through more
        {
            initConfigTypeMap("Timesteps_Between_Repetitions", &tsteps_between_reps, Timesteps_Between_Repetitions_DESC_TEXT, -1, 10000 /*undefined*/, -1 /*off*/, "Number_Repetitions", "<>0" );
        }
        //initConfigTypeMap("Include_Departures", &include_emigrants, Include_Departures_DESC_TEXT, false );
        //initConfigTypeMap("Include_Arrivals", &include_immigrants, Include_Arrivals_DESC_TEXT, false );

        demographic_restrictions.ConfigureRestrictions( this, inputJson );


        bool retValue = JsonConfigurable::Configure( inputJson );
        if( retValue && !JsonConfigurable::_dryrun)
        {
            demographic_restrictions.CheckConfiguration();

            validateInterventionConfig( intervention_config._json );

            if( HasNodeLevelIntervention() )
            {
                // ---------------------------------------------------------------------------
                // --- If the user is attempting to define demographic restrictions when they
                // --- are using a node level intervention, then we need to error because these
                // --- restrictions are not doing anything.
                // ---------------------------------------------------------------------------
                if( !demographic_restrictions.HasDefaultRestrictions() )
                {
                    std::ostringstream msg ;
                    msg << "In StandardInterventionDistributionEventCoordinator, demographic restrictions such as 'Demographic_Coverage'\n";
                    msg << "and 'Target_Gender' do not apply when distributing node level interventions such as ";
                    msg << std::string( json::QuickInterpreter(intervention_config._json)["class"].As<json::String>() );
                    msg << ".\nThe node level intervention must handle the demographic restrictions.";
                    throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, msg.str().c_str() );
                }
            }
        }

        return retValue;
    }
예제 #15
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 ;
    }
예제 #16
0
    bool HIVSimpleDiagnostic::Configure(const Configuration * inputJson)
    {
        if( getEventOrConfig( inputJson ) == EventOrConfig::Event || JsonConfigurable::_dryrun )
        {
            initConfigTypeMap( "Negative_Diagnosis_Event", &negative_diagnosis_event, HIV_SD_Negative_Diagnosis_Event_DESC_TEXT );
        }

        ConfigurePositiveEventOrConfig( inputJson );
        bool ret = JsonConfigurable::Configure(inputJson);
        if( ret )
        {
            // error if the cascadeState is an abortState
            if (abortStates.find(cascadeState) != abortStates.end())
            {
                std::string abort_state_list ;
                for( auto state : abortStates )
                {
                    abort_state_list += state + ", " ;
                }
                if( abortStates.size() > 0 )
                {
                    abort_state_list = abort_state_list.substr( 0, abort_state_list.length() - 2 );
                }
                throw IncoherentConfigurationException( __FILE__, __LINE__, __FUNCTION__,
                                                        "Cascade_State", cascadeState.c_str(),
                                                        "Abort_States", abort_state_list.c_str(),
                                                        "The Cascade_State cannot be one of the Abort_States." );
            }

            //CheckPostiveEventConfig();
        }
        return ret ;
    }
예제 #17
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;
    }
예제 #18
0
 SimpleHousingModification::SimpleHousingModification()
     : killing_effect( nullptr )
     , blocking_effect( nullptr )
 {
     initSimTypes( 2, "VECTOR_SIM", "MALARIA_SIM" );
     initConfigTypeMap("Cost_To_Consumer", &cost_per_unit, HM_Cost_To_Consumer_DESC_TEXT, 0, 999999, 8.0);
 }
예제 #19
0
    bool ReportEventRecorder::Configure( const Configuration * inputJson )
    {
        std::vector<EventTrigger> tmp_event_trigger_list ;

        initConfigTypeMap( "Report_Event_Recorder_Ignore_Events_In_List", &ignore_events_in_list, Report_Event_Recorder_Ignore_Events_In_List_DESC_TEXT, false, "Report_Event_Recorder" );
        initConfigTypeMap( "Report_Event_Recorder_Events", &tmp_event_trigger_list, Report_Event_Recorder_Events_DESC_TEXT, "Report_Event_Recorder" );

        if( inputJson && inputJson->Exist("Report_Event_Recorder_Individual_Properties" ) || JsonConfigurable::_dryrun )
        {
            properties_to_report.value_source = IPKey::GetConstrainedStringConstraintKey(); 
            // xpath-y way of saying that the possible values for prop restrictions comes from demographics file IP's.
            initConfigTypeMap("Report_Event_Recorder_Individual_Properties", &properties_to_report, Property_Restriction_DESC_TEXT, "Intervention_Config.*.iv_type", "IndividualTargeted" );
        }

        bool ret = JsonConfigurable::Configure( inputJson );

        if( ret && !JsonConfigurable::_dryrun )
        {
            if( !ignore_events_in_list && tmp_event_trigger_list.empty() )
            {
                LOG_WARN( "No data will be recorded.  The Report_Event_Recorder_Events list is empty and Report_Event_Recorder_Ignore_Events_In_List is false.\n" );
            }
            else
            {
                // This logic goes through all possible events.  It checks to see if that event
                // is in the listen-to-these event_list provided by the user. But that list can be a 
                // whitelist or blacklist. If using whitelist AND event-requested is in master THEN listen.
                // else if using blacklist AND if event-(de)requested is not in master THEN listen.

                std::vector<EventTrigger> all_trigger_list = EventTriggerFactory::GetInstance()->GetAllEventTriggers();
                for( auto trigger : all_trigger_list )
                {
                    bool in_event_list = std::find( tmp_event_trigger_list.begin(), 
                                                    tmp_event_trigger_list.end(), trigger ) != tmp_event_trigger_list.end() ;

                    if( (!ignore_events_in_list &&  in_event_list) ||
                        ( ignore_events_in_list && !in_event_list) )
                    {
                        // list of events to listen for
                        eventTriggerList.push_back( trigger );
                    }
                }
            }
        }

        return ret;
    }
예제 #20
0
    bool DiagnosticTreatNeg::Configure(
        const Configuration * inputJson
    )
    {
        EventOrConfig::Enum use_event_or_config;
        initConfig( "Event_Or_Config", use_event_or_config, inputJson, MetadataDescriptor::Enum("EventOrConfig", Event_Or_Config_DESC_TEXT, MDD_ENUM_ARGS( EventOrConfig ) ) );
        if( use_event_or_config == EventOrConfig::Event || JsonConfigurable::_dryrun )
        {
            initConfigTypeMap( "Negative_Diagnosis_Event", &negative_diagnosis_event, DTN_Negative_Diagnosis_Config_Event_DESC_TEXT );
            initConfigTypeMap( "Defaulters_Event", &defaulters_event, DTN_Defaulters_Diagnosis_Config_Event_DESC_TEXT );
        }

        if( use_event_or_config == EventOrConfig::Config || JsonConfigurable::_dryrun )
        {
            initConfigComplexType("Negative_Diagnosis_Config", &negative_diagnosis_config, DTN_Negative_Diagnosis_Config_DESC_TEXT, "Event_Or_Config", "Config" );
            initConfigComplexType("Defaulters_Config", &defaulters_config, DTN_Defaulters_Diagnosis_Config_DESC_TEXT, "Event_Or_Config", "Config" );
        }

        bool ret = SimpleDiagnostic::Configure( inputJson );
        if( ret  )
        {
            if( use_event_or_config == EventOrConfig::Config || JsonConfigurable::_dryrun )
            {
                InterventionValidator::ValidateIntervention( negative_diagnosis_config._json );
                InterventionValidator::ValidateIntervention( defaulters_config._json );
            }

            if( !JsonConfigurable::_dryrun && 
                negative_diagnosis_event.IsUninitialized() &&
                (negative_diagnosis_config._json.Type() == ElementType::NULL_ELEMENT) )
            {
                const char* msg = "You must define either Negative_Diagnosis_Event or Negative_Diagnosis_Config";
                throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, msg );
            }

            if( !JsonConfigurable::_dryrun && 
                defaulters_event.IsUninitialized() &&
                (defaulters_config._json.Type() == ElementType::NULL_ELEMENT) )
            {
                const char* msg = "You must define either Defaulters_Event or Defaulters_Config";
                throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, msg );
            }
        }
        return ret ;
    }
예제 #21
0
    void ConcurrencyParameters::Initialize( const std::string& rRelTypeName,
                                            const std::string& rConcurrencyProperty, 
                                            const ::Configuration *json )
    {
        if( rConcurrencyProperty == DEFAULT_PROPERTY )
        {
            ConcurrencyByProperty* p_cbp = new ConcurrencyByProperty( DEFAULT_PROPERTY );
            m_PropertyValueToConcurrencyMap[ DEFAULT_PROPERTY ] = p_cbp;

            initConfigTypeMap( DEFAULT_PROPERTY, p_cbp, "TBD" );
        }
        else
        {
            const IndividualProperty* p_ip = IPFactory::GetInstance()->GetIP( rConcurrencyProperty );

            for( auto kv : p_ip->GetValues<IPKeyValueContainer>()  )
            {
                const std::string& prop_value = kv.GetValueAsString();

                //if( !json->Exist( prop_value ) )
                //{
                //    std::stringstream ss;
                //    ss << "Each type of relationship's Concurrency_Parameters must have all of the Individual Properties defined.  Property Key = " << rConcurrencyProperty;
                //    ss << ", Not Defined Property Value = " << prop_value << " in element = " << rRelTypeName ;
                //    throw InvalidInputDataException( __FILE__, __LINE__, __FUNCTION__, ss.str().c_str() );
                //}

                ConcurrencyByProperty* p_cbp = new ConcurrencyByProperty( prop_value );
                m_PropertyValueToConcurrencyMap[ prop_value ] = p_cbp;

                initConfigTypeMap( prop_value.c_str(), p_cbp, "TBD" );
            }
        }
        try
        {
            JsonConfigurable::Configure( json );
        }
        catch( DetailedException& re )
        {
            std::stringstream ss ;
            ss << re.GetMsg();
            ss << " Occured while reading the 'Concurrency_Parameters' in '" << rRelTypeName << "' from the demographics.  ";
            throw InvalidInputDataException( __FILE__, __LINE__, __FUNCTION__, ss.str().c_str() );
        }
    }
예제 #22
0
    HIVSimpleDiagnostic::HIVSimpleDiagnostic()
    : SimpleDiagnostic() // true implies only support events in SimpleDiagnostic
    , abortStates()
    , cascadeState("")
    , firstUpdate(true)
    , result_of_positive_test(false)
    , original_days_to_diagnosis(0.0)
    , negative_diagnosis_event()
    {
        initSimTypes(1, "HIV_SIM");

        // in a refactor, these might be lifted to a common HIVIntervention class
        abortStates.value_source = "Valid_Cascade_States.*";

        initConfigTypeMap("Abort_States", &abortStates, HIV_Abort_States_DESC_TEXT);
        initConfigTypeMap("Cascade_State", &cascadeState, HIV_Cascade_State_DESC_TEXT);
        initConfigTypeMap("Days_To_Diagnosis", &days_to_diagnosis, SD_Days_To_Diagnosis_DESC_TEXT, 0, FLT_MAX, 0);
    }
예제 #23
0
 BaseIntervention::BaseIntervention()
     : cost_per_unit(0.0f)
     , expired(false)
     , dont_allow_duplicates(false)
 {
     //total_intervention_counter++;
     initSimTypes( 1, "*" );
     initConfigTypeMap( "Dont_Allow_Duplicates", &dont_allow_duplicates, Dont_Allow_Duplicates_DESC_TEXT, false );
     //LOG_DEBUG_F("New intervention, total_intervention_counter = %d\n", total_intervention_counter);
 }
예제 #24
0
 bool
 PropertyValueChanger::Configure(
     const Configuration * inputJson
 )
 {
     target_property_key.constraints = IPKey::GetConstrainedStringConstraintKey();
     target_property_value.constraints = IPKey::GetConstrainedStringConstraintValue();
     initConfigTypeMap("Target_Property_Key", &target_property_key, PC_Target_Property_Key_DESC_TEXT );
     initConfigTypeMap("Target_Property_Value", &target_property_value, PC_Target_Property_Value_DESC_TEXT );
     initConfigTypeMap("Daily_Probability", &probability, PC_Daily_Probability_DESC_TEXT, 0.0f, 1.0f );
     initConfigTypeMap("Maximum_Duration", &max_duration, PC_Maximum_Duration_DESC_TEXT, -1.0f, FLT_MAX, FLT_MAX);
     initConfigTypeMap("Revert", &revert, PC_Revert_DESC_TEXT, 0.0f, 10000.0f, 0.0f );
     bool ret = BaseIntervention::Configure( inputJson );
     if( ret )
     {
         SetActionTimer( this );
     }
     return ret;
 }
    bool
    NodeLevelHealthTriggeredIVScaleUpSwitch::Configure(
        const Configuration * inputJson
    )
    {
        initConfig("Demographic_Coverage_Time_Profile",  demographic_coverage_time_profile, inputJson, MetadataDescriptor::Enum("Demographic_Coverage_Time_Profile", NodeHTI_Demographic_Coverage_Time_Profile_DESC_TEXT, MDD_ENUM_ARGS(ScaleUpProfile) ) );
        if ( demographic_coverage_time_profile == ScaleUpProfile::Linear || JsonConfigurable::_dryrun )
        {
            initConfigTypeMap("Initial_Demographic_Coverage", &initial_demographic_coverage, NodeHTI_Initial_Demographic_Coverage_DESC_TEXT, 0.0f, 1.0f, 0.0f);
            initConfigTypeMap("Primary_Time_Constant", &primary_time_constant, NodeHTI_Primary_Time_Constant_DESC_TEXT, 0, INFINITE_TIME); //this is actually the time to reach the final demographic coverage, input as absolute days, not number of dts
        }
        //this has to be an array rather than a single intervention json so that it can be empty if you don't want to phase anything out
        initConfigComplexType("Not_Covered_IndividualIntervention_Configs", &not_covered_intervention_configs, NodeHTI_Not_Covered_IndividualIntervention_Configs_DESC_TEXT);


        bool ret= NodeLevelHealthTriggeredIV::Configure(inputJson);
        return ret;

    }
예제 #26
0
    bool ConcurrencyConfigurationByProperty::Configure( const ::Configuration *json )
    {
        initConfig( "Extra_Relational_Flag_Type", 
                    m_ExtraRelFlag,
                    json, 
                    MetadataDescriptor::Enum("Extra_Relational_Flag_Type", "TBD", MDD_ENUM_ARGS( ExtraRelationalFlagType ) ) );

        bool ret = true;
        if( m_ExtraRelFlag == ExtraRelationalFlagType::Correlated )
        {
            std::set<std::string> allowable_relationship_types = GetAllowableRelationshipTypes();
            std::vector<std::string> rel_type_strings ;
            initConfigTypeMap( "Correlated_Relationship_Type_Order", &rel_type_strings, "TBD", nullptr, allowable_relationship_types );

            ret = JsonConfigurable::Configure( json );
            if( ret )
            {
                if( rel_type_strings.size() != RelationshipType::COUNT )
                {
                    std::stringstream ss;
                    ss << "Reading '" << m_PropretyValue << ": 'Correlated_Relationship_Type_Order' has " << rel_type_strings.size() << " types and must have " << RelationshipType::COUNT;
                    throw InvalidInputDataException( __FILE__, __LINE__, __FUNCTION__, ss.str().c_str() );
                }

                for( auto& rel_type_str : rel_type_strings )
                {
                    int rel_type_val = RelationshipType::pairs::lookup_value( rel_type_str.c_str() );

                    // I don't think I need this but just in case.
                    if( rel_type_val == -1 )
                    {
                        std::stringstream ss;
                        ss << "Unknown relationship type = " << rel_type_str;
                        throw InvalidInputDataException( __FILE__, __LINE__, __FUNCTION__, ss.str().c_str() );
                    }
                    if( std::find( m_RelTypeOrder.begin(), m_RelTypeOrder.end(), RelationshipType::Enum(rel_type_val) ) != m_RelTypeOrder.end() )
                    {
                        std::stringstream ss;
                        ss << "Duplicate(='" << rel_type_str << "') found in 'Correlated_Relationship_Type_Order'.  There must be one and only one of each RelationshipType.";
                        throw InvalidInputDataException( __FILE__, __LINE__, __FUNCTION__, ss.str().c_str() );
                    }

                    m_RelTypeOrder.push_back( RelationshipType::Enum(rel_type_val) );
                }
            }
        }
        else
        {
            for( int i = 0 ; i < RelationshipType::pairs::count() ; ++i )
            {
                m_RelTypeOrder.push_back( RelationshipType::Enum(RelationshipType::pairs::get_values()[i]) );
            }
        }
        return ret;
    }
예제 #27
0
    bool
    CalendarEventCoordinator::Configure(
        const Configuration * inputJson
    )
    {
        std::vector<int> distribution_times;
        std::vector<float> distribution_coverages;
        initConfigTypeMap("Distribution_Times", &distribution_times, Distribution_Times_DESC_TEXT, 1, INT_MAX, 0 );
        initConfigTypeMap("Distribution_Coverages", &distribution_coverages, Distribution_Coverages_DESC_TEXT, 0.0f, 1.0f, 0.0f );
        bool retValue = StandardInterventionDistributionEventCoordinator::Configure( inputJson );

        if(distribution_times.size() != distribution_coverages.size())
        {
            throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, "In a Calendar Event Coordinator, vector of distribution coverages must match vector of distribution times" );
        }

        BuildDistributionCalendar(distribution_times, distribution_coverages);

        return retValue;
    }
예제 #28
0
 SimpleVaccine::SimpleVaccine() 
 : BaseIntervention()
 , parent(nullptr) 
 , vaccine_type(SimpleVaccineType::Generic)
 , vaccine_take(0.0)
 , vaccine_took(false)
 , waning_effect( nullptr )
 , ivc( nullptr )
 {
     initConfigTypeMap("Cost_To_Consumer", &cost_per_unit, SV_Cost_To_Consumer_DESC_TEXT, 0, 999999, 10.0);
 }
예제 #29
0
    bool
    MultiEffectBoosterVaccine::Configure(
        const Configuration * inputJson
    )
    {
        initConfigTypeMap("Prime_Acquire",                  &prime_acquire,    MEBV_Prime_Acquire_DESC_TEXT,   0.0, 1.0, 0.0 ); 
        initConfigTypeMap("Prime_Transmit",                 &prime_transmit,   MEBV_Prime_Transmit_DESC_TEXT,  0.0, 1.0, 0.0 ); 
        initConfigTypeMap("Prime_Mortality",                &prime_mortality,  MEBV_Prime_Mortality_DESC_TEXT, 0.0, 1.0, 0.0 ); 
        initConfigTypeMap("Boost_Acquire",                  &boost_acquire,    MEBV_Boost_Acquire_DESC_TEXT,   0.0, 1.0, 0.0 ); 
        initConfigTypeMap("Boost_Transmit",                 &boost_transmit,   MEBV_Boost_Transmit_DESC_TEXT,  0.0, 1.0, 0.0 ); 
        initConfigTypeMap("Boost_Mortality",                &boost_mortality,  MEBV_Boost_Mortality_DESC_TEXT, 0.0, 1.0, 0.0 ); 
        initConfigTypeMap("Boost_Threshold_Acquire",        &boost_threshold_acquire,  MEBV_Boost_Threshold_Acquire_DESC_TEXT,  0.0, 1.0, 0.0 );
        initConfigTypeMap("Boost_Threshold_Transmit",       &boost_threshold_acquire,  MEBV_Boost_Threshold_Transmit_DESC_TEXT,  0.0, 1.0, 0.0 );
        initConfigTypeMap("Boost_Threshold_Mortality",      &boost_threshold_acquire,  MEBV_Boost_Threshold_Mortality_DESC_TEXT,  0.0, 1.0, 0.0 );

        bool configured = MultiEffectVaccine::Configure( inputJson );
        return configured;
    }
예제 #30
0
    HIVSimpleDiagnostic::HIVSimpleDiagnostic()
    : SimpleDiagnostic() // true implies only support events in SimpleDiagnostic
    , firstUpdate(true)
    , result_of_positive_test(false)
    , original_days_to_diagnosis(0.0)
    , negative_diagnosis_event()
    {
        initSimTypes(2, "HIV_SIM", "TBHIV_SIM");

        initConfigTypeMap("Days_To_Diagnosis", &days_to_diagnosis, SD_Days_To_Diagnosis_DESC_TEXT, FLT_MAX, 0);

        days_to_diagnosis.handle = std::bind( &HIVSimpleDiagnostic::Callback, this, std::placeholders::_1 );
    }