graph.h Source File
|
CPP API
|
graph.h
Go to the documentation of this file.
111 return e1.start_node_idx == e2.start_node_idx && e1.end_node_idx == e2.end_node_idx && e1.property == e2.property;
146 //ensure correct std::is_copy_constructible; it's not correct by default because the nodes and edges are stored in std::vector
147 : not_copyable_if_t<!(std::is_copy_constructible_v<NodePropertyT> && std::is_copy_constructible_v<EdgePropertyT>)>
236 insert_sorted_replace(m_edges, Edge<EdgePropertyT>(start_node_idx, end_node_idx, std::forward<Args>(args)...),
325 template <typename FP, class TestAndTrace, class ContactPattern, class Model, class MobilityParams, class Parameters,
335 BOOST_OUTCOME_TRY(auto&& node_ids, node_func(population_data_path, is_node_for_county, rki_age_groups));
341 BOOST_OUTCOME_TRY(read_func(nodes, start_date, node_ids, scaling_factor_inf, scaling_factor_icu, data_dir.string(),
351 tnt_value.set_distribution(mio::ParameterDistributionUniform(0.8 * tnt_capacity, 1.2 * tnt_capacity));
364 std::vector<std::pair<mio::SimulationTime<FP>, mio::SimulationTime<FP>>>(holiday_periods.size());
366 holiday_periods.begin(), holiday_periods.end(), contacts.get_school_holidays().begin(), [=](auto& period) {
367 return std::make_pair(mio::SimulationTime<FP>(mio::get_offset_in_days(period.first, start_date)),
377 compartment_value.set_distribution(mio::ParameterDistributionUniform(0.9 * compartment_value.value(),
398 template <typename FP, class ContactLocation, class Model, class MobilityParams, class MobilityCoefficientGroup,
400 IOResult<void> set_edges(const std::filesystem::path& mobility_data_file, Graph<Model, MobilityParams>& params_graph,
418 // so that the same NPIs/dampings can be used for both (e.g. more home office => fewer commuters)
420 auto num_age_groups = (size_t)params_graph.nodes()[county_idx_i].property.parameters.get_num_groups();
438 //thresholds are chosen empirically so that more than 99% of mobility is covered, approx. 1/3 of the edges
440 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:278
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:233
auto out_edges(size_t node_idx) const
range of edges going out from a specific node
Definition: graph.h:286
requires std::constructible_from< NodePropertyT, Args... > void add_node(int id, Args &&... args)
add a node to the graph.
Definition: graph.h:218
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:180
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:192
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:156
Graph(std::vector< NodePropertyT > &node_properties)
Construct graph without edges from node_properties with default node ids [0, 1, .....
Definition: graph.h:168
Graph(std::vector< Node< NodePropertyT >> &&nodes, std::vector< Edge< EdgePropertyT >> &&edges)
Construct graph containing the given nodes and edges.
Definition: graph.h:204
An Index with more than one template parameter combines several Index objects.
Definition: index.h:191
Definition: parameter_distributions.h:440
Typesafe wrapper for a floating-point simulation time value (in days).
Definition: damping.h:78
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:124
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:381
@ InvalidValue
bool operator==(const Node< T > &n1, const Node< T > &n2)
comparison operator if node property type is equality comparable
Definition: graph.h:95
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:457
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:360
IOResult< void > set_nodes(const Parameters ¶ms, Date start_date, Date end_date, const std::filesystem::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:327
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_edges(const std::filesystem::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:400
DampingMatrixExpressionGroup< FP, MobilityCoefficients< FP > > MobilityCoefficientGroup
sum of time dependent mobility coefficients.
Definition: metapopulation_mobility_instant.h:114
std::filesystem::path data_dir()
Returns the absolute path to the project directory.
Definition: directories.cpp:30
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:354
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:82
Definition: io.h:95
Definition: graph.h:52
Definition: graph.h:45
Definition: graph.h:38
Generated by