bool CommunityHealthWorkerEventCoordinator::Distribute( IIndividualHumanEventContext* pIHEC )
    {
        release_assert( m_pInterventionIndividual );

        IDistributableIntervention *di = m_pInterventionIndividual->Clone();
        release_assert(di);

        ICampaignCostObserver* p_icco = nullptr;
        if (s_OK != pIHEC->GetNodeEventContext()->QueryInterface(GET_IID(ICampaignCostObserver), (void**)&p_icco))
        {
            throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "pIHEC->GetNodeEventContext()", "ICampaignCostObserver", "INodeEventContext" );
        }

        di->AddRef();

        bool distributed = di->Distribute( pIHEC->GetInterventionsContext(), p_icco );

        if( distributed )
        {
            LOG_DEBUG_F("Distributed '%s' intervention to individual %d\n", m_InterventionName.c_str(), pIHEC->GetSuid().data );
        }

        di->Release();

        return distributed;
    }
Ejemplo n.º 2
0
    void PairFormationParametersImpl::InitializeCumulativeProbabilities()
    {
        release_assert( joint_probabilities.size()    == male_age_bin_count   );
        release_assert( joint_probabilities[0].size() == female_age_bin_count );

        cumulative_joint_probabilities.resize(male_age_bin_count);
        for (auto& vec : cumulative_joint_probabilities)
        {
            vec.resize(female_age_bin_count);
        }

        float cumulative = 0.0f;
        for( int row = 0; row < male_age_bin_count; row++)
        {
            cumulative = 0.0f;
            for( int col = 0; col < female_age_bin_count; col++)
            {
                cumulative += joint_probabilities[row][col];
                cumulative_joint_probabilities[row][col] = cumulative;
            }

            for( int col = 0; col < female_age_bin_count; col++)
            {
                if (cumulative > 0.0f)
                {
                    joint_probabilities[row][col] /= cumulative;
                    cumulative_joint_probabilities[row][col] /= cumulative;
                }
                else
                {
                    cumulative_joint_probabilities[row][col] = 1.0f;
                }
            }
        }
    }
Ejemplo n.º 3
0
 bool assertDualSolution(const P3* ptArray, int n, const P3& p0, const P3& p1, const P3& p2) {
   release_assert(inDaZone(p0, p1, p2));
   V3 N = planeNormalFrom3Points(p0, p1, p2);
   
   for (int i=0; i<n; i++) {
     const P3& p = ptArray[i];
     release_assert(!PtIsBelowPlane(p0, p1, p2, N, p));
   }
   
   return true; // dummy return, so this function can be used in an assert
 }
Ejemplo n.º 4
0
    void IndividualHumanVector::UpdateInfectiousness(float dt)
    {
        infectiousness = 0;
        float tmp_infectiousness = 0;  

        typedef std::map< StrainIdentity, float >     strain_infectivity_map_t;
        typedef strain_infectivity_map_t::value_type  strain_infectivity_t;
        strain_infectivity_map_t infectivity_by_strain;
        StrainIdentity tmp_strainIDs;

        // Loop once over all infections, caching strains and infectivity.
        // If total infectiousness exceeds unity, we will normalize all strains down accordingly.
        for (auto infection : infections)
        {
            release_assert( infection );
            tmp_infectiousness = infection->GetInfectiousness();
            infectiousness += tmp_infectiousness;

            if ( tmp_infectiousness > 0 )
            {
                infection->GetInfectiousStrainID(&tmp_strainIDs);
                infectivity_by_strain[tmp_strainIDs] += tmp_infectiousness;
            }
        }

        // Effects of transmission-reducing immunity.  N.B. interventions on vector success are not here, since they depend on vector-population-specific behavior
        release_assert( susceptibility );
        release_assert( interventions );
        float modtransmit = susceptibility->GetModTransmit() * interventions->GetInterventionReducedTransmit();

        // Maximum individual infectiousness is set here, capping the sum of unmodified infectivity at prob=1
        float truncate_infectious_mod = (infectiousness > 1 ) ? 1.0f/infectiousness : 1.0f;
        infectiousness *= truncate_infectious_mod * modtransmit;

        // Host weight is the product of MC weighting and relative biting
        float host_vector_weight = float(GetMonteCarloWeight() * GetRelativeBitingRate());

        // Effects from vector intervention container
        IVectorInterventionsEffects* ivie = nullptr;
        if ( s_OK !=  interventions->QueryInterface(GET_IID(IVectorInterventionsEffects), (void**)&ivie) )
        {
            throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "interventions", "IVectorInterventionsEffects", "IndividualHumanVector" );
        }

        // Loop again over infection strains, depositing (downscaled) infectivity modified by vector intervention effects etc. (indoor + outdoor)
        for (auto& infectivity : infectivity_by_strain)
        {
            const StrainIdentity *id = &(infectivity.first);

            parent->DepositFromIndividual( const_cast<StrainIdentity*>(id), host_vector_weight * infectivity.second * truncate_infectious_mod * modtransmit * ivie->GetblockIndoorVectorTransmit(), &NodeVector::human_to_vector_indoor );
            parent->DepositFromIndividual( const_cast<StrainIdentity*>(id), host_vector_weight * infectivity.second * truncate_infectious_mod * modtransmit * ivie->GetblockOutdoorVectorTransmit(), &NodeVector::human_to_vector_outdoor );
        }
    }
    INodeTriggeredInterventionConsumer* CommunityHealthWorkerEventCoordinator::GetNodeTriggeredConsumer( INodeEventContext* pNEC )
    {
        release_assert( pNEC );
        INodeTriggeredInterventionConsumer* pNTIC = nullptr;
        if( pNEC->QueryInterface( GET_IID(INodeTriggeredInterventionConsumer), (void**)&pNTIC ) != s_OK )
        {
            throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "pNEC", "INodeTriggeredInterventionConsumer", "INodeEventContext" );
        }
        release_assert( pNTIC );

        return pNTIC ;
    }
Ejemplo n.º 6
0
    void PropertyValueChanger::Update( float dt )
    {
        release_assert( expired == false );
        release_assert( ibc );

        std::string current_prop_value = "";
        if( reversion_timer > 0 )
        {
            reversion_timer -= dt;
            if( reversion_timer <= 0 )
            {
                LOG_DEBUG_F( "Time to revert PropertyValueChanger.\n" );
                probability = 1.0;
            }
        }
        if( probability == 1.0 || action_timer < 0 )
        {
            if( revert )
            {
                // Need to ask individual (parent's parent) for current value of this property
                // TBD: use QI not static cast
                auto props = static_cast<InterventionsContainer*>(ibc)->GetParent()->GetEventContext()->GetProperties();
                current_prop_value = props->find( (std::string) target_property_key )->second;
            }
            ibc->ChangeProperty( target_property_key.c_str(), target_property_value.c_str() );

            //broadcast that the individual changed properties
            INodeTriggeredInterventionConsumer* broadcaster = nullptr;
            if (s_OK != parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&broadcaster))
            {
                throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "INodeTriggeredInterventionConsumer", "INodeEventContext" );
            }
            LOG_DEBUG_F( "Individual %d changed property, broadcasting PropertyChange \n", parent->GetSuid().data );
            broadcaster->TriggerNodeEventObservers( parent->GetEventContext(), IndividualEventTriggerType::PropertyChange );


            if( revert )
            {
                target_property_value = current_prop_value;
                probability = 0.0; // keep it simple for now, reversion is guaranteed
                reversion_timer = revert;
                action_timer= FLT_MAX;
                LOG_DEBUG_F( "Initializing reversion timer to %f\n", reversion_timer );
                revert = 0; // no more reversion from reversion
            }
            else
            {
                expired = true;
            }
        }
        action_timer -= dt;
    }
Ejemplo n.º 7
0
 void PairFormationStatsImpl::SetParameters( const IPairFormationParameters* params )
 {
     parameters = params;
     if( parameters != nullptr )
     {
         release_assert( eligible_population.size() == RiskGroup::COUNT );
         for( int i = 0 ; i < RiskGroup::COUNT ; i++ )
         {
             release_assert( eligible_population[i].size() == Gender::COUNT );
             release_assert( eligible_population[i][Gender::MALE  ].size() == parameters->GetMaleAgeBinCount()   );
             release_assert( eligible_population[i][Gender::FEMALE].size() == parameters->GetFemaleAgeBinCount() );
         }
     }
 }
Ejemplo n.º 8
0
 void PairFormationStatsImpl::UpdateEligible( float age_in_days, int sex, RiskGroup::Enum risk_group, int delta )
 {
     LOG_DEBUG_F("%s( %f, %d, %s, %d )\n", __FUNCTION__, age_in_days, sex, RiskGroup::pairs::lookup_key(risk_group), delta);
     int agebin_index = parameters->BinIndexForAgeAndSex(age_in_days, sex);
     release_assert( (eligible_population.at(risk_group).at(sex)[agebin_index] + delta) >= 0 );
     eligible_population.at(risk_group).at(sex)[agebin_index] += delta;
 }
Ejemplo n.º 9
0
void VectorSpeciesReport::Initialize( unsigned int nrmSize )
{
    _nrmSize = nrmSize;
    release_assert( _nrmSize );

    initChannelBins();
}
Ejemplo n.º 10
0
    bool
    NodeLevelHealthTriggeredIV::Distribute(
        INodeEventContext *pNodeEventContext,
        IEventCoordinator2 *pEC
    )
    {
        bool was_distributed = BaseNodeIntervention::Distribute(pNodeEventContext, pEC);
        if (was_distributed)
        {
            LOG_DEBUG_F("Distributed Nodelevel health-triggered intervention to NODE: %d\n", pNodeEventContext->GetId().data);

            // QI to register ourself as a NodeLevelHealthTriggeredIV observer
            INodeTriggeredInterventionConsumer * pNTIC = nullptr;
            if (s_OK != pNodeEventContext->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&pNTIC))
            {
                throw QueryInterfaceException(__FILE__, __LINE__, __FUNCTION__, "pNodeEventContext", "INodeTriggeredInterventionConsumer", "INodeEventContext");
            }
            release_assert(pNTIC);
            for (auto &trigger : m_trigger_conditions)
            {
                pNTIC->RegisterNodeEventObserver((IIndividualEventObserver*)this, trigger);
            }
        }
        return was_distributed;
    }
Ejemplo n.º 11
0
    EventTriggerFactory* EventTriggerFactory::GetInstance()
    {
        EventTriggerFactory* p_factory = (EventTriggerFactory*)Environment::getEventTriggerFactory();
        if( p_factory == nullptr )
        {
            p_factory = new EventTriggerFactory();

            release_assert( m_VectorBuiltIn.size() > 0 );
            bool built_in_created = ((m_VectorBuiltIn.size() > 0) && (m_VectorBuiltIn[0].second->m_pInternal != nullptr));

            // ---------------------------------------------------------------------------------
            // --- The Built-In events only get created once per execution.  For componentTests,
            // --- we need to get rid of the user defined events but maintain the built-in ones.
            // ---------------------------------------------------------------------------------
            if( built_in_created )
            {
                for( auto& entry : m_VectorBuiltIn )
                {
                    p_factory->m_VectorAll.push_back( entry.second->m_pInternal );
                    p_factory->m_MapAll[ entry.first ] = entry.second->m_pInternal;
                }
            }
            Environment::setEventTriggerFactory( p_factory );
        }
        return p_factory;
    }
    bool MultiInterventionEventCoordinator::DistributeInterventionsToIndividual( IIndividualHumanEventContext *ihec,
                                                                                 float & incrementalCostOut,
                                                                                 ICampaignCostObserver * pICCO )
    {
        bool all_distributed = true;
        for( auto di_master : m_IndividualInterventions )
        {
            // instantiate and distribute intervention
            LOG_DEBUG_F( "Attempting to instantiate intervention of class %s\n", std::string( json::QuickInterpreter( intervention_config._json )[ "class" ].As<json::String>() ).c_str() );

            IDistributableIntervention* di_clone = di_master->Clone();
            release_assert( di_clone );
            di_clone->AddRef();

            if( !di_clone->Distribute( ihec->GetInterventionsContext(), pICCO ) )
            {
                di_clone->Release(); // a bit wasteful for now, could cache it for the next fellow
                LOG_DEBUG_F( "Distributed an intervention %s to individual %d at a cost of %f\n",
                        di_clone->GetName().c_str(), ihec->GetSuid().data, incrementalCostOut );
            }
            else
            {
                all_distributed = false;
            }
        }
        return all_distributed;
    }
Ejemplo n.º 13
0
void CGAL_Solver::solve(const hough_min_max::P3 points[]) {
  for(int i=0; i<n; i++) {
    A[0][i] = points[i].x;
    A[1][i] = points[i].y;
    A[2][i] = -1;
    b[i] = points[i].z;
  }
  A[0][n] = 1;
  A[1][n] = 1;
  A[2][n] = 0;
  b[n] = 1;
  
  timeval t1, t2;
  gettimeofday(&t1, NULL);
  Solution s = CGAL::solve_nonnegative_linear_program(*lp, ET());
  gettimeofday(&t2, NULL);
  time += (t2.tv_sec - t1.tv_sec) * 1000.0;      // sec to ms
  time += (t2.tv_usec - t1.tv_usec) / 1000.0;   // us to ms

  release_assert(!s.is_infeasible());
  bounded = !s.is_unbounded();
  
  value = CGAL::to_double(s.objective_value());
  u = CGAL::to_double(*s.variable_values_begin());
  v = CGAL::to_double(*(s.variable_values_begin()+1));
}
Ejemplo n.º 14
0
    void IndividualHumanVector::Expose( const IContagionPopulation* cp, float dt, TransmissionRoute::Enum transmission_route )
    {
        release_assert( cp );
        release_assert( susceptibility );
        release_assert( interventions );
#if 1
        // get rid of this. but seems to be needed for malaria garki. :( :( :(
        if( !vector_interventions )
        {
            vector_interventions = static_cast<VectorInterventionsContainer*>(interventions);
        }
#endif
        release_assert( vector_interventions );
        float acqmod = GetRelativeBitingRate() * susceptibility->getModAcquire() * interventions->GetInterventionReducedAcquire();

        switch( transmission_route )
        {
            case TransmissionRoute::TRANSMISSIONROUTE_VECTOR_TO_HUMAN_INDOOR:
                acqmod *= vector_interventions->GetblockIndoorVectorAcquire();
                break;

            case TransmissionRoute::TRANSMISSIONROUTE_VECTOR_TO_HUMAN_OUTDOOR:
                acqmod *= vector_interventions->GetblockOutdoorVectorAcquire();
                break;
        
            default:
                throw BadEnumInSwitchStatementException( __FILE__, __LINE__, __FUNCTION__, "transmission_route", transmission_route, "Stringified enum value not available" );
        }

        // Accumulate vector of pairs of strain ids and cumulative infection probability
        float infection_probability = cp->GetTotalContagion() * acqmod * dt;
        if ( infection_probability > 0 )
        {
            // Increment total exposure
            m_total_exposure += infection_probability;

            // With a weighted random draw, pick a strain from the ContagionPopulation CDF
            StrainIdentity strain_id;
            strain_id.SetAntigenID(cp->GetAntigenId());
            cp->ResolveInfectingStrain(&strain_id); 

            // Push this exposure and strain back to the storage array for all vector-to-human pools (e.g. indoor, outdoor)
            m_strain_exposure.push_back( std::make_pair(strain_id, m_total_exposure) );
        }
    }
    bool Responder::visitIndividualCallback( IIndividualHumanEventContext *ihec, float & incrementalCostOut, ICampaignCostObserver * pICCO )
    {
        release_assert( m_pCurrentAction != nullptr );

        IIndividualEventBroadcaster* broadcaster = ihec->GetNodeEventContext()->GetIndividualEventBroadcaster();
        broadcaster->TriggerObservers( ihec, m_pCurrentAction->GetEventToBroadcastIndividual() );

        return true;
    }
Ejemplo n.º 16
0
/*
================
idImageManager::CreateIntrinsicImages
================
*/
void idImageManager::CreateIntrinsicImages()
{
	// create built in images
	defaultImage = ImageFromFunction( "_default", R_DefaultImage );
	whiteImage = ImageFromFunction( "_white", R_WhiteImage );
	blackImage = ImageFromFunction( "_black", R_BlackImage );
	flatNormalMap = ImageFromFunction( "_flat", R_FlatNormalImage );
	alphaNotchImage = ImageFromFunction( "_alphaNotch", R_AlphaNotchImage );
	fogImage = ImageFromFunction( "_fog", R_FogImage );
	fogEnterImage = ImageFromFunction( "_fogEnter", R_FogEnterImage );
	noFalloffImage = ImageFromFunction( "_noFalloff", R_CreateNoFalloffImage );
	ImageFromFunction( "_quadratic", R_QuadraticImage );
	
	// RB begin
	shadowImage[0] = ImageFromFunction( va( "_shadowMapArray0_%i", shadowMapResolutions[0] ), R_CreateShadowMapImage_Res0 );
	shadowImage[1] = ImageFromFunction( va( "_shadowMapArray1_%i", shadowMapResolutions[1] ), R_CreateShadowMapImage_Res1 );
	shadowImage[2] = ImageFromFunction( va( "_shadowMapArray2_%i", shadowMapResolutions[2] ), R_CreateShadowMapImage_Res2 );
	shadowImage[3] = ImageFromFunction( va( "_shadowMapArray3_%i", shadowMapResolutions[3] ), R_CreateShadowMapImage_Res3 );
	shadowImage[4] = ImageFromFunction( va( "_shadowMapArray4_%i", shadowMapResolutions[4] ), R_CreateShadowMapImage_Res4 );
	
	jitterImage1 = globalImages->ImageFromFunction( "_jitter1", R_CreateJitterImage1 );
	jitterImage4 = globalImages->ImageFromFunction( "_jitter4", R_CreateJitterImage4 );
	jitterImage16 = globalImages->ImageFromFunction( "_jitter16", R_CreateJitterImage16 );
	
	randomImage256 = globalImages->ImageFromFunction( "_random256", R_CreateRandom256Image );
	// RB end
	
	// scratchImage is used for screen wipes/doublevision etc..
	scratchImage = ImageFromFunction( "_scratch", R_RGBA8Image );
	scratchImage2 = ImageFromFunction( "_scratch2", R_RGBA8Image );
	accumImage = ImageFromFunction( "_accum", R_RGBA8Image );
	currentRenderImage = ImageFromFunction( "_currentRender", R_RGBA8Image );
	currentDepthImage = ImageFromFunction( "_currentDepth", R_DepthImage );
	
	// save a copy of this for material comparison, because currentRenderImage may get
	// reassigned during stereo rendering
	originalCurrentRenderImage = currentRenderImage;
	
	loadingIconImage = ImageFromFile( "textures/loadingicon2", TF_DEFAULT, TR_CLAMP, TD_DEFAULT, CF_2D );
	hellLoadingIconImage = ImageFromFile( "textures/loadingicon3", TF_DEFAULT, TR_CLAMP, TD_DEFAULT, CF_2D );
	
	release_assert( loadingIconImage->referencedOutsideLevelLoad );
	release_assert( hellLoadingIconImage->referencedOutsideLevelLoad );
}
Ejemplo n.º 17
0
    void HIVInterventionsContainer::SetContextTo(IIndividualHumanContext* context)
    {
        STIInterventionsContainer::SetContextTo( context );
        release_assert( parent );

        if( s_OK != parent->QueryInterface(GET_IID(IIndividualHumanHIV), (void**) &hiv_parent) )
        {
            throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent", "IIndividualHumanHIV", "IIndividualHumanContext" );
        }
    }
Ejemplo n.º 18
0
    GameLevel::GameLevel(World& world, FASaveGame::GameLoader& loader)
        : mWorld(world), mLevel(Level::Level(loader)), mLevelIndex(loader.load<int32_t>()), mItemMap(new ItemMap(loader, this))
    {
        release_assert(loader.currentlyLoadingLevel == nullptr);
        loader.currentlyLoadingLevel = this;

        uint32_t actorsSize = loader.load<uint32_t>();

        mActors.reserve(actorsSize);
        for (uint32_t i = 0; i < actorsSize; i++)
        {
            std::string actorTypeId = loader.load<std::string>();
            Actor* actor = static_cast<Actor*>(mWorld.mObjectIdMapper.construct(actorTypeId, loader));
            mActors.push_back(actor);
        }

        release_assert(loader.currentlyLoadingLevel == this);
        loader.currentlyLoadingLevel = nullptr;
    }
Ejemplo n.º 19
0
    const char* ConcurrencyConfiguration::GetConcurrencyPropertyValue( const tProperties* the_individuals_properties, 
                                                                       const char* prop, 
                                                                       const char* prop_value ) const
    {
        if( m_PropertyKey == DEFAULT_PROPERTY )
        {
            return DEFAULT_PROPERTY;
        }
        else if( (prop == nullptr) || (prop_value == nullptr) )
        {
            release_assert( the_individuals_properties );
            release_assert( the_individuals_properties->count( m_PropertyKey ) > 0 );

            return the_individuals_properties->at( m_PropertyKey ).c_str();
        }
        else
        {
            release_assert( m_PropertyKey == prop );
            return prop_value;
        }
    }
    bool CommunityHealthWorkerEventCoordinator::Distribute( INodeEventContext* pNEC )
    {
        release_assert( m_pInterventionNode );

        // Huge performance win by cloning instead of configuring.
        INodeDistributableIntervention *ndi = m_pInterventionNode->Clone();
        release_assert( ndi );

        ndi->AddRef();

        bool distributed =  ndi->Distribute( pNEC, nullptr );

        if( distributed )
        {
            LOG_DEBUG_F("Distributed '%s' intervention to node %d\n", m_InterventionName.c_str(), pNEC->GetExternalId() );
        }

        ndi->Release();

        return distributed;
    }
Ejemplo n.º 21
0
    void SimpleTransmissionGroups::GetGroupMembershipForProperties( const RouteList_t& route, const tProperties* properties, TransmissionGroupMembership_t* membershipOut ) const
    {
        (*membershipOut)[0] = GroupIndex(0); // map route 0 to index 0
        std::ostringstream* msg = nullptr;
        if (LOG_LEVEL(DEBUG)) 
        {
            msg = new std::ostringstream();
            *msg << "(fn=GetGroupMembershipForProperties) ";
        }

        for (const auto& entry : (*properties))
        {
            const string& propertyName = entry.first;
            const string& propertyValue = entry.second;

            if (propertyValueToIndexMap.find(propertyName) != propertyValueToIndexMap.end())
            {
                if( propertyValueToIndexMap.at(propertyName).find( propertyValue ) != propertyValueToIndexMap.at(propertyName).end() )
                {
                    (*membershipOut)[0] += propertyValueToIndexMap.at(propertyName).at(propertyValue);
                }
                else
                {
                    throw BadMapKeyException( __FILE__, __LINE__, __FUNCTION__, (std::string("propertyValueToIndexMap[")+propertyName+"]").c_str(), propertyValue.c_str() );
                }
            }
            if (LOG_LEVEL(DEBUG))
            {
                release_assert( msg ); // ensure someone doesn't change logic above so this is not allocated.
                *msg << propertyName << "=" << propertyValue << ", ";
            }
        }
        if (LOG_LEVEL(DEBUG))
        {
            release_assert( msg ); // ensure someone doesn't change logic above so this is not allocated.
            *msg << "=> Group index for route 0 is " << (*membershipOut)[0] << std::endl;
            LOG_DEBUG( msg->str().c_str() );
            delete msg;
        }
    }
Ejemplo n.º 22
0
    unsigned char ConcurrencyConfiguration::GetProbExtraRelationalBitMask( const char* prop, 
                                                                           const char* prop_value, 
                                                                           Gender::Enum gender,
                                                                           bool isSuperSpreader ) const
    {
        release_assert( m_PropertyKey == prop );

        unsigned char ret = 0;

        if( isSuperSpreader ) 
        {
            for( int rel = 0; rel < RelationshipType::COUNT; rel++ )
            {
                ret |= EXTRA_RELATIONAL_ALLOWED( rel );
            }
        }
        else
        {
            release_assert( m_PropertyValueToConfig.count( prop_value ) > 0 );

            const ConcurrencyConfigurationByProperty* p_ccbp = m_PropertyValueToConfig.at( prop_value );

            for( int rel = 0; rel < RelationshipType::COUNT; rel++ )
            {
                RelationshipType::Enum rel_type = p_ccbp->GetRelationshipTypeOrder()[rel];
                float prob = m_RelTypeToParametersMap.at( rel_type )->GetProbExtra( prop_value, gender );

                if( (prob > 0.0) && ((prob == 1.0) || (prob > Environment::getInstance()->RNG->e()) ) )
                {
                    ret |= EXTRA_RELATIONAL_ALLOWED(rel_type);
                }
                else if( p_ccbp->GetExtraRelationshipFlag() != ExtraRelationalFlagType::Independent )
                {
                    return ret ;
                }
            }
        }
        return ret;
    }
Ejemplo n.º 23
0
 void GameLevel::removeActor(Actor* actor)
 {
     for (auto i = mActors.begin(); i != mActors.end(); ++i)
     {
         if (*i == actor)
         {
             mActors.erase(i);
             actorMapRemove(actor);
             return;
         }
     }
     release_assert(false && "tried to remove actor that isn't in level");
 }
    ClimateConstant * ClimateConstant::CreateClimate( ClimateUpdateResolution::Enum update_resolution,
                                                      INodeContext * _parent,
                                                      float start_time,
                                                      RANDOMBASE* pRNG )
    {
        ClimateConstant * new_climate = _new_ ClimateConstant(update_resolution, _parent);
        release_assert( new_climate );
        new_climate->Configure( EnvPtr->Config );

        // initialize climate values
        new_climate->UpdateWeather( start_time, 1.0f, pRNG );

        return new_climate;
    }
Ejemplo n.º 25
0
    void HIVInterventionsContainer::GoOffART()
    {
        release_assert( hiv_parent );
        release_assert( hiv_parent->GetHIVSusceptibility() );
        if( hiv_parent->GetHIVInfection() == nullptr )
        {
            LOG_WARN_F( "Individual %d coming off ART without infection!!!\n", parent->GetSuid().data );
            return;
        }

        release_assert( hiv_parent->GetHIVInfection() );
        if( OnArtQuery() == false )
        {
            LOG_DEBUG_F( "Individual %d is not on ART, cannot dropout.\n", parent->GetSuid().data );
            return;
        }

        LOG_DEBUG_F( "EEL: Individual %d dropping off ART now\n", parent->GetSuid().data );
        ART_status = ARTStatus::OFF_BY_DROPOUT;
        full_suppression_timer = INACTIVE_DURATION;
        days_since_most_recent_ART_start = INACTIVE_DURATION;
        hiv_parent->GetHIVInfection()->ApplySuppressionDropout();

        // Make sure ART dropouts do no return to ON_BUT_FAILING
        m_suppression_failure_timer = INACTIVE_DURATION;

        INodeTriggeredInterventionConsumer* broadcaster = nullptr;
        if (s_OK != parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&broadcaster))
        {
            throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, 
                                           "parent->GetEventContext()->GetNodeEventContext()", 
                                           "INodeTriggeredInterventionConsumer",
                                           "INodeEventContext" );
        }

        broadcaster->TriggerNodeEventObservers( parent->GetEventContext(), EventTrigger::StoppedART );
    }
Ejemplo n.º 26
0
 void NodeLevelHealthTriggeredIV::Unregister()
 {
     // unregister ourself as a node level health triggered observer
     INodeTriggeredInterventionConsumer * pNTIC = nullptr;
     if (s_OK != parent->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&pNTIC))
     {
         throw QueryInterfaceException(__FILE__, __LINE__, __FUNCTION__, "parent", "INodeTriggeredInterventionConsumer", "INodeEventContext");
     }
     release_assert(pNTIC);
     for (auto &trigger : m_trigger_conditions)
     {
         pNTIC->UnregisterNodeEventObserver( this, trigger );
     }
     SetExpired( true );
 }
Ejemplo n.º 27
0
    bool SimpleVaccine::ApplyVaccineTake( IIndividualHumanContext* pihc )
    {
        release_assert( pihc );

        bool did_vaccine_take = true;
        if(vaccine_take<1.0)
        {
            if(pihc->GetRng()->e()>vaccine_take)
            {
                LOG_DEBUG("Vaccine did not take.\n");
                did_vaccine_take = false;
            }
        }
        return did_vaccine_take;
    }
Ejemplo n.º 28
0
    void EventTriggerFactory::SetBuiltIn()
    {
        // ----------------------------------------------------
        // --- See the top of the file about Built-in triggers.
        // --- Should only be called from DLLs and triggers should
        // --- not be used before hand.
        // ----------------------------------------------------
        release_assert( (m_VectorBuiltIn.size() > 0) && (m_VectorBuiltIn[ 0 ].second->m_pInternal == nullptr) );

        EventTriggerFactory* p_factory = (EventTriggerFactory*)Environment::getEventTriggerFactory();
        release_assert( p_factory != nullptr );

        for( int i = 0 ; i < m_VectorBuiltIn.size() ; ++i )
        {
            if( p_factory->m_MapAll.count( m_VectorBuiltIn[ i ].first ) == 0 )
            {
                std::stringstream ss;
                ss << "DLL Built-in trigger = " << m_VectorBuiltIn[ i ].first << " is missing in the EXE.";
                throw IllegalOperationException( __FILE__, __LINE__, __FUNCTION__, ss.str().c_str() );
            }

            m_VectorBuiltIn[i].second->m_pInternal = p_factory->m_MapAll.at( m_VectorBuiltIn[ i ].first );
        }
    }
Ejemplo n.º 29
0
    bool SimulationSTI::WasRelationshipTerminatedLastTimestep( const suids::suid& relId ) const
    {
        const NodeRankMap::RankMap_t& rank_map = nodeRankMap.GetRankMap();

        for( auto& entry : rank_map )
        {
            NodeInfoSTI* p_nis = dynamic_cast<NodeInfoSTI*>(entry.second);
            release_assert( p_nis );

            if( p_nis->WasRelationshipTerminatedLastTimestep( relId ) )
            {
                return true;
            }
        }
        return false;
    }
 void NodeEventContextHost::notifyCampaignExpenseIncurred(
     float expenseIncurred,
     const IIndividualHumanEventContext * pIndiv
 )
 {
     release_assert( node );
     if( expenseIncurred > 0 )
     {
         LOG_DEBUG("Campaign expense was incurred\n");
     }
     float cost = expenseIncurred;
     if( pIndiv != nullptr )
     {
         cost *= float( pIndiv->GetMonteCarloWeight() );
     }
     IncrementCampaignCost( cost );
 }