graph.h Source File
|
CPP API
|
graph.h
Go to the documentation of this file.
116 return e1.start_node_idx == e2.start_node_idx && e1.end_node_idx == e2.end_node_idx && e1.property == e2.property;
151 //ensure correct std::is_copy_constructible; it's not correct by default because the nodes and edges are stored in std::vector
152 : not_copyable_if_t<!(std::is_copy_constructible_v<NodePropertyT> && std::is_copy_constructible_v<EdgePropertyT>)>
241 insert_sorted_replace(m_edges, Edge<EdgePropertyT>(start_node_idx, end_node_idx, std::forward<Args>(args)...),
330 template <typename FP, class TestAndTrace, class ContactPattern, class Model, class MobilityParams, class Parameters,
332 IOResult<void> set_nodes(const Parameters& params, Date start_date, Date end_date, const fs::path& data_dir,
340 BOOST_OUTCOME_TRY(auto&& node_ids, node_func(population_data_path, is_node_for_county, rki_age_groups));
346 BOOST_OUTCOME_TRY(read_func(nodes, start_date, node_ids, scaling_factor_inf, scaling_factor_icu, data_dir.string(),
356 tnt_value.set_distribution(mio::ParameterDistributionUniform(0.8 * tnt_capacity, 1.2 * tnt_capacity));
369 std::vector<std::pair<mio::SimulationTime<FP>, mio::SimulationTime<FP>>>(holiday_periods.size());
371 holiday_periods.begin(), holiday_periods.end(), contacts.get_school_holidays().begin(), [=](auto& period) {
372 return std::make_pair(mio::SimulationTime<FP>(mio::get_offset_in_days(period.first, start_date)),
382 compartment_value.set_distribution(mio::ParameterDistributionUniform(0.9 * compartment_value.value(),
403 template <typename FP, class ContactLocation, class Model, class MobilityParams, class MobilityCoefficientGroup,
405 IOResult<void> set_edges(const fs::path& mobility_data_file, Graph<Model, MobilityParams>& params_graph,
423 // so that the same NPIs/dampings can be used for both (e.g. more home office => fewer commuters)
425 auto num_age_groups = (size_t)params_graph.nodes()[county_idx_i].property.parameters.get_num_groups();
443 //thresholds are chosen empirically so that more than 99% of mobility is covered, approx. 1/3 of the edges
445 params_graph.add_edge(county_idx_i, county_idx_j, std::move(mobility_coeffs), indices_of_saved_edges);
Graph()=default
auto out_edges(size_t node_idx)
range of edges going out from a specific node
Definition: graph.h:283
requires std::constructible_from< EdgePropertyT, Args... > void add_edge(size_t start_node_idx, size_t end_node_idx, Args &&... args)
add an edge to the graph.
Definition: graph.h:238
auto out_edges(size_t node_idx) const
range of edges going out from a specific node
Definition: graph.h:291
requires std::constructible_from< NodePropertyT, Args... > void add_node(int id, Args &&... args)
add a node to the graph.
Definition: graph.h:223
requires std::constructible_from< NodePropertyT, Args... > Graph(const std::vector< int > &node_ids, Args &&... node_args)
Construct graph without edges, creating a node for each id in node_ids from the same node_args.
Definition: graph.h:185
requires std::constructible_from< NodePropertyT, Args... > Graph(const int number_of_nodes, Args &&... args)
Construct graph without edges, creating each node from the same node_args with default node ids [0,...
Definition: graph.h:197
Graph(const std::vector< int > &node_ids, const std::vector< NodePropertyT > &node_properties)
Construct graph without edges from pairs of node_ids and node_properties.
Definition: graph.h:161
Graph(std::vector< NodePropertyT > &node_properties)
Construct graph without edges from node_properties with default node ids [0, 1, .....
Definition: graph.h:173
Graph(std::vector< Node< NodePropertyT >> &&nodes, std::vector< Edge< EdgePropertyT >> &&edges)
Construct graph containing the given nodes and edges.
Definition: graph.h:209
An Index with more than one template parameter combines several Index objects.
Definition: index.h:181
Definition: parameter_distributions.h:440
Parameters of the simulation that are the same everywhere within the Model.
Definition: abm/parameters.h:764
size_t get_num_groups() const
Get the number of the age groups.
Definition: abm/parameters.h:783
int size(Comm comm)
Return the size of the given communicator.
Definition: miompi.cpp:75
Range< std::vector< std::pair< Date, Date > >::const_iterator > get_holidays(StateId state)
get the holidays in a german state.
Definition: regions.cpp:37
StateId get_state_id(int county)
get the id of the state that the specified county is in.
Definition: regions.cpp:32
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
requires details::IsElementReference< M > RowMajorIterator< M, false > end(M &m)
create a non-const end iterator for the matrix m.
Definition: eigen_util.h:449
Range(std::pair< I, S > iterator_pair) -> Range< I, S >
Deduction guide to correctly deduce range type when constructed from a pair.
typename not_copyable_if< Cond >::type not_copyable_if_t
equivalent to not_copyable_if<Cond>::type.
Definition: metaprogramming.h:78
requires HasOstreamOperator< T > std::ostream & operator<<(std::ostream &os, const Edge< T > &e)
out stream operator for edges if edge property type has stream operator defined
Definition: graph.h:129
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:380
@ InvalidValue
bool operator==(const Node< T > &n1, const Node< T > &n2)
comparison operator if node property type is equality comparable
Definition: graph.h:100
IOResult< void > set_edges(const fs::path &mobility_data_file, Graph< Model, MobilityParams > ¶ms_graph, std::initializer_list< InfectionState > &mobile_compartments, size_t contact_locations_size, ReadFunction &&read_func, std::vector< FP > commuting_weights, std::vector< std::vector< size_t >> indices_of_saved_edges={})
Sets the graph edges.
Definition: graph.h:405
requires(!std::is_trivial_v< T >) void BinarySerializerObject
Definition: binary_serializer.h:333
requires HasOstreamOperator< T > void print_graph_object(std::ostream &os, size_t idx, const T &o)
Definition: graph.h:462
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359
requires details::IsElementReference< M > RowMajorIterator< M, false > begin(M &m)
create a non-const iterator to first element of the matrix m.
Definition: eigen_util.h:421
IOResult< void > set_nodes(const Parameters ¶ms, Date start_date, Date end_date, const fs::path &data_dir, const std::string &population_data_path, bool is_node_for_county, Graph< Model, MobilityParams > ¶ms_graph, ReadFunction &&read_func, NodeIdFunction &&node_func, const std::vector< FP > &scaling_factor_inf, FP scaling_factor_icu, FP tnt_capacity_factor, int num_days=0, bool export_time_series=false, bool rki_age_groups=true)
Sets the graph nodes for counties or districts.
Definition: graph.h:332
DampingMatrixExpressionGroup< FP, MobilityCoefficients< FP > > MobilityCoefficientGroup
sum of time dependent mobility coefficients.
Definition: metapopulation_mobility_instant.h:115
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:353
void insert_sorted_replace(std::vector< T > &vec, T const &item, Pred pred)
inserts element in a sorted vector, replacing items that are equal precondition: elements in the vect...
Definition: stl_util.h:66
Definition: io.h:94
The AgeGroup struct is used as a dynamically sized tag for all age dependent categories.
Definition: age_group.h:32
Definition: graph.h:57
Definition: graph.h:50
Definition: graph.h:43
Generated by