analyze_result.h Source File
|
CPP API
|
memilio/data/analyze_result.h
Go to the documentation of this file.
69 using InterpolateResultT = std::decay_t<decltype(interpolate_simulation_result(std::declval<T>()))>;
78 std::vector<InterpolateResultT<T>> interpolate_ensemble_results(const std::vector<T>& ensemble_results)
82 std::transform(ensemble_results.begin(), ensemble_results.end(), std::back_inserter(interpolated), [](auto& run) {
89 std::vector<std::vector<TimeSeries<FP>>> sum_nodes(const std::vector<std::vector<TimeSeries<FP>>>& ensemble_result);
100 std::vector<TimeSeries<FP>> ensemble_mean(const std::vector<std::vector<TimeSeries<FP>>>& ensemble_results);
114 std::vector<TimeSeries<FP>> ensemble_percentile(const std::vector<std::vector<TimeSeries<FP>>>& ensemble_result, FP p);
123 interpolate_simulation_result(const Graph<SimulationNode<FP, Simulation>, MobilityEdge<FP>>& graph_result)
127 std::transform(graph_result.nodes().begin(), graph_result.nodes().end(), std::back_inserter(interpolated),
171 for (auto iter_node1 = result1.begin(), iter_node2 = result2.begin(); iter_node1 < result1.end();
187 TimeSeries<FP> interpolate_simulation_result(const TimeSeries<FP>& simulation_result, const FP abs_tol)
218 "All but the first and the last time point of interpolation have lie between simulation times (strictly "
229 // add first time point of interpolation times in case it is smaller than the first time point of simulation_result
231 // this is necessary even if the tolerance is 0 due to the way the comparison in the loop is implemented (< and >=)
239 sim_idx < simulation_result.get_num_time_points() - 1 && interp_idx < interpolation_times.size();) {
257 // add last time point of interpolation times in case it is larger than the last time point of simulation_result
261 interpolated.add_time_point(interpolation_times[interp_idx], simulation_result.get_last_value());
268 std::vector<std::vector<TimeSeries<FP>>> sum_nodes(const std::vector<std::vector<TimeSeries<FP>>>& ensemble_result)
290 std::vector<TimeSeries<FP>> ensemble_mean(const std::vector<std::vector<TimeSeries<FP>>>& ensemble_result)
297 std::vector<TimeSeries<FP>> mean(num_nodes, TimeSeries<FP>::zero(num_time_points, num_elements));
317 std::vector<TimeSeries<FP>> ensemble_percentile(const std::vector<std::vector<TimeSeries<FP>>>& ensemble_result, FP p)
326 std::vector<TimeSeries<FP>> percentile(num_nodes, TimeSeries<FP>::zero(num_time_points, num_elements));
356 for (auto iter_node1 = result1.begin(), iter_node2 = result2.begin(); iter_node1 < result1.end();
377 IOResult<TimeSeries<FP>> merge_time_series(const TimeSeries<FP>& ts1, const TimeSeries<FP>& ts2,
represents the mobility between two nodes.
Definition: metapopulation_mobility_instant.h:298
represents the simulation in one node of the graph.
Definition: metapopulation_mobility_instant.h:41
stores vectors of values at time points (or some other abstract variable) the value at each time poin...
Definition: time_series.h:58
void reserve(Eigen::Index n)
reserve capacity for n time points
Definition: time_series.h:332
Eigen::Ref< const Vector > get_value(Eigen::Index i) const
reference to value vector at time point i
Definition: time_series.h:298
Eigen::Index get_num_elements() const
number of elements of vector at each time point
Definition: time_series.h:205
bool is_strictly_monotonic() const
Check if the time is strictly monotonic increasing.
Definition: time_series.h:185
FP & get_last_time()
time of time point at index num_time_points - 1
Definition: time_series.h:286
Eigen::Index get_num_time_points() const
number of time points in the series
Definition: time_series.h:197
FP & get_time(Eigen::Index i)
time of time point at index i
Definition: time_series.h:272
Eigen::Ref< Vector > add_time_point()
add one uninitialized time point
Definition: time_series.h:221
Eigen::Ref< const Vector > get_last_value() const
reference to value vector at time point (num_timepoints - 1)
Definition: time_series.h:320
ad::internal::unary_intermediate< AD_TAPE_REAL, ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 >, ad::operations::ad_sqrt< AD_TAPE_REAL > > sqrt(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x1)
Definition: ad.hpp:1023
static double floor(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x)
Definition: ad.hpp:2451
static double ceil(const ad::internal::active_type< AD_TAPE_REAL, DATA_HANDLER_1 > &x)
Definition: ad.hpp:2449
int size(Comm comm)
Return the size of the given communicator.
Definition: miompi.cpp:75
A collection of classes to simplify handling of matrix shapes in meta programming.
Definition: models/abm/analyze_result.h:30
auto failure(const IOStatus &s)
Create an object that is implicitly convertible to an error IOResult<T>.
Definition: io.h:380
@ InvalidValue
IOResult< TimeSeries< FP > > merge_time_series(const TimeSeries< FP > &ts1, const TimeSeries< FP > &ts2, bool add_values=false)
This function merges two TimeSeries by copying their time points and values to a new TimeSeries in th...
Definition: memilio/data/analyze_result.h:377
void log_warning(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:112
FP result_distance_2norm(const std::vector< mio::TimeSeries< FP >> &result1, const std::vector< mio::TimeSeries< FP >> &result2)
Compute the distance between two SECIR simulation results.
Definition: memilio/data/analyze_result.h:346
std::decay_t< decltype(interpolate_simulation_result(std::declval< T >()))> InterpolateResultT
helper template, type returned by overload interpolate_simulation_result(T t)
Definition: memilio/data/analyze_result.h:69
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359
void log_error(spdlog::string_view_t fmt, const Args &... args)
Definition: logging.h:100
std::vector< TimeSeries< FP > > ensemble_percentile(const std::vector< std::vector< TimeSeries< FP >>> &ensemble_result, FP p)
computes the p percentile of the result for each compartment, node, and time point.
Definition: memilio/data/analyze_result.h:317
TimeSeries< FP > interpolate_simulation_result(const TimeSeries< FP > &simulation_result, const FP abs_tol=FP{100.} *Limits< FP >::zero_tolerance())
Interpolate a given time series with evenly spaced, integer time points that represent whole days.
Definition: memilio/data/analyze_result.h:187
std::vector< TimeSeries< FP > > ensemble_mean(const std::vector< std::vector< TimeSeries< FP >>> &ensemble_results)
computes mean of each compartment, node, and time point over all runs input must be uniform as return...
Definition: memilio/data/analyze_result.h:290
std::vector< InterpolateResultT< T > > interpolate_ensemble_results(const std::vector< T > &ensemble_results)
Interpolates results of all runs with evenly spaced, integer time points that represent whole days.
Definition: memilio/data/analyze_result.h:78
std::vector< std::vector< TimeSeries< FP > > > sum_nodes(const std::vector< std::vector< TimeSeries< FP >>> &ensemble_result)
Definition: memilio/data/analyze_result.h:268
boost::outcome_v2::unchecked< T, IOStatus > IOResult
Value-or-error type for operations that return a value but can fail.
Definition: io.h:353
static constexpr FP zero_tolerance()=delete
Generated by