From 217ebbd7f6a804044e421683eb7db1b2713f9e3b Mon Sep 17 00:00:00 2001 From: Pandemic-Sim Team Date: Mon, 27 Jan 2025 19:04:53 -0800 Subject: [PATCH] Automated Code Change PiperOrigin-RevId: 720390227 --- .../core/distribution_sampler_test.cc | 2 +- .../core/enum_indexed_array_test.cc | 4 +-- .../core/exposure_store_test.cc | 27 +++++++------- .../core/graph_location.cc | 34 +++++++++--------- .../core/graph_location_test.cc | 16 ++++----- .../core/indexed_location_visit_generator.cc | 4 +-- .../indexed_location_visit_generator_test.cc | 2 +- ...n_discrete_event_simulator_builder_test.cc | 2 +- .../location_discrete_event_simulator_test.cc | 8 ++--- agent_based_epidemic_sim/core/risk_score.cc | 2 +- agent_based_epidemic_sim/core/seir_agent.cc | 28 +++++++-------- .../core/seir_agent_test.cc | 36 +++++++++---------- agent_based_epidemic_sim/core/simulation.cc | 14 ++++---- .../core/simulation_test.cc | 16 ++++----- 14 files changed, 99 insertions(+), 96 deletions(-) diff --git a/agent_based_epidemic_sim/core/distribution_sampler_test.cc b/agent_based_epidemic_sim/core/distribution_sampler_test.cc index 97b6ae55..049a78e3 100644 --- a/agent_based_epidemic_sim/core/distribution_sampler_test.cc +++ b/agent_based_epidemic_sim/core/distribution_sampler_test.cc @@ -28,7 +28,7 @@ using ::testing::AnyOf; using ::testing::ElementsAre; TEST(DiscreteDistributionSamplerTest, CreatesSingleIntDistribution) { - auto sampler = DiscreteDistributionSampler::FromProto( + auto sampler = DiscreteDistributionSampler::FromProto( ParseTextProtoOrDie(R"pb( buckets { count: 1 int_value: 1 } buckets { count: 2 int_value: 10 } diff --git a/agent_based_epidemic_sim/core/enum_indexed_array_test.cc b/agent_based_epidemic_sim/core/enum_indexed_array_test.cc index dbc6f23c..329f5157 100644 --- a/agent_based_epidemic_sim/core/enum_indexed_array_test.cc +++ b/agent_based_epidemic_sim/core/enum_indexed_array_test.cc @@ -27,7 +27,7 @@ enum class TestEnum { }; TEST(EnumIndexedArray, BracketOperator) { - EnumIndexedArray a{{1, 4, 6}}; + EnumIndexedArray a{{1, 4, 6}}; EXPECT_EQ(a[TestEnum::kCase0], 1); EXPECT_EQ(a[TestEnum::kCase1], 4); EXPECT_EQ(a[TestEnum::kCase2], 6); @@ -46,7 +46,7 @@ TEST(EnumIndexedArray, BracketOperator) { } TEST(EnumIndexedArray, BracketOperatorConst) { - const EnumIndexedArray a{{2, 5, 8}}; + const EnumIndexedArray a{{2, 5, 8}}; EXPECT_EQ(a[TestEnum::kCase0], 2); EXPECT_EQ(a[TestEnum::kCase1], 5); EXPECT_EQ(a[TestEnum::kCase2], 8); diff --git a/agent_based_epidemic_sim/core/exposure_store_test.cc b/agent_based_epidemic_sim/core/exposure_store_test.cc index 9bd878b1..266ec5c5 100644 --- a/agent_based_epidemic_sim/core/exposure_store_test.cc +++ b/agent_based_epidemic_sim/core/exposure_store_test.cc @@ -17,11 +17,11 @@ absl::Time TestHour(int day, int hour) { return TestDay(day) + absl::Hours(hour); } -std::vector Outcomes(int day, std::vector uuids) { +std::vector Outcomes(int day, std::vector uuids) { std::vector outcomes; const absl::Duration duration = absl::Hours(1); absl::Time start = TestDay(day); - for (int64 uuid : uuids) { + for (int64_t uuid : uuids) { outcomes.push_back({.exposure = {.start_time = start, .duration = duration}, .source_uuid = uuid}); start += duration; @@ -32,7 +32,7 @@ std::vector Outcomes(int day, std::vector uuids) { TEST(ExposureStoreTest, AddsAndRemovesExposures) { ExposureStore store; - auto get_notification_exposures = [&store](int64 uuid) { + auto get_notification_exposures = [&store](int64_t uuid) { ContactReport report = {.from_agent_uuid = uuid}; std::vector times; store.ProcessNotification(report, [×](const Exposure& exposure) { @@ -55,8 +55,8 @@ TEST(ExposureStoreTest, AddsAndRemovesExposures) { EXPECT_EQ(store.size(), 9); auto get_agents = [&store](absl::Time since) { - std::vector agents; - store.PerAgent(since, [&agents](int64 uuid) { agents.push_back(uuid); }); + std::vector agents; + store.PerAgent(since, [&agents](int64_t uuid) { agents.push_back(uuid); }); return agents; }; EXPECT_THAT(get_agents(TestDay(2)), @@ -66,16 +66,17 @@ TEST(ExposureStoreTest, AddsAndRemovesExposures) { EXPECT_THAT(get_agents(TestDay(4)), testing::UnorderedElementsAre(11, 12)); auto get_exposures = [&store](absl::Time since) { - std::vector> exposures; - store.PerExposure(since, [&exposures](int64 uuid, const Exposure& exposure, - const ContactReport* report) { - int64 from = report != nullptr ? report->from_agent_uuid : -1; - exposures.push_back({uuid, exposure.start_time, from}); - }); + std::vector> exposures; + store.PerExposure( + since, [&exposures](int64_t uuid, const Exposure& exposure, + const ContactReport* report) { + int64_t from = report != nullptr ? report->from_agent_uuid : -1; + exposures.push_back({uuid, exposure.start_time, from}); + }); return exposures; }; { - std::vector> expected = { + std::vector> expected = { {10, TestHour(2, 0), -1}, // {13, TestHour(2, 1), -1}, // {11, TestHour(2, 2), 11}, // @@ -90,7 +91,7 @@ TEST(ExposureStoreTest, AddsAndRemovesExposures) { testing::UnorderedElementsAreArray(expected)); } { - std::vector> expected = { + std::vector> expected = { {10, TestHour(3, 1), -1}, // {11, TestHour(4, 0), 11}, // {12, TestHour(4, 1), -1}, // diff --git a/agent_based_epidemic_sim/core/graph_location.cc b/agent_based_epidemic_sim/core/graph_location.cc index 82364fb7..50143f8b 100644 --- a/agent_based_epidemic_sim/core/graph_location.cc +++ b/agent_based_epidemic_sim/core/graph_location.cc @@ -35,9 +35,9 @@ namespace { class GraphLocation : public Location { public: - GraphLocation(int64 uuid, std::function location_transmissibility, + GraphLocation(int64_t uuid, std::function location_transmissibility, std::function drop_probability, - std::vector> graph, + std::vector> graph, const ExposureGenerator& exposure_generator) : graph_(std::move(graph)), uuid_(uuid), @@ -45,11 +45,11 @@ class GraphLocation : public Location { drop_probability_(drop_probability), exposure_generator_(exposure_generator) {} - int64 uuid() const override { return uuid_; } + int64_t uuid() const override { return uuid_; } void ProcessVisits(absl::Span visits, Broker* infection_broker) override { - thread_local absl::flat_hash_map visit_map; + thread_local absl::flat_hash_map visit_map; visit_map.clear(); for (const Visit& visit : visits) { visit_map[visit.agent_uuid] = visit; @@ -59,7 +59,7 @@ class GraphLocation : public Location { absl::BitGenRef gen = GetBitGen(); - for (const std::pair& edge : graph_) { + for (const std::pair& edge : graph_) { // Randomly drop some potential contacts. if (absl::Bernoulli(gen, drop_probability_())) { continue; @@ -90,12 +90,12 @@ class GraphLocation : public Location { } protected: - std::vector> graph_; + std::vector> graph_; private: virtual void MaybeUpdateGraph(absl::Span visits) {} - const int64 uuid_; + const int64_t uuid_; const std::function location_transmissibility_; const std::function drop_probability_; const ExposureGenerator& exposure_generator_; @@ -103,7 +103,7 @@ class GraphLocation : public Location { class RandomGraphLocation : public GraphLocation { public: - RandomGraphLocation(int64 uuid, + RandomGraphLocation(int64_t uuid, std::function location_transmissibility, std::function lockdown_multiplier, const ExposureGenerator& exposure_generator) @@ -117,7 +117,7 @@ class RandomGraphLocation : public GraphLocation { void MaybeUpdateGraph(absl::Span visits) override { // Construct list of agent UUIDs as potential endpoints for edges. An agent // is repeated once for each edge needed by it. - thread_local std::vector agent_uuids; + thread_local std::vector agent_uuids; internal::AgentUuidsFromRandomLocationVisits(visits, lockdown_multiplier_(), agent_uuids); // Connect random pairs till none remain. @@ -136,7 +136,7 @@ namespace internal { void AgentUuidsFromRandomLocationVisits(absl::Span visits, const float lockdown_multiplier, - std::vector& agent_uuids) { + std::vector& agent_uuids) { agent_uuids.clear(); for (const Visit& visit : visits) { agent_uuids.resize( @@ -146,12 +146,12 @@ void AgentUuidsFromRandomLocationVisits(absl::Span visits, } } -void ConnectAdjacentNodes(absl::Span agent_uuids, - std::vector>& graph) { +void ConnectAdjacentNodes(absl::Span agent_uuids, + std::vector>& graph) { graph.clear(); while (agent_uuids.size() >= 2) { - int64 a = agent_uuids[0]; - int64 b = agent_uuids[1]; + int64_t a = agent_uuids[0]; + int64_t b = agent_uuids[1]; if (a == b) { // Self-edges are not allowed. Try next pair. agent_uuids.remove_prefix(1); @@ -170,9 +170,9 @@ void ConnectAdjacentNodes(absl::Span agent_uuids, } // namespace internal std::unique_ptr NewGraphLocation( - int64 uuid, std::function location_transmissibility, + int64_t uuid, std::function location_transmissibility, std::function drop_probability, - std::vector> graph, + std::vector> graph, const ExposureGenerator& exposure_generator) { return absl::make_unique( uuid, std::move(location_transmissibility), std::move(drop_probability), @@ -180,7 +180,7 @@ std::unique_ptr NewGraphLocation( } std::unique_ptr NewRandomGraphLocation( - int64 uuid, std::function location_transmissibility, + int64_t uuid, std::function location_transmissibility, std::function lockdown_multiplier, const ExposureGenerator& exposure_generator) { return absl::make_unique( diff --git a/agent_based_epidemic_sim/core/graph_location_test.cc b/agent_based_epidemic_sim/core/graph_location_test.cc index 134ed497..98f02a7d 100644 --- a/agent_based_epidemic_sim/core/graph_location_test.cc +++ b/agent_based_epidemic_sim/core/graph_location_test.cc @@ -50,7 +50,7 @@ class FakeExposureGenerator : public ExposureGenerator { static constexpr int kLocationUUID = 1; -Visit GenerateVisit(int64 agent, HealthState::State health_state, +Visit GenerateVisit(int64_t agent, HealthState::State health_state, int random_location_edges = 1) { return { .location_uuid = kLocationUUID, @@ -62,8 +62,8 @@ Visit GenerateVisit(int64 agent, HealthState::State health_state, .random_location_edges = random_location_edges, }}; } -InfectionOutcome ExpectedOutcome(int64 agent, int64 source, float infectivity, - float transmissibility) { +InfectionOutcome ExpectedOutcome(int64_t agent, int64_t source, + float infectivity, float transmissibility) { return { .agent_uuid = agent, .exposure = @@ -124,7 +124,7 @@ TEST(GraphLocationTest, AllSamplesDropped) { } TEST(AgentUuidsFromRandomLocationVisits, Basic) { - std::vector agent_uuids; + std::vector agent_uuids; internal::AgentUuidsFromRandomLocationVisits( { GenerateVisit(0, HealthState::SUSCEPTIBLE, 2), @@ -142,7 +142,7 @@ TEST(AgentUuidsFromRandomLocationVisits, Basic) { TEST(AgentUuidsFromRandomLocationVisits, ClearsOutputArg) { // Tests that pre-existing values are removed from agent_uuids. - std::vector agent_uuids = {1, 2, 3}; + std::vector agent_uuids = {1, 2, 3}; internal::AgentUuidsFromRandomLocationVisits( { GenerateVisit(0, HealthState::SUSCEPTIBLE, 2), @@ -158,7 +158,7 @@ TEST(AgentUuidsFromRandomLocationVisits, ClearsOutputArg) { } TEST(ConnectAdjacentNodes, Basic) { - std::vector> graph; + std::vector> graph; internal::ConnectAdjacentNodes({1, 2, 3, 4, 5, 6, 7}, graph); EXPECT_THAT(graph, testing::ElementsAreArray({ testing::Pair(1, 2), @@ -169,7 +169,7 @@ TEST(ConnectAdjacentNodes, Basic) { TEST(ConnectAdjacentNodes, EdgesAreSortedAndDistinct) { // Tests that the graph's edges are sorted and distinct. - std::vector> graph; + std::vector> graph; internal::ConnectAdjacentNodes({2, 1, 3, 1, 3, 4, 1, 2}, graph); EXPECT_THAT(graph, testing::ElementsAreArray({ testing::Pair(1, 2), @@ -180,7 +180,7 @@ TEST(ConnectAdjacentNodes, EdgesAreSortedAndDistinct) { TEST(ConnectAdjacentNodes, NoSelfEdges) { // Tests that the graph does not include self-edges. - std::vector> graph; + std::vector> graph; internal::ConnectAdjacentNodes({1, 1, 2, 3, 3, 4}, graph); EXPECT_THAT(graph, testing::ElementsAreArray({ testing::Pair(1, 2), diff --git a/agent_based_epidemic_sim/core/indexed_location_visit_generator.cc b/agent_based_epidemic_sim/core/indexed_location_visit_generator.cc index 503aaa97..e8745daa 100644 --- a/agent_based_epidemic_sim/core/indexed_location_visit_generator.cc +++ b/agent_based_epidemic_sim/core/indexed_location_visit_generator.cc @@ -24,10 +24,10 @@ constexpr float kEpsilon = 1e-5; } // namespace IndexedLocationVisitGenerator::IndexedLocationVisitGenerator( - const std::vector& location_uuids) { + const std::vector& location_uuids) { std::vector location_durations; location_durations.reserve(location_uuids.size()); - for (const int64 location_uuid : location_uuids) { + for (const int64_t location_uuid : location_uuids) { location_durations.push_back( {.location_uuid = location_uuid, .sample_duration = [](float adjustment) { diff --git a/agent_based_epidemic_sim/core/indexed_location_visit_generator_test.cc b/agent_based_epidemic_sim/core/indexed_location_visit_generator_test.cc index f655995c..b0269615 100644 --- a/agent_based_epidemic_sim/core/indexed_location_visit_generator_test.cc +++ b/agent_based_epidemic_sim/core/indexed_location_visit_generator_test.cc @@ -27,7 +27,7 @@ absl::Duration VisitDuration(const Visit& visit) { } TEST(IndexedLocationVisitGeneratorTest, GeneratesVisits) { - std::vector location_uuids{0LL, 1LL, 2LL}; + std::vector location_uuids{0LL, 1LL, 2LL}; IndexedLocationVisitGenerator visit_generator(location_uuids); auto risk_score = NewNullRiskScore(); diff --git a/agent_based_epidemic_sim/core/location_discrete_event_simulator_builder_test.cc b/agent_based_epidemic_sim/core/location_discrete_event_simulator_builder_test.cc index 95127e6b..610ecf1a 100644 --- a/agent_based_epidemic_sim/core/location_discrete_event_simulator_builder_test.cc +++ b/agent_based_epidemic_sim/core/location_discrete_event_simulator_builder_test.cc @@ -23,7 +23,7 @@ namespace { class MockUuidGenerator : public UuidGenerator { public: - MOCK_METHOD(int64, GenerateUuid, (), (const, override)); + MOCK_METHOD(int64_t, GenerateUuid, (), (const, override)); }; TEST(LocationDiscreteEventSimulatorBuilderTest, BuildsAgents) { diff --git a/agent_based_epidemic_sim/core/location_discrete_event_simulator_test.cc b/agent_based_epidemic_sim/core/location_discrete_event_simulator_test.cc index 84ad2bb6..b0bda680 100644 --- a/agent_based_epidemic_sim/core/location_discrete_event_simulator_test.cc +++ b/agent_based_epidemic_sim/core/location_discrete_event_simulator_test.cc @@ -43,7 +43,7 @@ const ProximityTrace kFarProximityTrace({kFarProximity}); using testing::UnorderedElementsAreArray; std::vector InfectionOutcomesFromContacts( - const absl::Span contacts, const int64 uuid) { + const absl::Span contacts, const int64_t uuid) { std::vector infection_outcomes; for (const Contact& contact : contacts) { infection_outcomes.push_back( @@ -56,7 +56,7 @@ std::vector InfectionOutcomesFromContacts( } TEST(LocationDiscreteEventSimulatorTest, ContactTracing) { - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = 42LL, .agent_uuid = 0LL, .start_time = absl::FromUnixSeconds(0LL), @@ -180,7 +180,7 @@ TEST(LocationDiscreteEventSimulatorTest, ContactTracing) { TEST(LocationDiscreteEventSimulatorTest, ProcessVisitsRejectsWrongUuid) { auto infection_broker = absl::make_unique>(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = 314LL, .agent_uuid = 0LL, .start_time = absl::FromUnixSeconds(0LL), @@ -195,7 +195,7 @@ TEST(LocationDiscreteEventSimulatorTest, ProcessVisitsRejectsWrongUuid) { TEST(LocationDiscreteEventSimulatorTest, ProcessVisitsRejectsStartTimeNotBeforeEndTime) { auto infection_broker = absl::make_unique>(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = kUuid, .agent_uuid = 0LL, .start_time = absl::FromUnixSeconds(0LL), diff --git a/agent_based_epidemic_sim/core/risk_score.cc b/agent_based_epidemic_sim/core/risk_score.cc index 9fc41258..93e9226d 100644 --- a/agent_based_epidemic_sim/core/risk_score.cc +++ b/agent_based_epidemic_sim/core/risk_score.cc @@ -29,7 +29,7 @@ class NullRiskScore : public RiskScore { const ContactReport& notification) override {} VisitAdjustment GetVisitAdjustment(const Timestep& timestep, - int64 location_uuid) const override { + int64_t location_uuid) const override { return {.frequency_adjustment = 1.0, .duration_adjustment = 1.0}; } TestResult GetTestResult(const Timestep& timestep) const override { diff --git a/agent_based_epidemic_sim/core/seir_agent.cc b/agent_based_epidemic_sim/core/seir_agent.cc index 53af7394..1ca98dcf 100644 --- a/agent_based_epidemic_sim/core/seir_agent.cc +++ b/agent_based_epidemic_sim/core/seir_agent.cc @@ -76,7 +76,7 @@ class DefaultInfectivityModel : public InfectivityModel { /* static */ std::unique_ptr SEIRAgent::CreateSusceptible( - const int64 uuid, TransmissionModel* transmission_model, + const int64_t uuid, TransmissionModel* transmission_model, const InfectivityModel* infectivity_model, std::unique_ptr transition_model, const VisitGenerator& visit_generator, @@ -91,7 +91,7 @@ std::unique_ptr SEIRAgent::CreateSusceptible( /* static */ std::unique_ptr SEIRAgent::Create( - const int64 uuid, const HealthTransition& health_transition, + const int64_t uuid, const HealthTransition& health_transition, TransmissionModel* transmission_model, const InfectivityModel* infectivity_model, std::unique_ptr transition_model, @@ -224,18 +224,18 @@ void SEIRAgent::SendContactReports(const Timestep& timestep, } std::vector contact_reports; - exposures_.PerAgent(contact_report_send_cutoff_, - [this, &test_result, &contact_reports](const int64 uuid) { - contact_reports.push_back({ - .from_agent_uuid = this->uuid(), - .to_agent_uuid = uuid, - .test_result = test_result, - .initial_symptom_onset_time = - initial_symptom_onset_time_.has_value() - ? initial_symptom_onset_time_ - : test_result.time_requested, - }); - }); + exposures_.PerAgent(contact_report_send_cutoff_, [this, &test_result, + &contact_reports]( + const int64_t uuid) { + contact_reports.push_back({ + .from_agent_uuid = this->uuid(), + .to_agent_uuid = uuid, + .test_result = test_result, + .initial_symptom_onset_time = initial_symptom_onset_time_.has_value() + ? initial_symptom_onset_time_ + : test_result.time_requested, + }); + }); contact_report_send_cutoff_ = timestep.start_time(); broker->Send(contact_reports); } diff --git a/agent_based_epidemic_sim/core/seir_agent_test.cc b/agent_based_epidemic_sim/core/seir_agent_test.cc index f14da698..580b8d49 100644 --- a/agent_based_epidemic_sim/core/seir_agent_test.cc +++ b/agent_based_epidemic_sim/core/seir_agent_test.cc @@ -45,7 +45,7 @@ absl::Time TimeFromDayAndHour(const int day, const int hour) { absl::Time TimeFromDay(const int day) { return TimeFromDayAndHour(day, 0); } std::vector OutcomesFromContacts( - const int64 agent_uuid, absl::Span contacts) { + const int64_t agent_uuid, absl::Span contacts) { std::vector outcomes; for (const Contact& contact : contacts) { outcomes.push_back({ @@ -75,7 +75,7 @@ TEST(SEIRAgentTest, ComputesVisits) { .time = absl::FromUnixSeconds(43200LL), .health_state = HealthState::INFECTIOUS}))) .Times(1); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = 0LL, .start_time = absl::FromUnixSeconds(0LL), .end_time = absl::FromUnixSeconds(28800LL)}, @@ -141,7 +141,7 @@ TEST(SEIRAgentTest, InitializesSusceptibleState) { auto risk_score = NewNullRiskScore(); const Timestep timestep(absl::UnixEpoch(), absl::Hours(24)); EXPECT_CALL(*transition_model, GetNextHealthTransition).Times(0); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = 0LL, .start_time = absl::FromUnixSeconds(0LL), .end_time = absl::FromUnixSeconds(86400LL)}}; @@ -175,7 +175,7 @@ TEST(SEIRAgentTest, InitializesNonSusceptibleState) { .WillOnce( Return(HealthTransition{.time = absl::FromUnixSeconds(86400LL), .health_state = HealthState::INFECTIOUS})); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = 0LL, .start_time = absl::FromUnixSeconds(0LL), .end_time = absl::FromUnixSeconds(86400LL)}}; @@ -207,7 +207,7 @@ TEST(SEIRAgentTest, SetsInfectivityCorrectly) { MockTransmissionModel transmission_model; auto risk_score = NewNullRiskScore(); const Timestep timestep(absl::UnixEpoch(), absl::Hours(24)); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = 0LL, .start_time = absl::FromUnixSeconds(43202LL), .end_time = absl::FromUnixSeconds(43203LL)}}; @@ -261,7 +261,7 @@ TEST(SEIRAgentTest, RespectsTimestepBasedDwellTimeAndFiltersZeroIntervals) { .WillOnce( Return(HealthTransition{.time = absl::FromUnixSeconds(2LL * 86400LL), .health_state = HealthState::RECOVERED})); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector visits{Visit{.location_uuid = 0LL, .start_time = absl::FromUnixSeconds(0LL), .end_time = absl::FromUnixSeconds(86400LL)}}; @@ -308,7 +308,7 @@ TEST(SEIRAgentTest, ProcessesInfectionOutcomesIgnoresIfAlreadyExposed) { .WillOnce(Return(HealthTransition{.time = absl::FromUnixSeconds(-1LL), .health_state = HealthState::EXPOSED})); auto risk_score = NewNullRiskScore(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; auto agent = SEIRAgent::CreateSusceptible( kUuid, &transmission_model, SEIRAgent::default_infectivity_model(), @@ -347,7 +347,7 @@ TEST(SEIRAgentTest, ProcessesInfectionOutcomesRemainsSusceptible) { auto visit_generator = absl::make_unique(); MockTransmissionModel transmission_model; auto risk_score = NewNullRiskScore(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; EXPECT_CALL(transmission_model, GetInfectionOutcome(_)) .Times(1) @@ -376,7 +376,7 @@ TEST(SEIRAgentTest, ProcessesInfectionOutcomesMultipleExposuresSameContact) { auto visit_generator = absl::make_unique(); MockTransmissionModel transmission_model; auto risk_score = NewNullRiskScore(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; EXPECT_CALL(transmission_model, GetInfectionOutcome(_)).Times(1); auto agent = SEIRAgent::CreateSusceptible( @@ -403,7 +403,7 @@ TEST(SEIRAgentTest, ProcessInfectionOutcomesRejectsWrongUuid) { auto visit_generator = absl::make_unique(); MockTransmissionModel transmission_model; auto risk_score = NewNullRiskScore(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector infection_outcomes{InfectionOutcome{ .agent_uuid = kUuid + 1, }}; @@ -421,7 +421,7 @@ TEST(SEIRAgentTest, ProcessInfectionOutcomesReturnsNoOpIfNonePresent) { MockTransmissionModel transmission_model; auto risk_score = NewNullRiskScore(); EXPECT_CALL(*transition_model, GetNextHealthTransition).Times(0); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; auto agent = SEIRAgent::CreateSusceptible( kUuid, &transmission_model, SEIRAgent::default_infectivity_model(), std::move(transition_model), *visit_generator, std::move(risk_score)); @@ -433,7 +433,7 @@ TEST(SEIRAgentTest, ProcessInfectionOutcomesReturnsNoOpIfNonePresent) { // contact reports. TEST(SEIRAgentTest, ProcessInfectionOutcomesAndUpdateContactReportsUpdateRiskScore) { - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; auto transition_model = absl::make_unique(); auto visit_generator = absl::make_unique(); auto contact_report_broker = absl::make_unique>(); @@ -518,7 +518,7 @@ TEST(SEIRAgentTest, PositiveTest) { }; EXPECT_CALL(*risk_score, AddHealthStateTransistion(transition)); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; std::vector contacts = {{ .other_uuid = 314LL, .exposure = {.start_time = absl::FromUnixSeconds(0LL), @@ -567,7 +567,7 @@ TEST(SEIRAgentTest, PositiveTest) { TEST(SEIRAgentTest, NegativeTestResult) { auto transition_model = absl::make_unique(); auto visit_generator = absl::make_unique(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; auto risk_score = absl::make_unique(); EXPECT_CALL(*risk_score, ContactRetentionDuration()) .WillRepeatedly(Return(absl::Hours(24 * 14))); @@ -612,7 +612,7 @@ TEST(SEIRAgentTest, NegativeTestResult) { } TEST(SEIRAgentTest, SendContactReports) { - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; auto transition_model = absl::make_unique(); EXPECT_CALL(*transition_model, GetNextHealthTransition(_)) .WillRepeatedly( @@ -803,7 +803,7 @@ TEST(SEIRAgentTest, SendContactReports) { } TEST(SEIRAgentTest, SendContactReportsBeforeAndAfterSymptoms) { - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; auto transition_model = absl::make_unique(); EXPECT_CALL(*transition_model, GetNextHealthTransition(_)) .WillRepeatedly( @@ -899,7 +899,7 @@ TEST(SEIRAgentTest, UpdateContactReportsRejectsWrongUuid) { auto visit_generator = absl::make_unique(); MockTransmissionModel transmission_model; auto risk_score = NewNullRiskScore(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; const std::vector contact_reports{ {.from_agent_uuid = kUuid, .to_agent_uuid = kUuid + 1}}; auto agent = SEIRAgent::CreateSusceptible( @@ -920,7 +920,7 @@ TEST(SEIRAgentTest, SeedsInfection) { auto visit_generator = absl::make_unique(); MockTransmissionModel transmission_model; auto risk_score = NewNullRiskScore(); - const int64 kUuid = 42LL; + const int64_t kUuid = 42LL; auto agent = SEIRAgent::CreateSusceptible( kUuid, &transmission_model, SEIRAgent::default_infectivity_model(), std::move(transition_model), *visit_generator, std::move(risk_score)); diff --git a/agent_based_epidemic_sim/core/simulation.cc b/agent_based_epidemic_sim/core/simulation.cc index aeaccc3a..f88d8298 100644 --- a/agent_based_epidemic_sim/core/simulation.cc +++ b/agent_based_epidemic_sim/core/simulation.cc @@ -43,9 +43,11 @@ auto CompareUuid = [](const auto& a, const auto& b) { return a->uuid() < b->uuid(); }; -int64 GetDestId(const Visit& visit) { return visit.location_uuid; } -int64 GetDestId(const InfectionOutcome& outcome) { return outcome.agent_uuid; } -int64 GetDestId(const ContactReport& report) { return report.to_agent_uuid; } +int64_t GetDestId(const Visit& visit) { return visit.location_uuid; } +int64_t GetDestId(const InfectionOutcome& outcome) { + return outcome.agent_uuid; +} +int64_t GetDestId(const ContactReport& report) { return report.to_agent_uuid; } bool CompareDestId(const Visit& a, const Visit& b) { if (a.location_uuid != b.location_uuid) { @@ -77,7 +79,7 @@ void SortByDest(absl::Span msgs) { template std::pair, absl::Span> SplitMessages( - int64 uuid, absl::Span messages) { + int64_t uuid, absl::Span messages) { DCHECK(messages.empty() || GetDestId(messages[0]) >= uuid) << "Message found for non-local entity: " << GetDestId(messages[0]) << " msg: " << messages[0]; @@ -272,7 +274,7 @@ class Chunker { template int Chunk(const Msg& msg) const { - int64 dest = GetDestId(msg); + int64_t dest = GetDestId(msg); auto iter = chunk_map_.find(dest); DCHECK(iter != chunk_map_.end()); return iter->second; @@ -283,7 +285,7 @@ class Chunker { private: absl::FixedArray>> chunks_; - absl::flat_hash_map chunk_map_; + absl::flat_hash_map chunk_map_; }; // WorkQueueBroker is the thread-safe analog to ConsumableBroker. It can diff --git a/agent_based_epidemic_sim/core/simulation_test.cc b/agent_based_epidemic_sim/core/simulation_test.cc index 71adaeb0..3416d3df 100644 --- a/agent_based_epidemic_sim/core/simulation_test.cc +++ b/agent_based_epidemic_sim/core/simulation_test.cc @@ -42,7 +42,7 @@ const int kVisitsPerAgent = 7; const int kReportsPerAgent = 3; const int kNumSteps = 5; -std::array VisitLocations(int64 agent_id) { +std::array VisitLocations(int64_t agent_id) { std::array ret; for (int i = 0; i < kVisitsPerAgent; i++) { ret[i] = (agent_id + 7 * i) % kNumLocations; @@ -50,7 +50,7 @@ std::array VisitLocations(int64 agent_id) { return ret; } -std::array ReportRecipients(int64 agent_id) { +std::array ReportRecipients(int64_t agent_id) { std::array ret; for (int i = 0; i < kReportsPerAgent; i++) { ret[i] = (agent_id + 5 * i) % kNumAgents; @@ -58,7 +58,7 @@ std::array ReportRecipients(int64 agent_id) { return ret; } -std::unique_ptr MakeAgent(int64 uuid, OutcomeMap* outcome_counts, +std::unique_ptr MakeAgent(int64_t uuid, OutcomeMap* outcome_counts, ReportMap* report_counts) { auto agent = absl::make_unique>(); auto last_timestep = std::make_shared>(); @@ -118,7 +118,7 @@ std::unique_ptr MakeAgent(int64 uuid, OutcomeMap* outcome_counts, return agent; } -std::unique_ptr MakeLocation(int64 uuid, VisitMap* visit_counts) { +std::unique_ptr MakeLocation(int64_t uuid, VisitMap* visit_counts) { auto location = absl::make_unique>(); ON_CALL(*location, uuid()).WillByDefault([uuid]() { return uuid; }); ON_CALL(*location, ProcessVisits(testing::_, testing::_)) @@ -163,8 +163,8 @@ class FakeObserver : public AgentInfectionObserver, private: friend class FakeObserverFactory; - absl::flat_hash_map agent_stats_; - absl::flat_hash_map location_stats_; + absl::flat_hash_map agent_stats_; + absl::flat_hash_map location_stats_; }; class FakeObserverFactory : public ObserverFactory { @@ -201,8 +201,8 @@ class FakeObserverFactory : public ObserverFactory { } private: - absl::flat_hash_map agent_stats_; - absl::flat_hash_map location_stats_; + absl::flat_hash_map agent_stats_; + absl::flat_hash_map location_stats_; }; using SimBuilder = std::function(