mio Namespace Reference

CPP API: mio Namespace Reference
mio Namespace Reference

A collection of classes to simplify handling of matrix shapes in meta programming. More...

Namespaces

 abm
 
 dabm
 
 details
 
 geo
 
 glsecir
 
 hybrid
 
 isecir
 
 iseir
 
 lsecir
 
 lsecir2d
 
 mpi
 
 omp
 
 omseirs4
 
 oseair
 
 osecir
 
 osecirts
 
 osecirvvs
 
 oseir
 
 oseirdb
 
 oseirv
 
 osir
 
 regions
 Contains utilities that depend on geographical regions.
 
 smm
 
 sseirvv
 
 ssir
 
 ssirs
 
 timing
 

Classes

class  ABMMobilityEdge
 Represents the mobility between two nodes. More...
 
class  ABMSimulationNode
 Represents the ABM simulation in one node of the ABM graph model. More...
 
class  AbstractParameterDistribution
 This class represents an arbitrary ParameterDistribution. More...
 
struct  AdoptionRate
 Struct defining a possible status adoption in a Model based on Poisson Processes. More...
 
struct  AgeGroup
 The AgeGroup struct is used as a dynamically sized tag for all age dependent categories. More...
 
struct  back_inserter_second_element
 Back inserter that ignores the first element of pairs given to it. More...
 
class  BinarySerializerContext
 Serializes objects in binary format. More...
 
class  BinarySerializerObject
 Stores a binary serialized object. More...
 
struct  BlendingFactorLocal
 Blending factor for local ICU occupancy. More...
 
struct  BlendingFactorRegional
 Blending factor for regional ICU occupancy. More...
 
class  ByteStream
 In-memory stream of bytes. More...
 
class  ColumnVectorShape
 shape of a column vector. More...
 
struct  CompartmentalModel
 CompartmentalModel is a template for a compartmental model for an array of initial populations and a parameter set. More...
 
struct  ConstantFunction
 Class that defines a constant function. More...
 
struct  ConstVisitor
 
struct  ConstVisitor< T >
 
struct  ConstVisitor< T, Types... >
 
class  ContactMatrix
 represents time dependent contact frequencies between groups. More...
 
class  ContactMatrixGroup
 represents a collection of contact frequency matrices that whose sum is the total number of contacts. More...
 
struct  ContactReductionMax
 Maximum allowed contact reduction factors per location. More...
 
struct  ContactReductionMin
 Minimum allowed contact reduction factors per location. More...
 
class  ControlledStepperWrapper
 This is an adaptive IntegratorCore. More...
 
class  CustomIndexArray
 A class template for an array with custom indices. More...
 
struct  CVPlainMatrix
 helper to get the matrix type from an eigen expression with correct const volatile qualitfications. More...
 
struct  CVPlainMatrix< Eigen::Ref< const M > >
 
class  Damping
 represent interventions or effects that affect contact frequencies between multiple groups. More...
 
class  DampingMatrixExpression
 represents the coefficient wise matrix (or vector) expression B - D * M where B is a baseline, M is a minimum and D is some time dependent complex damping factor. More...
 
class  DampingMatrixExpressionGroup
 represents a collection of DampingMatrixExpressions that are summed up. More...
 
class  Dampings
 collection of dampings at different time points. More...
 
class  DampingSampling
 randomly sample dampings for e.g. More...
 
struct  DataWriterToMemory
 This class writes data retrieved from loggers to memory. More...
 
struct  Date
 Simple date representation as year, month, and day. More...
 
struct  DefaultFactory
 Creates an instance of T for later initialization. More...
 
struct  DefaultFactory< abm::Mask >
 Creates an instance of abm::Mask for default serialization. More...
 
struct  DefaultFactory< abm::Person >
 Creates an instance of abm::Person for default serialization. More...
 
struct  DefaultFactory< abm::ProtectionEvent >
 Creates an instance of abm::ProtectionEvent for default serialization. More...
 
struct  DefaultFactory< abm::Trip >
 Creates an instance of abm::Trip for default serialization. More...
 
class  DynamicNPIs
 represents non-pharmaceutical interventions (NPI) that are activated during the simulation if some value (e.g. More...
 
struct  Edge
 represents an edge of the graph More...
 
struct  EdgeBase
 
struct  ErlangDensity
 Class that defines the probability density function corresponding to the Erlang distribution with the parameters shape and scale depending on the state age. More...
 
class  EulerIntegratorCore
 Simple explicit euler integration y(t+1) = y(t) + h*f(t,y) for ODE y'(t) = f(t,y) More...
 
class  EulerMaruyamaIntegratorCore
 Simple explicit integration y(t+1) = y(t) + h*f(t,y) + sqrt(h) * noise_f(t,y) for SDE systems. More...
 
class  ExplicitStepperWrapper
 This is a non-adaptive IntegratorCore. More...
 
struct  ExponentialSurvivalFunction
 Class that defines the survival function corresponding to the exponential distribution depending on the state age. More...
 
class  FeedbackGraphSimulation
 
class  FeedbackSimulation
 A generic feedback simulation extending existing simulations with a feedback mechanism. More...
 
struct  Flow
 A Flow defines a possible transition between two Compartments in a FlowModel. More...
 
class  FlowModel
 A FlowModel is a CompartmentalModel defined by the flows between compartments. More...
 
class  FlowSimulation
 A class for simulating a FlowModel. More...
 
struct  GammaCutOff
 Number of days in the past considered for the gamma distribution. More...
 
struct  GammaScaleParameter
 Scale parameter of the gamma distribution. More...
 
struct  GammaShapeParameter
 Shape parameter of the gamma distribution. More...
 
struct  GammaSurvivalFunction
 Class that defines an GammaSurvivalFunction function depending on the state age. More...
 
class  Graph
 generic graph structure More...
 
class  GraphABModel
 
class  GraphBuilder
 A builder class for constructing graphs. More...
 
class  GraphSimulation
 
class  GraphSimulationBase
 abstract simulation on a graph with alternating node and edge actions More...
 
class  GraphSimulationStochastic
 
struct  has_duplicates
 Tests whether the list Types contains any type multiple times. More...
 
class  History
 History class that handles writers and loggers. More...
 
struct  ICUOccupancyHistory
 Daily local ICU occupancy per age group. More...
 
class  Index
 An Index with more than one template parameter combines several Index objects. More...
 
class  Index< CategoryTag >
 An Index with a single template parameter is a typesafe wrapper for size_t that is associated with a Tag. More...
 
struct  index_of_type
 Finds the index of a Type in the list Types. More...
 
struct  index_of_type< Index< CategoryTags... >, Index< CategoryTags... > >
 Specialization of index_of_type for Index. Resolves ambiguity when using Indexs as items. More...
 
struct  index_of_type< Tag, ::mio::Index< CategoryTags... > >
 Specialization of index_of_type for Index. More...
 
struct  index_of_type< Type, TypeList< Types... > >
 Specialization of index_of_type for TypeList. More...
 
struct  index_of_type< TypeList< Types... >, TypeList< Types... > >
 Specialization of index_of_type for TypeList. Resolves ambiguity when using TypeLists as items. More...
 
struct  InEdgeBase
 
struct  Influence
 Struct defining an influence for a second-order adoption. More...
 
class  IntegratorCore
 Interface class defining the integration step used in a SystemIntegrator. More...
 
class  IOStatus
 IOStatus represents the result of an operation. More...
 
struct  is_ad_type
 Detects whether a type is an automatic differentiation (AD) type. More...
 
struct  is_ad_type< ad::internal::active_type< Value, Tape > >
 
struct  is_feedback_simulation
 
struct  is_feedback_simulation< FeedbackSimulation< FP, Sim, ContactPatterns > >
 
struct  is_type_in_list
 Tests whether Type is in the list Types. More...
 
class  LctInfectionState
 Provides the functionality to be able to work with subcompartments in an LCT model. More...
 
class  LctPopulations
 A class template for compartment populations of LCT models. More...
 
struct  Limits
 Type specific limits for floating-points. More...
 
struct  Limits< ad::internal::active_type< FP, DataHandler > >
 
struct  Limits< double >
 
struct  Limits< float >
 
struct  LogAlways
 
struct  LognormSurvivalFunction
 Class that defines an LognormSurvivalFunction function depending on the state age. More...
 
struct  LogOnce
 LogOnce and LogAlways can be used as a base class to write a logger for History. More...
 
struct  Members
 List of a class's members. More...
 
class  MobilityEdge
 represents the mobility between two nodes. More...
 
class  MobilityEdgeStochastic
 represents the mobility between two nodes. More...
 
class  MobilityParameters
 parameters that influence mobility. More...
 
class  MobilityParametersStochastic
 parameters that influence mobility. More...
 
class  MultiIndexIterator
 A Range that can be used to iterate over a MultiIndex. More...
 
struct  NamedRef
 A pair of name and reference. More...
 
struct  Node
 represents a node of the graph More...
 
struct  NoDefaultInit
 A tag used for tag-dispatching the Constructor of ParameterSet, triggering default initialization of all parameters using the get_default member function. More...
 
struct  NominalICUCapacity
 Nominal ICU capacity. More...
 
class  observer_ptr
 A non-owning pointer. More...
 
class  OperatorAdditionSubtraction
 base class to add default operator +, +=, -, -= to a class derived from TypeSafe. More...
 
class  OperatorComparison
 base class to add operator <, <=, >, >= to a class derived from TypeSafe. More...
 
class  OperatorIncrementDecrement
 base class to add operator ++, – (pre- and post-) to a class derived from TypeSafe. More...
 
class  OperatorScalarMultiplicationDivision
 base class to add operator *, *=, /, /= with a scalar to a class derived from TypeSafe. More...
 
struct  OutEdgeBase
 
class  ParameterDistribution
 
class  ParameterDistributionConstant
 
class  ParameterDistributionExponential
 
class  ParameterDistributionLogNormal
 
class  ParameterDistributionNormal
 
class  ParameterDistributionUniform
 
class  ParameterSet
 a set of parameters defined at compile time More...
 
class  ParameterStudy
 Class used to perform multiple simulation runs with randomly sampled parameters. More...
 
struct  ParameterTagTraits
 the properties of a parameter More...
 
class  Populations
 A class template for compartment populations. More...
 
class  Populations< FP, Index< Categories... > >
 Population template specialization, forwarding categories from a MultiIndex to the Population. More...
 
class  Range
 A range of items defined by two iterators. More...
 
class  RectMatrixShape
 shape of a rectangular matrix. More...
 
class  RKIntegratorCore
 Two scheme Runge-Kutta numerical integrator with adaptive step width. More...
 
class  RowMajorIterator
 iterate over elements of eigen matrix expressions in row major order. More...
 
struct  Seq
 sequence of indices More...
 
class  SerializerBase
 Base class for implementations of serialization framework concepts. More...
 
class  Simulation
 A class for simulating a CompartmentalModel. More...
 
class  SimulationDay
 Represents the simulation time as an integer index. More...
 
class  SimulationNode
 represents the simulation in one node of the graph. More...
 
class  SimulationTime
 double simulation time. More...
 
struct  SmootherCosine
 Class that defines an smoother_cosine function depending on the state age. More...
 
struct  SoftPlusCurvatureParameter
 Soft-plus curvature parameter for contact adjustment. More...
 
class  Span
 a reference to any contigiuous array of objects. More...
 
class  SquareMatrixShape
 shape of a square matrix. More...
 
struct  StateAgeFunction
 A generic function depending on the state age, i.e. More...
 
struct  StateAgeFunctionWrapper
 Wrapper around StateAgeFunction so that one can work with an arbitrary StateAgeFunction. More...
 
class  StochasticModel
 A CompartmentalModel with an additional get_noise member. More...
 
class  StochasticSimulation
 A class for simulating a StochasticModel. More...
 
struct  StringLiteral
 Wrapper for string literals, that allows passing them as template arguments. Should be used with constexpr. More...
 
class  SystemIntegrator
 Integrate a system of equations over time. More...
 
class  Tableau
 Two scheme Runge-Kutta numerical integrator with adaptive step width for ODE y'(t) = f(t,y) which is given by y_{n+1} = y_n + h*\sum_{i=1}^lb_ik_{ni} with k_{ni} = f(t_n + c_i*h, y_n + h*\sum_{j=1}^{i-1}a_{ij}k_{nj}) where the general Butcher tableau is 0 | c_2 | a_{21} c_3 | a_{31} a_{32} ... More...
 
class  TableauFinal
 
class  TimeSeries
 stores vectors of values at time points (or some other abstract variable) the value at each time point is a vector. More...
 
class  TimeSeriesFunctor
 
class  TimeSeriesTimeIterator
 Iterate over vector values of a time series by time point. More...
 
class  TimeSeriesValueIterator
 Iterate over vector values of a time series by time point. More...
 
struct  type_at_index
 Finds the type at the Index-th position in the list Types. More...
 
struct  type_at_index< Index, TypeList< Types... > >
 Specialization of type_at_index for TypeList. More...
 
struct  type_at_index< Tag, ::mio::Index< CategoryTags... > >
 Specialization of type_at_index for Index. More...
 
struct  TypeList
 Collection of types. Each type is mapped to an index of type size_t. More...
 
class  TypeSafe
 typesafe wrapper around any type to make function arguments, tuple elements, etc. More...
 
class  UncertainContactMatrix
 The UncertainContactMatrix class consists of a ContactMatrix with fixed baseline and uncertain Dampings. More...
 
class  UncertainValue
 The UncertainValue class consists of a scalar value and a Distribution object. More...
 
struct  Visitable
 
struct  Visitor
 A generic visitor inspired by Fedor Pikus. More...
 
struct  Visitor< T >
 
struct  Visitor< T, Types... >
 

Typedefs

using ConstParameterDistributionVisitor = ConstVisitor< class ParameterDistributionNormal, class ParameterDistributionUniform, class ParameterDistributionLogNormal, class ParameterDistributionExponential, class ParameterDistributionConstant >
 
template<class M >
using CVPlainMatrixT = typename CVPlainMatrix< M >::Type
 
template<typename FP >
using DefaultIntegratorCore = mio::ControlledStepperWrapper< FP, boost::numeric::odeint::runge_kutta_cash_karp54 >
 The default integrator used by Simulation. More...
 
template<typename FP >
using DerivFunction = std::function< void(Eigen::Ref< const Eigen::VectorX< FP > > y, FP t, Eigen::Ref< Eigen::VectorX< FP > > dydt)>
 Function template to be integrated. More...
 
template<typename FP >
using FeedbackSimulationParameters = ParameterSet< ICUOccupancyHistory< FP >, GammaShapeParameter< FP >, GammaScaleParameter< FP >, GammaCutOff, ContactReductionMax< FP >, ContactReductionMin< FP >, SoftPlusCurvatureParameter< FP >, NominalICUCapacity< FP >, BlendingFactorLocal< FP >, BlendingFactorRegional< FP > >
 
template<class T , class... Args>
using has_get_default_member_function = details::has_get_default_member_function< T, void, Args... >
 check whether a get_default function exists More...
 
template<class... Loggers>
using HistoryWithMemoryWriter = History< DataWriterToMemory, Loggers... >
 
template<class T >
using InterpolateResultT = std::decay_t< decltype(interpolate_simulation_result(std::declval< T >()))>
 helper template, type returned by overload interpolate_simulation_result(T t) More...
 
template<class T >
using IOResult = boost::outcome_v2::unchecked< T, IOStatus >
 Value-or-error type for operations that return a value but can fail. More...
 
template<class T >
using is_64bit_integral = std::integral_constant< bool,(std::is_integral_v< T > &&sizeof(T)==8)>
 Bool constant to check whether T is an integral type of 64 bits. Used for Json library. More...
 
template<typename T >
using is_no_default_init_tag = std::is_same< NoDefaultInit, T >
 
template<class T >
using is_small_integral = std::integral_constant< bool,(std::is_integral_v< T > &&sizeof(T)<=4)>
 Bool constant to check whether T is an integral type of 32 bits or less. Used for Json library. More...
 
template<typename FP >
using MobilityCoefficientGroup = DampingMatrixExpressionGroup< FP, MobilityCoefficients< FP > >
 sum of time dependent mobility coefficients. More...
 
template<typename FP >
using MobilityCoefficients = DampingMatrixExpression< FP, VectorDampings< FP > >
 time dependent mobility coefficients. More...
 
template<bool Cond>
using not_copyable_if = std::conditional< Cond, details::NoCopy, details::Empty >
 Defines a type that is not copy constructible or assignable if the specified condition is true. More...
 
template<bool Cond>
using not_copyable_if_t = typename not_copyable_if< Cond >::type
 equivalent to not_copyable_if<Cond>::type. More...
 
template<typename FP >
using OdeIntegrator = SystemIntegrator< FP, DerivFunction< FP > >
 Solver for a system of initial value problems (IVPs) consisting of ordinary differential equations (ODEs). More...
 
template<class FP >
using OdeIntegratorCore = IntegratorCore< FP, DerivFunction< FP > >
 Interface for defining solvers for ODE problems. Also. More...
 
using ParameterDistributionVisitor = Visitor< class ParameterDistributionNormal, class ParameterDistributionUniform, class ParameterDistributionLogNormal, class ParameterDistributionExponential, class ParameterDistributionConstant >
 This is a visitor class to visit all Parameter Distribution objects. More...
 
template<size_t I, class ParamSet >
using ParameterTag = details::ParameterTag< I, ParamSet >
 get the the tag of the I-th parameter in a set More...
 
template<size_t I, class ParamSet >
using ParameterTagT = typename ParameterTag< I, ParamSet >::Type
 
template<typename FP >
using SdeIntegrator = SystemIntegrator< FP, DerivFunction< FP >, DerivFunction< FP > >
 Solver for a system of initial value problems (IVPs) consisting of stochastic differential equations (SDEs). More...
 
template<class FP >
using SdeIntegratorCore = IntegratorCore< FP, DerivFunction< FP >, DerivFunction< FP > >
 Interface for defining solvers for SDE problems. Also. More...
 
template<typename FP >
using SquareDamping = Damping< FP, SquareMatrixShape< FP > >
 aliases for common damping specializations. More...
 
template<typename FP >
using SquareDampings = Dampings< FP, SquareDamping< FP > >
 
template<class T >
using Tag = boost::outcome_v2::in_place_type_t< T >
 Type that is used for overload resolution. More...
 
template<std::size_t Index, class... Types>
using type_at_index_t = typename type_at_index< Index, Types... >::type
 The type at the Index-th position in the list Types. More...
 
template<typename FP >
using VectorDamping = Damping< FP, ColumnVectorShape< FP > >
 
template<typename FP >
using VectorDampings = Dampings< FP, VectorDamping< FP > >
 
template<class T >
using VectorRange = std::conditional_t< std::is_const_v< T >, typename mio::Range< typename std::vector< std::remove_const_t< T > >::const_iterator >, typename mio::Range< typename std::vector< std::remove_const_t< T > >::iterator > >
 Defines generic Range type for IterPair of a vector. More...
 
template<class Derived >
using VisitableParameterDistribution = Visitable< Derived, class ParameterDistribution, ParameterDistributionVisitor, ConstParameterDistributionVisitor >
 

Enumerations

enum  IOFlags { IOF_None = 0 , IOF_OmitDistributions = 1 << 0 , IOF_OmitValues = 1 << 1 , IOF_IncludeTypeInfo = 1 << 2 }
 flags to determine the behavior of the serialization process. More...
 
enum class  LogLevel {
  trace , debug , info , warn ,
  err , critical , off
}
 
enum class  StatusCode {
  OK = 0 , UnknownError = 1 , OutOfRange , InvalidValue ,
  InvalidFileFormat , KeyNotFound , InvalidType , FileNotFound
}
 code to indicate the result of an operation. More...
 
enum class  TimeSeriesFunctorType { LinearInterpolation }
 Type of a TimeSeriesFunctor. More...
 

Functions

template<typename FP >
FP abs_max (FP v1, FP v2)
 maximum absolute value of two numbers. More...
 
obj add_list ("Items", container.begin(), container.end())
 
template<class... History>
void advance_model (abm::TimePoint t, abm::TimeSpan dt, ABMSimulationNode< History... > &node)
 Node functor for abm graph simulation. More...
 
template<typename FP , class Sim >
void advance_model (FP t, FP dt, SimulationNode< FP, Sim > &node)
 edge functor for mobility-based simulation. More...
 
return apply (io, [](auto &&i_) { return Container(i_.begin(), i_.end());}, i)
 
template<class DampingExpression , class DampingSamplings , class F >
void apply_dampings (DampingExpression &damping_expression, const DampingSamplings &dampings, F make_matrix)
 add sampled dampings to a damping expression. More...
 
template<class... History>
void apply_mobility (abm::TimePoint t, abm::TimeSpan, ABMMobilityEdge< History... > &edge, ABMSimulationNode< History... > &node_from, ABMSimulationNode< History... > &node_to)
 Edge functor for abm graph simulation. More...
 
template<typename FP , class Sim >
void apply_mobility (FP t, FP dt, MobilityEdge< FP > &mobilityEdge, SimulationNode< FP, Sim > &node_from, SimulationNode< FP, Sim > &node_to)
 edge functor for mobility-based simulation. More...
 
template<typename FP , class Sim , class StochasticEdge >
void apply_mobility (StochasticEdge &mobilityEdge, size_t event, SimulationNode< FP, Sim > &node_from, SimulationNode< FP, Sim > &node_to)
 edge functor for mobility-based simulation. More...
 
static const std::string base_dir ()
 Returns the absolute path to the project directory. More...
 
template<IsMatrixExpression M>
RowMajorIterator< M, true > begin (const M &m)
 create a const iterator to first element of the matrix m. More...
 
template<class... Categories>
MultiIndexIterator< Index< Categories... > > begin (Index< Categories... > dimensions)
 STL iterator for a MultiIndex. More...
 
template<IsMatrixExpression M>
requires details::IsElementReference< M > RowMajorIterator< M, false > begin (M &m)
 create a non-const iterator to first element of the matrix m. More...
 
template<typename FP , IsCompartmentalModelSimulation< FP > Sim>
void calculate_mobility_returns (Eigen::Ref< typename TimeSeries< FP >::Vector > mobile_population, const Sim &sim, Eigen::Ref< const typename TimeSeries< FP >::Vector > total, FP t, FP dt)
 adjust number of people that changed node when they return according to the model. More...
 
std::array< int, 12 > calculate_partial_sum_of_months (const Date &date)
 Computes the cumulative number of days at the end of each month for a given year. More...
 
template<IsMatrixExpression M>
RowMajorIterator< M, true > cbegin (const M &m)
 create a const iterator to first element of the matrix m. More...
 
template<IsMatrixExpression M>
RowMajorIterator< M, true > cend (const M &m)
 create a non-const end iterator for the matrix m. More...
 
template<class... IndexArgs>
decltype(auto) concatenate_indices (IndexArgs &&... args)
 Combine several Indexs into one MultiIndex. More...
 
template<class Iter , class Pred >
bool contains (Iter b, Iter e, Pred p)
 checks if there is an element in this range that matches a predicate More...
 
IOResult< int > count_lines (const std::string &filename)
 Counts lines of txt file. More...
 
IOResult< bool > create_directory (std::string const &rel_path)
 Creates a directory in the file system. More...
 
IOResult< bool > create_directory (std::string const &rel_path, std::string &abs_path)
 Creates a directory in the file system. More...
 
 DECL_TYPESAFE (int, DampingLevel)
 integer damping level. More...
 
 DECL_TYPESAFE (int, DampingType)
 integer damping type. More...
 
template<class IOContext , class T >
IOResult< T > deserialize (IOContext &io, Tag< T > tag)
 Restores an object from the data stored in an IO context. More...
 
template<class T >
IOResult< T > deserialize_binary (ByteStream &stream, Tag< T >, int flags=0)
 Deserialize an object from binary format. More...
 
template<class IOContext >
IOResult< AbstractParameterDistributiondeserialize_internal (IOContext &io, Tag< AbstractParameterDistribution >)
 deserialize a AbstractParameterDistribution. More...
 
template<class IOContext , class E >
requires std::is_enum_v< E > IOResult< E > deserialize_internal (IOContext &io, Tag< E >)
 deserialize an enum value from its underlying type. More...
 
template<class IOContext , IsMatrixExpression M>
IOResult< M > deserialize_internal (IOContext &io, Tag< M >)
 deserialize an Eigen matrix. More...
 
template<class IOContext , size_t N>
IOResult< std::bitset< N > > deserialize_internal (IOContext &io, Tag< std::bitset< N >> tag)
 Deserialize an std::bitset. More...
 
template<class IOContext >
IOResult< std::shared_ptr< ParameterDistribution > > deserialize_internal (IOContext &io, Tag< std::shared_ptr< ParameterDistribution >>)
 deserialize a parameter distribution as a shared_ptr. More...
 
template<class IOContext , IsDefaultDeserializable< IOContext > T>
IOResult< T > deserialize_internal (IOContext &io, Tag< T > tag)
 Deserialization implementation for the default serialization feature. More...
 
template<class IOContext , template< class... > class Tup, class... T>
requires std::same_as< Tup< T... >, std::pair< T... > > std::same_as< Tup< T... >, std::tuple< T... > > IOResult< Tup< T... > > deserialize_internal (IOContext &io, Tag< Tup< T... >> tag)
 deserialize a tuple-like object, e.g. More...
 
template<class U , class T >
std::unique_ptr< U > dynamic_unique_ptr_cast (std::unique_ptr< T > &&base_ptr)
 converts a unique_ptr<T> to unique_ptr. More...
 
template<IsMatrixExpression M>
RowMajorIterator< M, true > end (const M &m)
 create a const end iterator for the matrix m. More...
 
template<class... Categories>
MultiIndexIterator< Index< Categories... > > end (Index< Categories... > dimensions)
 STL iterator for a MultiIndex. More...
 
template<IsMatrixExpression M>
requires details::IsElementReference< M > RowMajorIterator< M, false > end (M &m)
 create a non-const end iterator for the matrix m. More...
 
template<typename FP >
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 returned by interpolated_ensemble_result: same number of nodes, same time points and elements. More...
 
template<typename FP >
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. More...
 
template<class T >
constexpr std::array< T, size_t(T::Count)> enum_members ()
 Get an std::array that contains all members of an enum class. More...
 
template<typename Type , typename Intermediate >
auto evaluate_intermediate (Intermediate &&x)
 Evaluate an intermediate expression to its underlying type, if necessary. More...
 
template<class SuperIndex , class SubIndex >
SuperIndex extend_index (const SubIndex &index, size_t fill_value=0)
 Create a SuperIndex by copying values from SubIndex, filling new categories with fill_value. More...
 
auto failure (const IOStatus &s)
 Create an object that is implicitly convertible to an error IOResult<T>. More...
 
auto failure (std::error_code c, const std::string &msg="")
 Create an object that is implicitly convertible to an error IOResult<T>. More...
 
bool file_exists (std::string const &rel_path, std::string &abs_path)
 Check if a file exists. More...
 
template<class FP , class TS >
decltype(std::declval< TS >().rend()) find_value_reverse (TS &&ts, FP t_search, FP abs_tol=0, FP rel_tol=0)
 find the value in the time series at time t_search starting from the end. More...
 
template<typename MultiIndex >
size_t flatten_index (MultiIndex const &indices, MultiIndex const &dimensions)
 flatten_index takes a set of indices into a mutlidemsional array and calculates the flat index More...
 
template<typename FP >
bool floating_point_equal (FP v1, FP v2, FP abs_tol=0, FP rel_tol=std::numeric_limits< FP >::min())
 compare two floating point values for equality with tolerances. More...
 
template<typename FP >
bool floating_point_greater (FP v1, FP v2, FP abs_tol=0, FP rel_tol=std::numeric_limits< FP >::min())
 compare two floating point values with tolerances. More...
 
template<typename FP >
bool floating_point_greater_equal (FP v1, FP v2, FP abs_tol=0, FP rel_tol=std::numeric_limits< FP >::min())
 compare two floating point values with tolerances. More...
 
template<typename FP >
bool floating_point_less (FP v1, FP v2, FP abs_tol=0, FP rel_tol=std::numeric_limits< FP >::min())
 compare two floating point values with tolerances. More...
 
template<typename FP >
bool floating_point_less_equal (FP v1, FP v2, FP abs_tol=0, FP rel_tol=std::numeric_limits< FP >::min())
 compare two floating point values with tolerances. More...
 
template<class F , class... Tags>
void foreach (const ParameterSet< Tags... > &p, F f)
 call f(p, t) for all parameters in a ParameterSet with p the value of the parameter t a default constructed parameter tag More...
 
template<class F , class... Tags>
void foreach (ParameterSet< Tags... > &p, F f)
 
template<class Params , class F >
void foreach_tag (F f)
 call f(t) for all parameters in a ParameterSet with t a default constructed parameter tag More...
 
std::string format_as (const mio::Date &d)
 Format date objects using the ISO notation for logging with spdlog. More...
 
template<class FP >
const FP & format_as (const UncertainValue< FP > &uv)
 Format UncertainValues using their value for logging with spdlog. More...
 
template<size_t I, typename... CategoryTags>
constexpr std::tuple_element< I, std::tuple< Index< CategoryTags >... > >::type & get (Index< CategoryTags... > &i) noexcept
 Retrieves the Index (by reference) at the Ith position of a MultiIndex. More...
 
template<typename Tag , typename... CategoryTags>
constexpr Index< Tag > & get (Index< CategoryTags... > &i) noexcept
 Retrieves the Index (by reference) by its Tag in a MultiIndex. Requires unique tags. More...
 
template<size_t I, typename... CategoryTags>
constexpr std::tuple_element< I, std::tuple< Index< CategoryTags >... > >::type const & get (Index< CategoryTags... > const &i) noexcept
 Retrieves the Index (by const reference) at the Ith position of a MultiIndex. More...
 
template<typename Tag , typename... CategoryTags>
constexpr Index< Tag > const & get (Index< CategoryTags... > const &i) noexcept
 Retrieves the Index (by const reference) by its Tag in a MultiIndex. Requires unique tags. More...
 
template<typename FP , class DampingExpr >
Eigen::Ref< const typename DampingExpr::Matrix > get_active_damping (const DampingExpr &damping_expr, DampingLevel lvl, DampingType type, SimulationTime< FP > t)
 Get the value of the damping that matches the given type and level and that is active at the specified time. More...
 
std::string get_current_dir_name ()
 Returns the current working directory name. More...
 
template<typename FP , class DampingExpr >
std::vector< size_t > get_damping_indices (const DampingExpr &damping_expr, DampingLevel lvl, DampingType type, SimulationTime< FP > begin, SimulationTime< FP > end)
 Get a list of indices of specified dampings. More...
 
int get_day_in_year (Date date)
 Computes the day in year based on a given date. More...
 
template<typename FP , class Sim >
FP get_infections_relative (const SimulationNode< FP, Sim > &node, FP t, const Eigen::Ref< const Eigen::VectorX< FP >> &y)
 get the percantage of infected people of the total population in the node If dynamic NPIs are enabled, there needs to be an overload of get_infections_relative(model, y) for the Model type that can be found with argument-dependent lookup. More...
 
template<typename FP , class Sim >
auto get_mobility_factors (const SimulationNode< FP, Sim > &node, FP t, const Eigen::Ref< const Eigen::VectorX< FP >> &y)
 Get an additional mobility factor. More...
 
int get_month_length (Date date)
 Computes the length of a month for a given date. More...
 
int get_offset_in_days (Date date1, Date date2)
 Computes the offset in days given two dates: first date minus second date. More...
 
template<typename FP , class DampingExprGroup , class MakeMatrix >
void implement_dynamic_npis (DampingExprGroup &damping_expr_group, const std::vector< DampingSampling< FP >> &npis, SimulationTime< FP > begin, SimulationTime< FP > end, MakeMatrix &&make_matrix)
 implement dynamic NPIs for a time span. More...
 
template<typename T >
void insert_sorted_replace (std::vector< T > &vec, T const &item)
 
template<typename T , typename Pred >
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 vector are partially sorted and unique according the predicate postcondition: same as precondition, additionally contains exactly one element that is equal to item, order of other items is preserved More...
 
template<class T >
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. More...
 
template<typename FP , class Simulation >
std::vector< TimeSeries< FP > > interpolate_simulation_result (const Graph< SimulationNode< FP, Simulation >, MobilityEdge< FP >> &graph_result)
 interpolate time series with evenly spaced, integer time points for each node. More...
 
template<typename FP >
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. More...
 
template<typename FP >
TimeSeries< FP > interpolate_simulation_result (const TimeSeries< FP > &simulation_result, const std::vector< FP > &interpolation_times)
 Interpolate a time series at the given time points. More...
 
bool is_leap_year (int year)
 Computes if a given year is a leap year. More...
 
template<typename X , typename V >
auto linear_interpolation (const X &x_eval, const X &x_1, const X &x_2, const V &y1, const V &y2)
 Linear interpolation between two data values. More...
 
template<class FP >
TimeSeries< FP >::Vector linear_interpolation (FP time, const TimeSeries< FP > &data)
 Linear interpolation of a TimeSeries. More...
 
template<typename X , typename Y >
linear_interpolation_of_data_set (std::vector< std::pair< X, Y >> vector, const X &x_eval)
 Linear interpolation between two points of a dataset, which is represented by a vector of pairs of node and value. More...
 
template<typename... Args>
void log (LogLevel level, spdlog::string_view_t fmt, const Args &... args)
 
template<typename... Args>
void log_critical (spdlog::string_view_t fmt, const Args &... args)
 
template<typename... Args>
void log_debug (spdlog::string_view_t fmt, const Args &... args)
 
template<typename... Args>
void log_error (spdlog::string_view_t fmt, const Args &... args)
 
template<typename... Args>
void log_info (spdlog::string_view_t fmt, const Args &... args)
 
template<typename... Args>
void log_warning (spdlog::string_view_t fmt, const Args &... args)
 
template<class M >
Eigen::Index major_size (M &&m)
 number of rows (columns) of a row (column) major matrix. More...
 
template<class... History>
GraphSimulation< ScalarType, Graph< ABMSimulationNode< History... >, ABMMobilityEdge< History... > >, abm::TimePoint, abm::TimeSpan, void(*)(mio::abm::TimePoint, mio::abm::TimeSpan, mio::ABMMobilityEdge< History... > &, mio::ABMSimulationNode< History... > &, mio::ABMSimulationNode< History... > &), void(*)(mio::abm::TimePoint, mio::abm::TimeSpan, mio::ABMSimulationNode< History... > &)> make_abm_graph_sim (abm::TimePoint t0, abm::TimeSpan dt, Graph< ABMSimulationNode< History... >, ABMMobilityEdge< History... >> &&graph)
 Creates an abm graph simulation. More...
 
template<class V >
auto make_contact_damping_matrix (V &&groups)
 Make a contact damping matrix from dampings by group. More...
 
const std::error_code & make_error_code (const IOStatus &status)
 Convert IOStatus to std::error_code. More...
 
std::error_code make_error_code (StatusCode e)
 Convert StatusCode to std::error_code. More...
 
template<typename FP , typename Timepoint , class Timespan , class Graph , class NodeF , class EdgeF >
auto make_graph_sim (Timepoint t0, Timespan dt, Graph &&g, NodeF &&node_func, EdgeF &&edge_func)
 
template<typename FP , class Graph , class NodeF , class EdgeF >
auto make_graph_sim_stochastic (FP t0, FP dt, Graph &&g, NodeF &&node_func, EdgeF &&edge_func)
 
template<class... Categories>
Range< MultiIndexIterator< Index< Categories... > > > make_index_range (Index< Categories... > dimensions)
 Construct a range that can be used to iterate over all MultiIndices in the given dimensions. More...
 
template<typename FP , class V >
auto make_mobility_damping_vector (ColumnVectorShape< FP > shape, V &&groups)
 Make mobility coefficient damping vector from dampings by group. More...
 
template<typename T >
observer_ptr< T > make_observer (T *p)
 
template<typename FP , class Sim >
auto make_sampled_graph_simulation (const Graph< typename Sim::Model, MobilityParameters< FP >> &sampled_graph, FP t0, FP dt_node_sim, FP dt_graph_sim)
 Create a GraphSimulation from a parameter graph. More...
 
template<class Rng , class F >
auto map (const Rng &v, F f)
 Maps a random access range (i.e. More...
 
template<typename FP >
IOResult< void > map_to_nonnegative (Eigen::Ref< Eigen::VectorX< FP >> x, const FP tolerance=Limits< FP >::zero_tolerance())
 Map a vector onto nonnegative values while preserving its nonnegative sum. More...
 
template<class A , class B >
auto max (const Eigen::MatrixBase< A > &a, B &&b)
 coefficient wise maximum of two matrices. More...
 
template<class FP >
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 the correct order. More...
 
template<class M >
Eigen::Index minor_size (M &&m)
 number of columns (rows) of a row (column) major matrix. More...
 
Date offset_date_by_days (Date date, int offset_days)
 Computes the new date corresponding to a given date and a offset in days. More...
 
template<std::equality_comparable T>
bool operator!= (const Edge< T > &e1, const Edge< T > &e2)
 
template<std::equality_comparable T>
bool operator!= (const Node< T > &n1, const Node< T > &n2)
 
template<class T >
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 More...
 
template<std::equality_comparable T>
bool operator== (const Edge< T > &e1, const Edge< T > &e2)
 comparison operator if edge property type is equality comparable More...
 
template<std::equality_comparable T>
bool operator== (const Node< T > &n1, const Node< T > &n2)
 comparison operator if node property type is equality comparable More...
 
IOResult< Dateparse_date (const std::string &date_str)
 parses a date from a string. More...
 
template<class String , class... Strings>
std::string path_join (String &&base, Strings &&... app)
 join one ore more strings with path separators. More...
 
template<class Graph >
void print_graph (std::ostream &os, const Graph &g)
 
template<class T >
requires HasOstreamOperator< T > void print_graph_object (std::ostream &os, size_t idx, const T &o)
 
void PrintTo (const IOStatus &status, std::ostream *os)
 gtest printer for IOStatus. More...
 
template<typename FP >
void PrintTo (const UncertainValue< FP > &uv, std::ostream *os)
 
template<class I , class S >
 Range (std::pair< I, S > iterator_pair) -> Range< I, S >
 Deduction guide to correctly deduce range type when constructed from a pair. More...
 
template<class T >
 Range (T &&range) -> Range< decltype(range.begin()), decltype(range.end())>
 Deduction guide to correctly deduce range type when constructed from another range. More...
 
IOResult< Eigen::MatrixXd > read_mobility_formatted (const std::string &filename)
 Reads formatted mobility or contact data which is given in columns from_str to_str from_rs to_rs count_abs and separated by tabs. More...
 
IOResult< Eigen::MatrixXd > read_mobility_plain (const std::string &filename)
 Reads txt mobility data or contact which is given by values only and separated by spaces. More...
 
template<class T >
 requires (!HasOstreamOperator< T >) std
 out stream operator for edges if edge property type does not have stream operator defined More...
 
template<class IOContext , IsContainer Container>
 requires (!HasSerialize< IOContext, Container >) void serialize_internal(IOContext &io
 serialize an STL compatible container. More...
 
template<class T >
 requires (!std::is_trivial_v< T >) void BinarySerializerObject
 
template<typename M >
auto reshape (M &&m, Eigen::Index rows, Eigen::Index cols)
 reshape the matrix. More...
 
template<typename FP >
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. More...
 
template<typename FP , class InfectionState >
FP result_distance_2norm (const std::vector< mio::TimeSeries< FP >> &result1, const std::vector< mio::TimeSeries< FP >> &result2, InfectionState compartment)
 Compute the distance between two compartment model simulation results in one compartment. More...
 
template<class IOContext , class T >
void serialize (IOContext &io, const T &t)
 Save data that describes an object in a format determined by the given context. More...
 
template<class T >
ByteStream serialize_binary (const T &t, int flags=0)
 Serialize an object into binary format. More...
 
template<class IOContext , class M >
void serialize_internal (IOContext &io, const Eigen::EigenBase< M > &mat)
 serialize an Eigen matrix expression. More...
 
template<class IOContext , size_t N>
void serialize_internal (IOContext &io, const std::bitset< N > bitset)
 Serialize an std::bitset. More...
 
template<class IOContext , IsDefaultSerializable< IOContext > T>
void serialize_internal (IOContext &io, const T &a)
 Serialization implementation for the default serialization feature. More...
 
template<class IOContext , template< class... > class Tup, class... T>
requires std::same_as< Tup< T... >, std::pair< T... > > std::same_as< Tup< T... >, std::tuple< T... > > void serialize_internal (IOContext &io, const Tup< T... > &tup)
 serialize a tuple-like object, e.g. More...
 
template<class IOContext , class E >
requires std::is_enum_v< E > void serialize_internal (IOContext &io, E e)
 serialize an enum value as its underlying type. More...
 
template<typename FP , class ContactLocation , class Model , class MobilityParams , class MobilityCoefficientGroup , class InfectionState , class ReadFunction >
IOResult< void > set_edges (const fs::path &mobility_data_file, Graph< Model, MobilityParams > &params_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. More...
 
void set_log_level (LogLevel level)
 Sets the verbosity of the logger. More...
 
template<typename FP , class TestAndTrace , class ContactPattern , class Model , class MobilityParams , class Parameters , class ReadFunction , class NodeIdFunction >
IOResult< void > set_nodes (const Parameters &params, 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 > &params_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. More...
 
std::ostream & set_ostream_format (std::ostream &out, size_t width, size_t precision, char fill=' ')
 Adds manipulators for width, (fixed) precision and fill character to an ostream. More...
 
template<typename FP , class Model , class Sim = mio::Simulation<FP, Model>>
TimeSeries< FP > simulate (FP t0, FP tmax, FP dt, Model const &model, std::unique_ptr< OdeIntegratorCore< FP >> &&integrator_core=nullptr)
 Run a Simulation of a CompartmentalModel. More...
 
template<typename FP , class Model , class Sim = FlowSimulation<FP, Model>>
std::vector< TimeSeries< FP > > simulate_flows (FP t0, FP tmax, FP dt, Model const &model, std::unique_ptr< OdeIntegratorCore< FP >> &&integrator_core=nullptr)
 Run a FlowSimulation of a FlowModel. More...
 
template<typename FP , class Model , class Sim = StochasticSimulation<FP, Model>>
TimeSeries< FP > simulate_stochastic (FP t0, FP tmax, FP dt, Model const &model, std::unique_ptr< SdeIntegratorCore< FP >> &&integrator_core=nullptr)
 
template<IsDynamicMatrix M>
auto slice (M &&m, Seq< Eigen::Index > rows, Seq< Eigen::Index > cols)
 take a regular slice of a matrix. More...
 
template<IsDynamicVector V>
auto slice (V &&v, Seq< Eigen::Index > elems)
 take a regular slice of a row or column vector. More...
 
template<typename FP , class LeftExpr , class RightExpr >
auto smoother_cosine (FP x, FP xleft, FP xright, const Eigen::MatrixBase< LeftExpr > &yleft_expr, const Eigen::MatrixBase< RightExpr > &yright_expr)
 smoother_cosine as a matrix valued function. More...
 
template<typename FP >
FP smoother_cosine (FP x, FP xleft, FP xright, FP yleft, FP yright)
 Returns the smoothed evaluation of a discrete jump of function values
yleft and yright on xleft and xright, respectively, by using a cosine function. More...
 
std::vector< std::string > split (const std::string &s, char delimiter)
 Splits string into a Vector of strings according to delimiter. More...
 
const details::StatusCodeCategorystatus_code_category ()
 singleton StatusCodeCategory instance. More...
 
template<size_t Size>
 StringLiteral (const char(&string)[Size]) -> StringLiteral< Size - 1 >
 
auto success ()
 Create an object that is implicitly convertible to a succesful IOResult<void>. More...
 
template<class T >
auto success (T &&t)
 Create an object that is implicitly convertible to a succesful IOResult. More...
 
template<typename FP >
std::vector< std::vector< TimeSeries< FP > > > sum_nodes (const std::vector< std::vector< TimeSeries< FP >>> &ensemble_result)
 
template<typename FP , class Sim >
void test_commuters (SimulationNode< FP, Sim > &node, Eigen::Ref< Eigen::VectorX< FP >> mobile_population, FP time)
 Test persons when moving from their source node. More...
 
RandomNumberGenerator & thread_local_rng ()
 
template<class... T>
void unused (T &&...)
 Does nothing, can be used to mark variables as not used. More...
 
template<class IOContext , class F , class... T>
details::ApplyResultT< F, T... > apply (IOContext &io, F f, const IOResult< T > &... rs)
 Evaluate a function with zero or more unpacked IOResults as arguments. More...
 
template<class IOContext , class F , class... T>
details::ApplyResultT< F, T... > apply (IOContext &io, F f, const std::tuple< IOResult< T >... > &results)
 Evaluate a function with zero or more unpacked IOResults as arguments. More...
 
template<typename FP , class Sim >
GraphSimulation< FP, Graph< SimulationNode< FP, Sim >, MobilityEdge< FP > >, FP, FP, void(*)(FP, FP, mio::MobilityEdge< FP > &, mio::SimulationNode< FP, Sim > &, mio::SimulationNode< FP, Sim > &), void(*)(FP, FP, mio::SimulationNode< FP, Sim > &)> make_mobility_sim (FP t0, FP dt, const Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &graph)
 create a mobility-based simulation. More...
 
template<typename FP , class Sim >
GraphSimulation< FP, Graph< SimulationNode< FP, Sim >, MobilityEdge< FP > >, FP, FP, void(*)(FP, FP, mio::MobilityEdge< FP > &, mio::SimulationNode< FP, Sim > &, mio::SimulationNode< FP, Sim > &), void(*)(FP, FP, mio::SimulationNode< FP, Sim > &)> make_mobility_sim (FP t0, FP dt, Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &&graph)
 create a mobility-based simulation. More...
 
template<typename FP , class Sim >
auto make_no_mobility_sim (FP t0, Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &graph)
 Create a graph simulation without mobility. More...
 
template<typename FP , class Sim >
auto make_no_mobility_sim (FP t0, Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &&graph)
 Create a graph simulation without mobility. More...
 
template<typename FP , class Sim >
GraphSimulationStochastic< FP, Graph< SimulationNode< FP, Sim >, MobilityEdgeStochastic< FP > > > make_mobility_sim (FP t0, FP dt, const Graph< SimulationNode< FP, Sim >, MobilityEdgeStochastic< FP >> &graph)
 create a mobility-based simulation. More...
 
template<typename FP , class Sim >
GraphSimulationStochastic< FP, Graph< SimulationNode< FP, Sim >, MobilityEdgeStochastic< FP > > > make_mobility_sim (FP t0, FP dt, Graph< SimulationNode< FP, Sim >, MobilityEdgeStochastic< FP >> &&graph)
 create a mobility-based simulation. More...
 
template<class SubIndex , class SuperIndex >
decltype(auto) reduce_index (const SuperIndex &index)
 Create a SubIndex by copying values from SuperIndex. More...
 
template<class Enum , class SuperIndex >
requires std::is_enum_v< Enum > Index< Enum > reduce_index (const SuperIndex &index)
 Create a SubIndex by copying values from SuperIndex. More...
 
Comparison operators with scalar or AD type on right (UncertainValue <op> T)
template<typename FP , typename T >
bool operator> (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
bool operator< (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
bool operator>= (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
bool operator<= (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
bool operator== (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
bool operator!= (const UncertainValue< FP > &lhs, const T &rhs)
 
Comparison operators with scalar or AD type on left (T <op> UncertainValue)
template<typename FP , typename T >
bool operator> (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
bool operator< (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
bool operator>= (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
bool operator<= (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
bool operator== (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
bool operator!= (const T &lhs, const UncertainValue< FP > &rhs)
 
Comparison operators between two UncertainValue objects
template<typename FP >
bool operator> (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
bool operator< (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
bool operator>= (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
bool operator<= (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
bool operator== (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
bool operator!= (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
Arithmetic operators between two UncertainValue objects (returns FP)
template<typename FP >
FP operator* (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
FP operator/ (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
FP operator+ (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP >
FP operator- (const UncertainValue< FP > &lhs, const UncertainValue< FP > &rhs)
 
Arithmetic operators with scalar or AD type on right (UncertainValue <op> T)
template<typename FP , typename T >
FP operator* (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
FP operator/ (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
FP operator+ (const UncertainValue< FP > &lhs, const T &rhs)
 
template<typename FP , typename T >
FP operator- (const UncertainValue< FP > &lhs, const T &rhs)
 
Arithmetic operators with scalar or AD type on left (T <op> UncertainValue)
template<typename FP , typename T >
FP operator* (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
FP operator/ (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
FP operator+ (const T &lhs, const UncertainValue< FP > &rhs)
 
template<typename FP , typename T >
FP operator- (const T &lhs, const UncertainValue< FP > &rhs)
 
Compound assignment operators for FP and UncertainValue<FP>
template<typename FP >
FP & operator+= (FP &lhs, const UncertainValue< FP > &rhs)
 Print statement for UncertainValue<FP> (required for AD types) More...
 
template<typename FP >
FP & operator-= (FP &lhs, const UncertainValue< FP > &rhs)
 Print statement for UncertainValue<FP> (required for AD types) More...
 
template<typename FP >
FP & operator*= (FP &lhs, const UncertainValue< FP > &rhs)
 Print statement for UncertainValue<FP> (required for AD types) More...
 
template<typename FP >
FP & operator/= (FP &lhs, const UncertainValue< FP > &rhs)
 Print statement for UncertainValue<FP> (required for AD types) More...
 
template<typename FP >
std::ostream & operator<< (std::ostream &os, const UncertainValue< FP > &uv)
 Print statement for UncertainValue<FP> (required for AD types) More...
 

Variables

const Container & container
 
template<class... Types>
constexpr bool has_duplicates_v = has_duplicates<Types...>::value
 Checks whether Type has any duplicates. More...
 
template<class T >
concept HasApplyConstraints
 Check that the given type has an apply_constraints member function. More...
 
template<class T >
concept HasCheckConstraints
 Check that the given type has a check_constraints member function. More...
 
template<class T , class IOContext >
concept HasDeserialize
 
template<class T >
concept HasOstreamOperator = requires(std::ostream os, T t) { os << t; }
 Concept to check if type T has an existing stream output operator "<<". More...
 
template<class T , class IOContext >
concept HasSerialize = requires(IOContext& ctxt, const T& t) { t.serialize(ctxt); }
 
auto i = obj.expect_list("Items", Tag<typename Container::value_type>{})
 
template<class Type , class... Types>
constexpr std::size_t index_of_type_v = index_of_type<Type, Types...>::value
 The index of Type in the list Types. More...
 
template<class Type , class... Types>
constexpr bool is_type_in_list_v = is_type_in_list<Type, Types...>::value
 Checks whether Type is in the list Types. More...
 
template<class Model , typename FP >
concept IsCompartmentalModel
 Concept to check if a type is a valid compartment model. More...
 
template<class Simulation , typename FP >
concept IsCompartmentalModelSimulation
 Concept to check if a type is a simulation for a compartmental model. More...
 
template<class C >
concept IsContainer
 Concept to check whether C is a STL compatible container. More...
 
template<class T , class IOContext >
concept IsDefaultDeserializable
 Detect whether T has a default_serialize member function, but no deserialize member. More...
 
template<class T , class IOContext >
concept IsDefaultSerializable
 Detect whether T has a default_serialize member function, but no serialize member. More...
 
template<class M >
concept IsDynamicMatrix
 check if Eigen::Matrix type M is a dynamic matrix type. More...
 
template<class M >
concept IsDynamicVector
 check if Eigen::Matrix type M is a dynamic vector type. More...
 
template<class Model , typename FP >
concept IsFlowModel
 Concept to check if a type is a valid FlowModel. More...
 
template<class M >
concept IsMatrixExpression = std::is_base_of_v<Eigen::EigenBase<M>, M>
 Concept to detect whether T is an Eigen matrix expression. More...
 
template<typename... CategoryTags>
concept IsMultiIndex = requires(Index<CategoryTags...> i) { details::is_multi_index_impl(i); }
 A MultiIndex is an Index with any number of categories. Does accept empty or single category indices. More...
 
template<class Model , typename FP >
concept IsStochasticModel
 Concept to check if a type is a valid stochastic model. More...
 
 Tag< Container >
 
template<class T >
constexpr bool is_ad_type_v = is_ad_type<T>::value
 

Detailed Description

A collection of classes to simplify handling of matrix shapes in meta programming.

Matrix shape types follow this model:

  • subtype Matrix that is an alias of an Eigen matrix type
  • at least one constructor that sets the shape from dimensions
  • static member function get_shape_of that takes a compatible matrix expression and returns it's shape
  • const member functions rows() and cols()
  • trivially copyable, moveable, assignable, move assignable
  • equality comparable

Typedef Documentation

◆ ConstParameterDistributionVisitor

◆ CVPlainMatrixT

template<class M >
using mio::CVPlainMatrixT = typedef typename CVPlainMatrix<M>::Type

◆ DefaultIntegratorCore

template<typename FP >
using mio::DefaultIntegratorCore = typedef mio::ControlledStepperWrapper<FP, boost::numeric::odeint::runge_kutta_cash_karp54>

The default integrator used by Simulation.

◆ DerivFunction

template<typename FP >
using mio::DerivFunction = typedef std::function<void(Eigen::Ref<const Eigen::VectorX<FP> > y, FP t, Eigen::Ref<Eigen::VectorX<FP> > dydt)>

Function template to be integrated.

Template Parameters
FPA floating point type, e.g. double.

◆ FeedbackSimulationParameters

◆ has_get_default_member_function

template<class T , class... Args>
using mio::has_get_default_member_function = typedef details::has_get_default_member_function<T, void, Args...>

check whether a get_default function exists

Template Parameters
Thetype to check for the existence of the member function

◆ HistoryWithMemoryWriter

template<class... Loggers>
using mio::HistoryWithMemoryWriter = typedef History<DataWriterToMemory, Loggers...>

◆ InterpolateResultT

template<class T >
using mio::InterpolateResultT = typedef std::decay_t<decltype(interpolate_simulation_result(std::declval<T>()))>

helper template, type returned by overload interpolate_simulation_result(T t)

◆ IOResult

template<class T >
using mio::IOResult = typedef boost::outcome_v2::unchecked<T, IOStatus>

Value-or-error type for operations that return a value but can fail.

Can also be used for functions that return void so that all IO functions have compatible signatures. e.g. IOResult<int> parse_int(const std::string& s); IOResult<void> mkdir(const std::string& path);

Create IOResult objects with:

  • success(t), failure(e): Create objects that store a T or IOStatus and are implicitly convertible to IOResult. This is the easiest way to return from a function that returns an IOResult.
  • constructors: IOResult can normally be constructed directly from T or IOStatus. If T is convertible to an error code (e.g. T = int), these constructors are disabled. There are constructors IOResult(Tag<T>{}, t) and IOResult(Tag<IOStatus>{}, e) that always work.

Inspect the result with:

  • operator bool(): true if result represents success.
  • value(): returns a reference to the value.
  • error(): returns a reference to the error. value()/error() assert (terminate in debug mode) if the result is not succesful/not an error.

When nesting functions that return IOResult, it is also possible to unpack the value and forward errors using the macro BOOST_OUTCOME_TRY. The statement BOOST_OUTCOME_TRY(x, try_get_x()); is equivalent to the statements

auto result = try_get_x();
if (!result) {
return result.as_failure();
}
auto&& x = result.value();

This way, code the branches that are added for error handling are not visible in your code, the logic looks completely linear, e.g.:

extern void use_int(int i);
IOResult<void> parse_and_use_int(const std::string& s)
{
BOOST_OUTCOME_TRY(auto&& i, parse_int(s));
use_int(i);
return success();
}
auto i
Definition: io.h:809
auto success()
Create an object that is implicitly convertible to a succesful IOResult<void>.
Definition: io.h:359

The variable name can be omitted for operations that return IOResult<void>.

See also
https://www.boost.org/doc/libs/1_75_0/libs/outcome/doc/html/index.html
Template Parameters
thetype produced by an opertion that can fail.

◆ is_64bit_integral

template<class T >
using mio::is_64bit_integral = typedef std::integral_constant<bool, (std::is_integral_v<T> && sizeof(T) == 8)>

Bool constant to check whether T is an integral type of 64 bits. Used for Json library.

◆ is_no_default_init_tag

template<typename T >
using mio::is_no_default_init_tag = typedef std::is_same<NoDefaultInit, T>

◆ is_small_integral

template<class T >
using mio::is_small_integral = typedef std::integral_constant<bool, (std::is_integral_v<T> && sizeof(T) <= 4)>

Bool constant to check whether T is an integral type of 32 bits or less. Used for Json library.

◆ MobilityCoefficientGroup

template<typename FP >
using mio::MobilityCoefficientGroup = typedef DampingMatrixExpressionGroup<FP, MobilityCoefficients<FP> >

sum of time dependent mobility coefficients.

differentiate between sources of mobility.

◆ MobilityCoefficients

template<typename FP >
using mio::MobilityCoefficients = typedef DampingMatrixExpression<FP, VectorDampings<FP> >

time dependent mobility coefficients.

status and age dependent mobility coefficients.

◆ not_copyable_if

template<bool Cond>
using mio::not_copyable_if = typedef std::conditional<Cond, details::NoCopy, details::Empty>

Defines a type that is not copy constructible or assignable if the specified condition is true.

Otherwise, defines a type that is copyable. In both cases, the type will be trivially moveable and constructible. To be used as a base type to make a class conditionally copyable. Can be used to e.g. ensure that std::is_copy_constructible and std::is_copy_assignable is true only if the type can actually be copied (Note: this is not true for some STL containers, e.g., std::vector).

◆ not_copyable_if_t

template<bool Cond>
using mio::not_copyable_if_t = typedef typename not_copyable_if<Cond>::type

equivalent to not_copyable_if<Cond>::type.

See also
not_copyable_if

◆ OdeIntegrator

template<typename FP >
using mio::OdeIntegrator = typedef SystemIntegrator<FP, DerivFunction<FP> >

Solver for a system of initial value problems (IVPs) consisting of ordinary differential equations (ODEs).

The IVPs are of the form y'(t) = f(y(t), t), y(0) = y0.

◆ OdeIntegratorCore

template<class FP >
using mio::OdeIntegratorCore = typedef IntegratorCore<FP, DerivFunction<FP> >

Interface for defining solvers for ODE problems. Also.

See also
IntegratorCore and
CompartmentalModel.

◆ ParameterDistributionVisitor

This is a visitor class to visit all Parameter Distribution objects.

More information to the visitor pattern is here: https://en.wikipedia.org/wiki/Visitor_pattern

◆ ParameterTag

template<size_t I, class ParamSet >
using mio::ParameterTag = typedef details::ParameterTag<I, ParamSet>

get the the tag of the I-th parameter in a set

◆ ParameterTagT

template<size_t I, class ParamSet >
using mio::ParameterTagT = typedef typename ParameterTag<I, ParamSet>::Type

◆ SdeIntegrator

template<typename FP >
using mio::SdeIntegrator = typedef SystemIntegrator<FP, DerivFunction<FP>, DerivFunction<FP> >

Solver for a system of initial value problems (IVPs) consisting of stochastic differential equations (SDEs).

The IVPs are of the form dY'(t) = f(Y(t), t)dt + g(Y(t), t)dW(t), y(0) = y0. Each summand corresponds to one DerivFunction.

◆ SdeIntegratorCore

template<class FP >
using mio::SdeIntegratorCore = typedef IntegratorCore<FP, DerivFunction<FP>, DerivFunction<FP> >

Interface for defining solvers for SDE problems. Also.

See also
IntegratorCore and
StochasticModel.

◆ SquareDamping

template<typename FP >
using mio::SquareDamping = typedef Damping<FP, SquareMatrixShape<FP> >

aliases for common damping specializations.

◆ SquareDampings

template<typename FP >
using mio::SquareDampings = typedef Dampings<FP, SquareDamping<FP> >

◆ Tag

template<class T >
using mio::Tag = typedef boost::outcome_v2::in_place_type_t<T>

Type that is used for overload resolution.

Use as dummy arguments to resolve overloads that would otherwise only differ by return type and don't have any other arguments that allow resolution. e.g.

int foo(Tag<int>);
double foo(Tag<double>);

◆ type_at_index_t

template<std::size_t Index, class... Types>
using mio::type_at_index_t = typedef typename type_at_index<Index, Types...>::type

The type at the Index-th position in the list Types.

Equivalent to type_at<Index, Types...>::type.

See also
type_at_index.

◆ VectorDamping

template<typename FP >
using mio::VectorDamping = typedef Damping<FP, ColumnVectorShape<FP> >

◆ VectorDampings

template<typename FP >
using mio::VectorDampings = typedef Dampings<FP, VectorDamping<FP> >

◆ VectorRange

template<class T >
using mio::VectorRange = typedef std::conditional_t<std::is_const_v<T>, typename mio::Range<typename std::vector<std::remove_const_t<T> >::const_iterator>, typename mio::Range<typename std::vector<std::remove_const_t<T> >::iterator> >

Defines generic Range type for IterPair of a vector.

When elements should be const, template argument accepts const type. As vector is not defined for const values, the const specifier is removed and the const_iterator is used. std::conditional tries to compile both cases, thus we also need std::remove_const for the case where T is not const.

◆ VisitableParameterDistribution

Enumeration Type Documentation

◆ IOFlags

flags to determine the behavior of the serialization process.

Objects must be deseralized with the same set of flags as they were serialized.

Enumerator
IOF_None 

default behavior.

IOF_OmitDistributions 

Don't serialize distributions for types that contain both a specific value and a distribution from which new values can be sampled, e.g.

UncertainValue.

IOF_OmitValues 

Don't serialize the current value for types that contain both a specific value and a distribution from which new values can be sampled, e.g., UncertainValue.

IOF_IncludeTypeInfo 

Include type info in the serialization.

Can Increase file size a lot, mostly for debugging.

◆ LogLevel

enum mio::LogLevel
strong
Enumerator
trace 
debug 
info 
warn 
err 
critical 
off 

◆ StatusCode

enum mio::StatusCode
strong

code to indicate the result of an operation.

convertible to std::error_code. see https://www.boost.org/doc/libs/1_75_0/libs/outcome/doc/html/motivation/plug_error_code.html

Enumerator
OK 
UnknownError 
OutOfRange 
InvalidValue 
InvalidFileFormat 
KeyNotFound 
InvalidType 
FileNotFound 

◆ TimeSeriesFunctorType

Type of a TimeSeriesFunctor.

The available types are:

  • LinearInterpolation:
    • Requires at least one time point with exactly one value each. Time must be strictly monotic increasing.
    • Linearly interpolates between data points. Stays constant outside of provided data with first/last value.
Enumerator
LinearInterpolation 

Function Documentation

◆ abs_max()

template<typename FP >
FP mio::abs_max ( FP  v1,
FP  v2 
)

maximum absolute value of two numbers.

Parameters
v1first number
v2second number
Returns
maximum absolute value between v1 and v2

◆ add_list()

obj mio::add_list ( "Items"  ,
container.  begin(),
container.  end() 
)

◆ advance_model() [1/2]

template<class... History>
void mio::advance_model ( abm::TimePoint  t,
abm::TimeSpan  dt,
ABMSimulationNode< History... > &  node 
)

Node functor for abm graph simulation.

See also
ABMSimulationNode::advance
Parameters
[in]tTime point the functor is applied.
[in]dtTime interval the node is advanced.
[in]nodeABMSimulationNode to which the functor is applied.

◆ advance_model() [2/2]

template<typename FP , class Sim >
void mio::advance_model ( FP  t,
FP  dt,
SimulationNode< FP, Sim > &  node 
)

edge functor for mobility-based simulation.

See also
SimulationNode::advance

◆ apply() [1/3]

return mio::apply ( io  ,
[] (auto &&i_) { return Container(i_.begin(), i_.end());}  ,
i   
)

◆ apply() [2/3]

template<class IOContext , class F , class... T>
details::ApplyResultT<F, T...> mio::apply ( IOContext &  io,
f,
const IOResult< T > &...  rs 
)

Evaluate a function with zero or more unpacked IOResults as arguments.

Returns an IOResult that contains the result of f(rs.value()...) if all IOResults rs contain a value. If any IOResult contains an error, that error is returned instead. The function f may return an object of any type U. It can also return IOResult (e.g. to validate the values contained in the arguments). In either case, apply returns IOResult and never any nested IOResult<IOResult>. If apply returns an error, it is also stored in the given IO context so that the context is informed of e.g. validation errors that cannot be checked simply from the types and the format of the file.

Template Parameters
IOContexta type with a set_error(const IOStatus&) member function.
Fa type that has a function call operator with signature either U F(T&&...) or IOResult<U> F(T&&...) for any U.
Tzero ore more types of values contained in the IOResult arguments.
Parameters
ioan IOContext that is notified of errors.
fthe function that is called with the values contained in rs as arguments.
rszero or more IOResults from previous operations.
Returns
the result of f(rs.value()...) if successful, the first error encountered otherwise.

◆ apply() [3/3]

template<class IOContext , class F , class... T>
details::ApplyResultT<F, T...> mio::apply ( IOContext &  io,
f,
const std::tuple< IOResult< T >... > &  results 
)

Evaluate a function with zero or more unpacked IOResults as arguments.

Returns an IOResult that contains the result of f(rs.value()...) if all IOResults rs contain a value. If any IOResult contains an error, that error is returned instead. The function f may return an object of any type U. It can also return IOResult (e.g. to validate the values contained in the arguments). In either case, apply returns IOResult and never any nested IOResult<IOResult>. If apply returns an error, it is also stored in the given IO context so that the context is informed of e.g. validation errors that cannot be checked simply from the types and the format of the file.

Template Parameters
IOContexta type with a set_error(const IOStatus&) member function.
Fa type that has a function call operator with signature either U F(T&&...) or IOResult<U> F(T&&...) for any U.
Tzero ore more types of values contained in the IOResult arguments.
Parameters
ioan IOContext that is notified of errors.
fthe function that is called with the values contained in rs as arguments.
rszero or more IOResults from previous operations.
Returns
the result of f(rs.value()...) if successful, the first error encountered otherwise.

◆ apply_dampings()

template<class DampingExpression , class DampingSamplings , class F >
void mio::apply_dampings ( DampingExpression &  damping_expression,
const DampingSamplings &  dampings,
make_matrix 
)

add sampled dampings to a damping expression.

does not draw new random value, just adds dampings.

Parameters
damping_expressione.g. contact matrix group.
dampingssampled dampings.
make_maskfunctor that creates a matrix from damping value weighted by group.

◆ apply_mobility() [1/3]

template<class... History>
void mio::apply_mobility ( abm::TimePoint  t,
abm::TimeSpan  ,
ABMMobilityEdge< History... > &  edge,
ABMSimulationNode< History... > &  node_from,
ABMSimulationNode< History... > &  node_to 
)

Edge functor for abm graph simulation.

See also
ABMMobilityEdge::apply_mobility The attribute dt is required by the GraphSimulation class and therefore an input argument of the function. However it is not used in ABMMobilityEdge::apply_mobility.
Parameters
[in]tTime point the functor is applied.
[in]edgeABMMobilityEdge for which the functor is applied.
[in]node_fromEdge start node.
[in]node_toEdge end node.

◆ apply_mobility() [2/3]

template<typename FP , class Sim >
void mio::apply_mobility ( FP  t,
FP  dt,
MobilityEdge< FP > &  mobilityEdge,
SimulationNode< FP, Sim > &  node_from,
SimulationNode< FP, Sim > &  node_to 
)

edge functor for mobility-based simulation.

See also
MobilityEdge::apply_mobility

◆ apply_mobility() [3/3]

template<typename FP , class Sim , class StochasticEdge >
void mio::apply_mobility ( StochasticEdge &  mobilityEdge,
size_t  event,
SimulationNode< FP, Sim > &  node_from,
SimulationNode< FP, Sim > &  node_to 
)

edge functor for mobility-based simulation.

See also
MobilityEdgeStochastic::apply_mobility

◆ base_dir()

static const std::string mio::base_dir ( )
static

Returns the absolute path to the project directory.

◆ begin() [1/3]

template<IsMatrixExpression M>
RowMajorIterator<M, true> mio::begin ( const M &  m)

create a const iterator to first element of the matrix m.

◆ begin() [2/3]

template<class... Categories>
MultiIndexIterator<Index<Categories...> > mio::begin ( Index< Categories... >  dimensions)

STL iterator for a MultiIndex.

The range spans over [0, d) for each category in the MultiIndex, where d is that category's value in dimensions.

Parameters
[in]dimensionsA MultiIndex that contains the dimension for each category.
Template Parameters
CategoriesAll categories of the given MultiIndex.
Returns
Returns the first index for the given dimensions, i.e. 0.

◆ begin() [3/3]

template<IsMatrixExpression M>
requires details::IsElementReference<M> RowMajorIterator<M, false> mio::begin ( M &  m)

create a non-const iterator to first element of the matrix m.

only enabled if the matrix is evaluated in memory, i.e. elements can be modified.

◆ calculate_mobility_returns()

template<typename FP , IsCompartmentalModelSimulation< FP > Sim>
void mio::calculate_mobility_returns ( Eigen::Ref< typename TimeSeries< FP >::Vector >  mobile_population,
const Sim &  sim,
Eigen::Ref< const typename TimeSeries< FP >::Vector >  total,
FP  t,
FP  dt 
)

adjust number of people that changed node when they return according to the model.

E.g. during the time in the other node, some people who left as susceptible will return exposed. Implemented for general compartmentmodel simulations, overload for your custom model if necessary so that it can be found with argument-dependent lookup, i.e. in the same namespace as the model.

Parameters
[in,out]mobile_populationnumber of people that changed node as input, number of people that return as output
paramsparameters of model in the node that the people changed to.
totaltotal population in the node that the people changed to.
ttime of mobility
dttime between mobility and return

◆ calculate_partial_sum_of_months()

std::array<int, 12> mio::calculate_partial_sum_of_months ( const Date date)
inline

Computes the cumulative number of days at the end of each month for a given year.

Parameters
dateDate object representing the year we use to compute the cumulative days.
Returns
array with partial sum for each month

◆ cbegin()

template<IsMatrixExpression M>
RowMajorIterator<M, true> mio::cbegin ( const M &  m)

create a const iterator to first element of the matrix m.

◆ cend()

template<IsMatrixExpression M>
RowMajorIterator<M, true> mio::cend ( const M &  m)

create a non-const end iterator for the matrix m.

◆ concatenate_indices()

template<class... IndexArgs>
decltype(auto) mio::concatenate_indices ( IndexArgs &&...  args)

Combine several Indexs into one MultiIndex.

Parameters
argsEither enum or MultiIndex values.
Returns
A MultiIndex with all categories and values of the given Indices concatonated.

◆ contains()

template<class Iter , class Pred >
bool mio::contains ( Iter  b,
Iter  e,
Pred  p 
)

checks if there is an element in this range that matches a predicate

◆ count_lines()

IOResult< int > mio::count_lines ( const std::string &  filename)

Counts lines of txt file.

Parameters
filenamename of file which is counted

◆ create_directory() [1/2]

IOResult< bool > mio::create_directory ( std::string const &  rel_path)

Creates a directory in the file system.

Parameters
rel_pathpath of directory relative to current working directory.
Returns
true if the directory was created, false if it already exists, or any errors that occured.

◆ create_directory() [2/2]

IOResult< bool > mio::create_directory ( std::string const &  rel_path,
std::string &  abs_path 
)

Creates a directory in the file system.

Parameters
rel_pathpath of directory relative to current working directory.
abs_pathWill contain the absolute path of the directory.
Returns
true if the directory was created, false if it already exists, or any errors that occured.

◆ DECL_TYPESAFE() [1/2]

mio::DECL_TYPESAFE ( int  ,
DampingLevel   
)

integer damping level.

◆ DECL_TYPESAFE() [2/2]

mio::DECL_TYPESAFE ( int  ,
DampingType   
)

integer damping type.

◆ deserialize()

template<class IOContext , class T >
IOResult< T > mio::deserialize ( IOContext &  io,
Tag< T >  tag 
)

Restores an object from the data stored in an IO context.

There must be provided for the type T either a free function deserialize_internal(io, tag) that can be found using argument dependent lookup (ADL) or a static member function T::deserialize(io). The deserialize_internal function or deserialize member function retrieve the data needed to restore the object from the IO context. The context provides the data if it can and keeps track of errors. deserialize_internal overloads are already provided for many common types, e.g. STL containers or Eigen Matrices. serialize and deserialize are the main entry points into this IO framework, but there may be more convenient functions provided for specific IO contexts. These functions are not expected to use ADL, so should be called namespace qualified.

Template Parameters
IOContexta type that models the IOContext concept.
Tany deserializable type, i.e., that has a deserialize member function or deserialize_internal overload
Parameters
ioIO context that contains the data for an object of type T
tagspecifies the type to be restored from the data, for overload resolution only.
Returns
the restored T if succesful, an error code otherwise.

◆ deserialize_binary()

template<class T >
IOResult<T> mio::deserialize_binary ( ByteStream stream,
Tag< T >  ,
int  flags = 0 
)

Deserialize an object from binary format.

Parameters
streamByteStream that contains the bytes that represent the object.
tagTag that carries the type of the object to be deserialized.
Returns
The deserialized object if succesful, an error otherwise.
Template Parameters
Tthe type of the object to be serialized.

◆ deserialize_internal() [1/7]

template<class IOContext >
IOResult<AbstractParameterDistribution> mio::deserialize_internal ( IOContext &  io,
Tag< AbstractParameterDistribution  
)

◆ deserialize_internal() [2/7]

template<class IOContext , class E >
requires std::is_enum_v<E> IOResult<E> mio::deserialize_internal ( IOContext &  io,
Tag< E >   
)

deserialize an enum value from its underlying type.

It is impossible to validate the range of the enum type, validate after if necessary.

Template Parameters
IOContexta type that models the IOContext concept.
Ean enum type to be deserialized.
Parameters
ioan IO context
tagdefines the type of the enum to be deserialized
Returns
an enum value if succesful, an error otherwise.

◆ deserialize_internal() [3/7]

template<class IOContext , IsMatrixExpression M>
IOResult<M> mio::deserialize_internal ( IOContext &  io,
Tag< M >   
)

deserialize an Eigen matrix.

It is possible to serialize an unevaluated expression, e.g. Eigen::MatrixXd::Constant(r, c, v). But it is (at least currently) not possible to deserialize it. Only matrices that own their memory can be deserialized.

Template Parameters
IOContexta type that models the IOContext concept.
Mthe type of Eigen matrix expression to be deserialized.
Parameters
ioan IO context.
tagdefines the type of the matrix to be serialized.

◆ deserialize_internal() [4/7]

template<class IOContext , size_t N>
IOResult<std::bitset<N> > mio::deserialize_internal ( IOContext &  io,
Tag< std::bitset< N >>  tag 
)

Deserialize an std::bitset.

Template Parameters
IOContextA type that models the IOContext concept.
NThe size of the bitset.
Parameters
ioAn IO context.
tagDefines the type of the object that is to be deserialized.
Returns
The restored object if successful, an error otherwise.

◆ deserialize_internal() [5/7]

template<class IOContext >
IOResult<std::shared_ptr<ParameterDistribution> > mio::deserialize_internal ( IOContext &  io,
Tag< std::shared_ptr< ParameterDistribution >>   
)

deserialize a parameter distribution as a shared_ptr.

See also
mio::deserialize

◆ deserialize_internal() [6/7]

template<class IOContext , IsDefaultDeserializable< IOContext > T>
IOResult< T > mio::deserialize_internal ( IOContext &  io,
Tag< T >  tag 
)

Deserialization implementation for the default serialization feature.

deserialize an object that has a deserialize(io) static member function.

Disables itself (SFINAE) if there is no default_serialize member or if a deserialize member is present. Generates the deserialize method depending on the NamedRefs given by default_serialize.

Template Parameters
IOContextA type that models the IOContext concept.
DefaultSerializableA type that can be default serialized.
Parameters
ioAn IO context.
tagDefines the type of the object that is to be deserialized (i.e. DefaultSerializble).
Returns
The restored object if successful, an error otherwise.
Template Parameters
IOContexta type that models the IOContext concept.
Tthe type of the object to be deserialized. Must have a serialize member function.
Parameters
ioan io context.
tagdefines the type of the object for overload resolution.
Returns
the restored object if succesful, an error otherwise.

◆ deserialize_internal() [7/7]

template<class IOContext , template< class... > class Tup, class... T>
requires std::same_as<Tup<T...>, std::pair<T...> > std::same_as<Tup<T...>, std::tuple<T...> > IOResult<Tup<T...> > mio::deserialize_internal ( IOContext &  io,
Tag< Tup< T... >>  tag 
)

deserialize a tuple-like object, e.g.

std::tuple or std::pair.

Template Parameters
IOContexta type that models the IOContext concept.
Tupthe tuple-like type to be deserialized, i.e. anything that supports tuple_size and tuple_element.
Parameters
ioan IO context.
tagdefine the type of the object to be deserialized.
Returns
a restored tuple

◆ dynamic_unique_ptr_cast()

template<class U , class T >
std::unique_ptr<U> mio::dynamic_unique_ptr_cast ( std::unique_ptr< T > &&  base_ptr)

converts a unique_ptr<T> to unique_ptr.

behavior is similar to normal dynamic_cast except if the conversion is successful, the original unique_ptr<T> is now in a moved-from state and ownership of the object has been transferred to the returned unique_ptr.

Parameters
base_ptrptr to object to convert
Returns
converted unique_ptr if object can be cast to U, default unique_ptr otherwise

◆ end() [1/3]

template<IsMatrixExpression M>
RowMajorIterator<M, true> mio::end ( const M &  m)

create a const end iterator for the matrix m.

◆ end() [2/3]

template<class... Categories>
MultiIndexIterator<Index<Categories...> > mio::end ( Index< Categories... >  dimensions)

STL iterator for a MultiIndex.

The range spans over [0, d) for each category in the MultiIndex, where d is that category's value in dimensions.

Parameters
[in]dimensionsA MultiIndex that contains the dimension for each category.
Template Parameters
CategoriesAll categories of the given MultiIndex.
Returns
Returns the first index outside of the given dimensions.

◆ end() [3/3]

template<IsMatrixExpression M>
requires details::IsElementReference<M> RowMajorIterator<M, false> mio::end ( M &  m)

create a non-const end iterator for the matrix m.

◆ ensemble_mean()

template<typename FP >
std::vector< TimeSeries< FP > > mio::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 returned by interpolated_ensemble_result: same number of nodes, same time points and elements.

See also
interpolated_ensemble_result
Parameters
ensemble_resultsuniform results of multiple simulation runs
Returns
mean of the results over all runs

◆ ensemble_percentile()

template<typename FP >
std::vector< TimeSeries< FP > > mio::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.

Produces for each compartment the value that that is bigger than approximately a p-th share of the values of this compartment over all runs. input must be uniform as returned by interpolated_ensemble_result: same number of nodes, same time points and elements.

See also
interpolated_ensemble_result
Parameters
ensemble_resultuniform results of multiple simulation runs
ppercentile value in open interval (0, 1)
Returns
p percentile of the results over all runs

◆ enum_members()

template<class T >
constexpr std::array<T, size_t(T::Count)> mio::enum_members ( )
constexpr

Get an std::array that contains all members of an enum class.

The enum class must be a valid index, i.e. members must be sequential starting at 0 and there must be a member Count at the end, that will not be included in the array. Example:

enum class E { A, B, Count };
assert(enum_members<E>() == std::array<2, E>(E::A, E::B));
Template Parameters
TAn enum class that is a valid index.
Returns
Array of all members of the enum class not including T::Count.

◆ evaluate_intermediate()

template<typename Type , typename Intermediate >
auto mio::evaluate_intermediate ( Intermediate &&  x)
inline

Evaluate an intermediate expression to its underlying type, if necessary.

Parameters
xAn intermediate expression, resulting e.g. from auto x = y + z.
Template Parameters
TypeUnderlying type of the expression, e.g. an AD type. Usually this is set to FP.
IntermediateType of the expression result. Do not specify this template, let the compiler deduce it.
Returns
Either casts the intermediate expression to Type, or forwards it.

The main purpose of this function is reconcile the handling of intermediate types from Eigen and AD. Eigen wants to return intermediates for optimization, while AD values must be evaluated (due to using references).

◆ extend_index()

template<class SuperIndex , class SubIndex >
SuperIndex mio::extend_index ( const SubIndex &  index,
size_t  fill_value = 0 
)

Create a SuperIndex by copying values from SubIndex, filling new categories with fill_value.

If a type T is contained multiple times in SubIndex, only the first occurance of T is used. For example, extend_index<Index<T, T, T>>(Index<T, T>{1,2}) returns {1,1,1}.

Parameters
[in]indexAn instance of SubIndex
[in]fill_valueThe value to use for categories not in SubIndex.
Template Parameters
SuperIndexAny Index.
SubIndexAn Index that contains a subset of the categories from SuperIndex.
Returns
A (super)index with the given categories and values from index.

◆ failure() [1/2]

auto mio::failure ( const IOStatus s)
inline

Create an object that is implicitly convertible to an error IOResult<T>.

Use return failure(s) to conveniently return an error from a function.

Parameters
sthe status that contains the error.

◆ failure() [2/2]

auto mio::failure ( std::error_code  c,
const std::string &  msg = "" 
)
inline

Create an object that is implicitly convertible to an error IOResult<T>.

Use return failure(c, msg) to conveniently return an error from a function.

Parameters
can error code.
msga string that contains more information about the error.

◆ file_exists()

bool mio::file_exists ( std::string const &  rel_path,
std::string &  abs_path 
)

Check if a file exists.

Also computes the absolute path of the file.

Parameters
[in]rel_pathrelative path to the file.
[out]abs_pathabsolute path, computed by the function.
Returns
true if the file exists.

◆ find_value_reverse()

template<class FP , class TS >
decltype(std::declval<TS>().rend()) mio::find_value_reverse ( TS &&  ts,
FP  t_search,
FP  abs_tol = 0,
FP  rel_tol = 0 
)

find the value in the time series at time t_search starting from the end.

Parameters
tsTimeSeries to seach
t_searcha time point
abs_tolabsolute floating point tolerance for equality of time values
rel_tolrelative floating point tolerance for equality of time values
Returns
TimeSeries::reverse_iterator that points to ts[t_search] or ts.rend()

◆ flatten_index()

template<typename MultiIndex >
size_t mio::flatten_index ( MultiIndex const &  indices,
MultiIndex const &  dimensions 
)

flatten_index takes a set of indices into a mutlidemsional array and calculates the flat index

Given indices (i,j,k,...) of a tensor with dimensions (n,m,l,...), flatten_index calculates the index of the corresponding element if the elements are sorted sequentially in a row major fashion (that is right indices are incremented before left indices)

Parameters
indicesa vector of indices of a hypothetical tensor
dimensionsa vector of the dimension sizes of each dimension
Returns
the corresponding flat index

◆ floating_point_equal()

template<typename FP >
bool mio::floating_point_equal ( FP  v1,
FP  v2,
FP  abs_tol = 0,
FP  rel_tol = std::numeric_limits<FP>::min() 
)

compare two floating point values for equality with tolerances.

Use absolute tolerance for comparisons with zero or if you know the magnitude of the values. Otherwise use relative tolerance. If unsure, use both.

Parameters
v1first floating point value
v2second floating point value
abs_tolmaximum allowed absolute difference, default 0.
rel_tolmaximum allowed relative difference, default numeric_limits::min.
Returns
true if v1 is within the specified relative OR absolute tolerance of v2

◆ floating_point_greater()

template<typename FP >
bool mio::floating_point_greater ( FP  v1,
FP  v2,
FP  abs_tol = 0,
FP  rel_tol = std::numeric_limits<FP>::min() 
)

compare two floating point values with tolerances.

v1 > v2 if a) v1 not == v2 within tolerances AND b) v1 not < v2. Use absolute tolerance for comparisons with zero or if you know the magnitude of the values. Use relative tolerance (or both) otherwise.

Parameters
v1first floating point value
v2second floating point value
abs_tolmaximum allowed absolute difference, default 0.
rel_tolmaximum allowed relative difference, default numeric_limits::min.
Returns
true if v1 is greater than v2 and not within absolute or relative tolerance of v2.

◆ floating_point_greater_equal()

template<typename FP >
bool mio::floating_point_greater_equal ( FP  v1,
FP  v2,
FP  abs_tol = 0,
FP  rel_tol = std::numeric_limits<FP>::min() 
)

compare two floating point values with tolerances.

v1 >= v2 if a) v1 > v2 OR b) v1 == v2 within tolerances. Use absolute tolerance for comparisons with zero or if you know the magnitude of the values. Use relative tolerance (or both) otherwise.

Parameters
v1first floating point value
v2second floating point value
abs_tolmaximum allowed absolute difference, default 0.
rel_tolmaximum allowed relative difference, default numeric_limits::min.
Returns
true if v1 is greater than v2 or within absolute or relative tolerance of v2.

◆ floating_point_less()

template<typename FP >
bool mio::floating_point_less ( FP  v1,
FP  v2,
FP  abs_tol = 0,
FP  rel_tol = std::numeric_limits<FP>::min() 
)

compare two floating point values with tolerances.

v1 < v2 if a) v1 not == v2 within tolerances and b) v1 not > v2. Use absolute tolerance for comparisons with zero or if you know the magnitude of the values. Use relative tolerance (or both) otherwise.

Parameters
v1first floating point value
v2second floating point value
abs_tolmaximum allowed absolute difference for equality, default 0.
rel_tolmaximum allowed relative difference for equality, default numeric_limits::min.
Returns
true if v1 is less than v2 and not within relative or absolute tolerance of v2.

◆ floating_point_less_equal()

template<typename FP >
bool mio::floating_point_less_equal ( FP  v1,
FP  v2,
FP  abs_tol = 0,
FP  rel_tol = std::numeric_limits<FP>::min() 
)

compare two floating point values with tolerances.

v1 <= v2 if a) v1 < v2 OR b) v1 == v2 within tolerances. Use absolute tolerance for comparisons with zero or if you know the magnitude of the values. Use relative tolerance (or both) otherwise.

Parameters
v1first floating point value
v2second floating point value
abs_tolmaximum allowed absolute difference, default 0.
rel_tolmaximum allowed relative difference, default numeric_limits::min.
Returns
true if v1 is less than v2 or within relative or absolute tolerances of v2.

◆ foreach() [1/2]

template<class F , class... Tags>
void mio::foreach ( const ParameterSet< Tags... > &  p,
f 
)

call f(p, t) for all parameters in a ParameterSet with p the value of the parameter t a default constructed parameter tag

Template Parameters
FThe function type of f
Tagsthe parameters
Parameters
pthe ParameterSet
fThe function to be called

◆ foreach() [2/2]

template<class F , class... Tags>
void mio::foreach ( ParameterSet< Tags... > &  p,
f 
)

◆ foreach_tag()

template<class Params , class F >
void mio::foreach_tag ( f)

call f(t) for all parameters in a ParameterSet with t a default constructed parameter tag

Template Parameters
Paramsa ParameterSet
FThe function type of f
Parameters
fThe function to be called

◆ format_as() [1/2]

std::string mio::format_as ( const mio::Date d)
inline

Format date objects using the ISO notation for logging with spdlog.

Parameters
ddate object.

◆ format_as() [2/2]

template<class FP >
const FP& mio::format_as ( const UncertainValue< FP > &  uv)

Format UncertainValues using their value for logging with spdlog.

◆ get() [1/4]

template<size_t I, typename... CategoryTags>
constexpr std::tuple_element<I, std::tuple<Index<CategoryTags>...> >::type& mio::get ( Index< CategoryTags... > &  i)
constexprnoexcept

Retrieves the Index (by reference) at the Ith position of a MultiIndex.

◆ get() [2/4]

template<typename Tag , typename... CategoryTags>
constexpr Index<Tag>& mio::get ( Index< CategoryTags... > &  i)
constexprnoexcept

Retrieves the Index (by reference) by its Tag in a MultiIndex. Requires unique tags.

◆ get() [3/4]

template<size_t I, typename... CategoryTags>
constexpr std::tuple_element<I, std::tuple<Index<CategoryTags>...> >::type const& mio::get ( Index< CategoryTags... > const &  i)
constexprnoexcept

Retrieves the Index (by const reference) at the Ith position of a MultiIndex.

◆ get() [4/4]

template<typename Tag , typename... CategoryTags>
constexpr Index<Tag> const& mio::get ( Index< CategoryTags... > const &  i)
constexprnoexcept

Retrieves the Index (by const reference) by its Tag in a MultiIndex. Requires unique tags.

◆ get_active_damping()

template<typename FP , class DampingExpr >
Eigen::Ref<const typename DampingExpr::Matrix> mio::get_active_damping ( const DampingExpr &  damping_expr,
DampingLevel  lvl,
DampingType  type,
SimulationTime< FP >  t 
)

Get the value of the damping that matches the given type and level and that is active at the specified time.

If no damping is found, returns a zero matrix of the correct shape. Utility for implementation of dynamic NPIs.

Parameters
damping_exprsome matrix expression that contains dampings, e.g. a ContactMatrix.
lvldamping level to match
typedamping type to match
timetime where the damping is active
Returns
matrix of damping coefficients if active damping is found. zero matrix otherwise.

◆ get_current_dir_name()

std::string mio::get_current_dir_name ( )

Returns the current working directory name.

◆ get_damping_indices()

template<typename FP , class DampingExpr >
std::vector<size_t> mio::get_damping_indices ( const DampingExpr &  damping_expr,
DampingLevel  lvl,
DampingType  type,
SimulationTime< FP >  begin,
SimulationTime< FP >  end 
)

Get a list of indices of specified dampings.

Returns the indices of dampings that match the given type and level and that become active in the specified time span (excluding the particular interval boundaries, begin and end). Utility for implementation of dynamic NPIs.

Parameters
damping_exprsome matrix expression that contains dampings, e.g. a ContactMatrix.
lvldamping level to match
typedamping type to match
beginbeginning of the time span that contains the dampings
endend of the time span that contains the dampings.
Returns
list of indices in range damping_expr.get_dampings()

◆ get_day_in_year()

int mio::get_day_in_year ( Date  date)
inline

Computes the day in year based on a given date.

Parameters
datedate
Returns
day in year, starting January, 1st, with 1.

◆ get_infections_relative()

template<typename FP , class Sim >
FP mio::get_infections_relative ( const SimulationNode< FP, Sim > &  node,
FP  t,
const Eigen::Ref< const Eigen::VectorX< FP >> &  y 
)

get the percantage of infected people of the total population in the node If dynamic NPIs are enabled, there needs to be an overload of get_infections_relative(model, y) for the Model type that can be found with argument-dependent lookup.

Ideally define get_infections_relative in the same namespace as the Model type.

Parameters
nodea node of a mobility graph.
ythe current value of the simulation.
tthe current simulation time

◆ get_mobility_factors()

template<typename FP , class Sim >
auto mio::get_mobility_factors ( const SimulationNode< FP, Sim > &  node,
FP  t,
const Eigen::Ref< const Eigen::VectorX< FP >> &  y 
)

Get an additional mobility factor.

The absolute mobility for each compartment is computed by c_i * y_i * f_i, wher c_i is the coefficient set in MobilityParameters, y_i is the current compartment population, f_i is the factor returned by this function. This factor is optional, default 1.0. If you need to adjust mobility in that way, overload get_mobility_factors(model, t, y) for your Model type so that can be found with argument-dependent lookup.

Parameters
nodea node of a mobility graph.
ythe current value of the simulation.
tthe current simulation time
Returns
a vector expression, same size as y, with the factor for each compartment.

◆ get_month_length()

int mio::get_month_length ( Date  date)
inline

Computes the length of a month for a given date.

Parameters
datedate.
Returns
length of month for given date

◆ get_offset_in_days()

int mio::get_offset_in_days ( Date  date1,
Date  date2 
)
inline

Computes the offset in days given two dates: first date minus second date.

Parameters
date1first date.
date2second date.
Returns
offset in days between the two dates.

◆ implement_dynamic_npis()

template<typename FP , class DampingExprGroup , class MakeMatrix >
void mio::implement_dynamic_npis ( DampingExprGroup &  damping_expr_group,
const std::vector< DampingSampling< FP >> &  npis,
SimulationTime< FP >  begin,
SimulationTime< FP >  end,
MakeMatrix &&  make_matrix 
)

implement dynamic NPIs for a time span.

Adds or removes dampings to ensure that the active dampings during the specified time span is at least as big as the specified dynamic dampings. If another damping of the same type and level is active at the beginning of the time span or becomes active during the time span, the coefficient wise maximum of the new damping and the existing damping is used. At the end of the time span, another set of dampings may be added that restores the dampings on each level and type as they would have been without the dynamic npis that have just been implemented. Examples: a) no damping exists yet, dynamic npi of value d: one damping is added at the beginning of the time span that has the value d, another damping is added at the end of the time span that has a value zero. b) damping of value a is active before the beginning of the time span, dynamic npi of value d is added: one damping is added at the beginning of the time span that has the value max(a, d), another damping is added at the end of the time span that has the value a b) damping of value a becomes active at a time t_a between the beginning of the time span and the end, dynamic npi of value d is added: one damping is added at the beginning of the time span that has the value d, the value of the damping at time t_a is set to max(d, a), another damping is added at the end of the time span that has the value a

Parameters
damping_expr_groupa group of matrix expressions that contains dampings, e.g. a ContactMatrixGroup.
dynamic_npisthe NPIs to be implemented
beginbeginning of the time span that the NPIs will be active for.
endend of the time span that the NPIs will be active for.
make_matrixfunction to make a matrix of the same shape as the damping expression, see e.g. make_contact_damping_matrix

◆ insert_sorted_replace() [1/2]

template<typename T >
void mio::insert_sorted_replace ( std::vector< T > &  vec,
T const &  item 
)

◆ insert_sorted_replace() [2/2]

template<typename T , typename Pred >
void mio::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 vector are partially sorted and unique according the predicate postcondition: same as precondition, additionally contains exactly one element that is equal to item, order of other items is preserved

Parameters
vecvector where item will be inserted
itemitem to insert
predbinary comparator, pred(item, a) returns true if item should go before element a, pred(a, item) returns true if element a should go before item

◆ interpolate_ensemble_results()

template<class T >
std::vector<InterpolateResultT<T> > mio::interpolate_ensemble_results ( const std::vector< T > &  ensemble_results)

Interpolates results of all runs with evenly spaced, integer time points that represent whole days.

See also
interpolate_simulation_result
Parameters
ensemble_resultresult of multiple simulations (single TimeSeries or Graph)
Returns
interpolated time series, one (or as many as nodes in the graph) per result in the ensemble

◆ interpolate_simulation_result() [1/3]

template<typename FP , class Simulation >
std::vector<TimeSeries<FP> > mio::interpolate_simulation_result ( const Graph< SimulationNode< FP, Simulation >, MobilityEdge< FP >> &  graph_result)

interpolate time series with evenly spaced, integer time points for each node.

See also
interpolate_simulation_result
Parameters
graph_resultgraph of simulations whose results will be interpolated
Returns
one interpolated time series per node

◆ interpolate_simulation_result() [2/3]

template<typename FP >
TimeSeries< FP > mio::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.

We choose the time points for the interpolated time series using the first and last time points, t0 and tmax, as [ceil(t0 - abs_tol), floor(t0) + 1, ..., floor(tmax + abs_tol)]. The tolerances in the first and last time point account for inaccuracies from the integration scheme or floating point arithmetic. Avoid using large(r) tolerances, as this function can not extrapolate results. The values at new time points are linearly interpolated from their immediate neighbors within the given time series.

See also
interpolate_simulation_result
Parameters
simulation_resultA time series to interpolate.
abs_tolOptional parameter to set the absolute tolerance used to account for small deviations from whole days. Must be less then 1. The default tolerance is chosen to minimize the chances of "loosing" days due to rounding.
Returns
An interpolated time series with integer valued times.

◆ interpolate_simulation_result() [3/3]

template<typename FP >
TimeSeries< FP > mio::interpolate_simulation_result ( const TimeSeries< FP > &  simulation_result,
const std::vector< FP > &  interpolation_times 
)

Interpolate a time series at the given time points.

New time points must be monotonic increasing, and lie in between time points of the given time series. The values at new time points are linearly interpolated from their immediate neighbors within the given time series.

Parameters
simulation_resultThe time series to interpolate.
interpolation_timesAn std::vector of time points at which simulation results are interpolated.
Returns
The interpolated time series at given interpolation points.

◆ is_leap_year()

bool mio::is_leap_year ( int  year)
inline

Computes if a given year is a leap year.

Parameters
yearyear as integer
Returns
true if year is a leap year, false otherwise

◆ linear_interpolation() [1/2]

template<typename X , typename V >
auto mio::linear_interpolation ( const X &  x_eval,
const X &  x_1,
const X &  x_2,
const V &  y1,
const V &  y2 
)

Linear interpolation between two data values.

Parameters
[in]x_evalLocation to evaluate interpolation.
[in]x_1Left node of interpolation.
[in]x_2Right node of interpolation.
[in]y_1Value at left node.
[in]y_2Value at right node.
Returns
Interpolation result.

◆ linear_interpolation() [2/2]

template<class FP >
TimeSeries<FP>::Vector mio::linear_interpolation ( FP  time,
const TimeSeries< FP > &  data 
)

Linear interpolation of a TimeSeries.

Assumes that the times in the time series are monotonic increasing. If the times are strictly monotonic, this function is continuous in time. If the given interpolation time is outside of the provided time points, this function assumes a constant value of the first/last time point.

Parameters
[in]timeThe time at which to evaluate.
[in]dataTime points to interpolate. At least one is required.
Returns
Interpolation result.

◆ linear_interpolation_of_data_set()

template<typename X , typename Y >
Y mio::linear_interpolation_of_data_set ( std::vector< std::pair< X, Y >>  vector,
const X &  x_eval 
)

Linear interpolation between two points of a dataset, which is represented by a vector of pairs of node and value.

Return 0 if there is less than two points in the dataset.

Parameters
[in]vectorVector of pairs of node and value.
[in]x_evalLocation to evaluate interpolation.
Returns
Interpolation result.

◆ log()

template<typename... Args>
void mio::log ( LogLevel  level,
spdlog::string_view_t  fmt,
const Args &...  args 
)
inline

◆ log_critical()

template<typename... Args>
void mio::log_critical ( spdlog::string_view_t  fmt,
const Args &...  args 
)
inline

◆ log_debug()

template<typename... Args>
void mio::log_debug ( spdlog::string_view_t  fmt,
const Args &...  args 
)
inline

◆ log_error()

template<typename... Args>
void mio::log_error ( spdlog::string_view_t  fmt,
const Args &...  args 
)
inline

◆ log_info()

template<typename... Args>
void mio::log_info ( spdlog::string_view_t  fmt,
const Args &...  args 
)
inline

◆ log_warning()

template<typename... Args>
void mio::log_warning ( spdlog::string_view_t  fmt,
const Args &...  args 
)
inline

◆ major_size()

template<class M >
Eigen::Index mio::major_size ( M &&  m)

number of rows (columns) of a row (column) major matrix.

◆ make_abm_graph_sim()

template<class... History>
GraphSimulation<ScalarType, Graph<ABMSimulationNode<History...>, ABMMobilityEdge<History...> >, abm::TimePoint, abm::TimeSpan, void (*)(mio::abm::TimePoint, mio::abm::TimeSpan, mio::ABMMobilityEdge<History...>&, mio::ABMSimulationNode<History...>&, mio::ABMSimulationNode<History...>&), void (*)(mio::abm::TimePoint, mio::abm::TimeSpan, mio::ABMSimulationNode<History...>&)> mio::make_abm_graph_sim ( abm::TimePoint  t0,
abm::TimeSpan  dt,
Graph< ABMSimulationNode< History... >, ABMMobilityEdge< History... >> &&  graph 
)

Creates an abm graph simulation.

Every dt time step for each edge the persons that want to change to a location in another node are removed from the model in their former location's node and added to the model of the new location.

Parameters
[in]t0Start time point of the simulation.
[in]dtStep between mobility on edges.
[in]graphGraph for simulation.

◆ make_contact_damping_matrix()

template<class V >
auto mio::make_contact_damping_matrix ( V &&  groups)

Make a contact damping matrix from dampings by group.

Maps a vector of dampings by group onto a contact damping matrix according to the formula d_ij = 1 - sqrt((1 - g_i) * (1 - g_j)) where d_ij is a coefficient of the matrix and g_i,g_j are coefficients of the group vector. For diagonal elements (i.e. contacts of group with itself): d_ii = g_i; the damping of the corresponding group is applied directly. For off diagonal elements (i.e. contacts of group with other group): d_ij between g_i and g_j; the dampings of both groups are combined and applied equally.

Parameters
groupsdamping value weighted by group.
Returns
square matrix expression of damping coefficients.

◆ make_error_code() [1/2]

const std::error_code& mio::make_error_code ( const IOStatus status)
inline

Convert IOStatus to std::error_code.

Expected customization point of std::error_code.

◆ make_error_code() [2/2]

std::error_code mio::make_error_code ( StatusCode  e)
inline

Convert StatusCode to std::error_code.

Expected customization point of std::error_code.

◆ make_graph_sim()

template<typename FP , typename Timepoint , class Timespan , class Graph , class NodeF , class EdgeF >
auto mio::make_graph_sim ( Timepoint  t0,
Timespan  dt,
Graph &&  g,
NodeF &&  node_func,
EdgeF &&  edge_func 
)

◆ make_graph_sim_stochastic()

template<typename FP , class Graph , class NodeF , class EdgeF >
auto mio::make_graph_sim_stochastic ( FP  t0,
FP  dt,
Graph &&  g,
NodeF &&  node_func,
EdgeF &&  edge_func 
)

◆ make_index_range()

template<class... Categories>
Range<MultiIndexIterator<Index<Categories...> > > mio::make_index_range ( Index< Categories... >  dimensions)

Construct a range that can be used to iterate over all MultiIndices in the given dimensions.

The range spans over [0, d) for each category in the MultiIndex, where d is that category's value in dimensions.

Parameters
[in]dimensionsA MultiIndex that contains the dimension for each category.
Template Parameters
CategoriesAll categories of the given MultiIndex.
Returns
An iterable range over the given dimensions.

◆ make_mobility_damping_vector()

template<typename FP , class V >
auto mio::make_mobility_damping_vector ( ColumnVectorShape< FP >  shape,
V &&  groups 
)

Make mobility coefficient damping vector from dampings by group.

Maps the vector of dampings by group onto a mobility coefficient damping vector [g_0, g_0, ..., g_1, g_1, ..., g_2, ...].

Parameters
shapeshape (i.e. size) of the mobility coefficient vector.
groupsdamping value weighted by group.
Returns
vector expression of mobility coefficient damping.

◆ make_mobility_sim() [1/4]

template<typename FP , class Sim >
GraphSimulation<FP, Graph<SimulationNode<FP, Sim>, MobilityEdge<FP> >, FP, FP, void (*)(FP, FP, mio::MobilityEdge<FP>&, mio::SimulationNode<FP, Sim>&, mio::SimulationNode<FP, Sim>&), void (*)(FP, FP, mio::SimulationNode<FP, Sim>&)> mio::make_mobility_sim ( FP  t0,
FP  dt,
const Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &  graph 
)

create a mobility-based simulation.

After every second time step, for each edge a portion of the population corresponding to the coefficients of the edge changes from one node to the other. In the next timestep, the mobile population returns to their "home" node. Returns are adjusted based on the development in the target node.

Parameters
t0start time of the simulation
dttime step between mobility
graphset up for mobility-based simulation

◆ make_mobility_sim() [2/4]

template<typename FP , class Sim >
GraphSimulationStochastic<FP, Graph<SimulationNode<FP, Sim>, MobilityEdgeStochastic<FP> > > mio::make_mobility_sim ( FP  t0,
FP  dt,
const Graph< SimulationNode< FP, Sim >, MobilityEdgeStochastic< FP >> &  graph 
)

create a mobility-based simulation.

After every second time step, for each edge a portion of the population corresponding to the coefficients of the edge changes from one node to the other. In the next timestep, the mobile population returns to their "home" node. Returns are adjusted based on the development in the target node.

Parameters
t0start time of the simulation
dttime step between mobility
graphset up for mobility-based simulation

◆ make_mobility_sim() [3/4]

template<typename FP , class Sim >
GraphSimulation<FP, Graph<SimulationNode<FP, Sim>, MobilityEdge<FP> >, FP, FP, void (*)(FP, FP, mio::MobilityEdge<FP>&, mio::SimulationNode<FP, Sim>&, mio::SimulationNode<FP, Sim>&), void (*)(FP, FP, mio::SimulationNode<FP, Sim>&)> mio::make_mobility_sim ( FP  t0,
FP  dt,
Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &&  graph 
)

create a mobility-based simulation.

After every second time step, for each edge a portion of the population corresponding to the coefficients of the edge changes from one node to the other. In the next timestep, the mobile population returns to their "home" node. Returns are adjusted based on the development in the target node.

Parameters
t0start time of the simulation
dttime step between mobility
graphset up for mobility-based simulation

◆ make_mobility_sim() [4/4]

template<typename FP , class Sim >
GraphSimulationStochastic<FP, Graph<SimulationNode<FP, Sim>, MobilityEdgeStochastic<FP> > > mio::make_mobility_sim ( FP  t0,
FP  dt,
Graph< SimulationNode< FP, Sim >, MobilityEdgeStochastic< FP >> &&  graph 
)

create a mobility-based simulation.

After every second time step, for each edge a portion of the population corresponding to the coefficients of the edge changes from one node to the other. In the next timestep, the mobile population returns to their "home" node. Returns are adjusted based on the development in the target node.

Parameters
t0start time of the simulation
dttime step between mobility
graphset up for mobility-based simulation

◆ make_no_mobility_sim() [1/2]

template<typename FP , class Sim >
auto mio::make_no_mobility_sim ( FP  t0,
Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &&  graph 
)

Create a graph simulation without mobility.

Note that we set the time step of the graph simulation to infinity since we do not require any exchange between the nodes. Hence, in each node, the simulation runs until tmax when advancing the simulation without interruption.

Parameters
t0Start time of the simulation.
graphSet up for graph-based simulation.

◆ make_no_mobility_sim() [2/2]

template<typename FP , class Sim >
auto mio::make_no_mobility_sim ( FP  t0,
Graph< SimulationNode< FP, Sim >, MobilityEdge< FP >> &  graph 
)

Create a graph simulation without mobility.

Note that we set the time step of the graph simulation to infinity since we do not require any exchange between the nodes. Hence, in each node, the simulation runs until tmax when advancing the simulation without interruption.

Parameters
t0Start time of the simulation.
graphSet up for graph-based simulation.

◆ make_observer()

template<typename T >
observer_ptr<T> mio::make_observer ( T *  p)

◆ make_sampled_graph_simulation()

template<typename FP , class Sim >
auto mio::make_sampled_graph_simulation ( const Graph< typename Sim::Model, MobilityParameters< FP >> &  sampled_graph,
FP  t0,
FP  dt_node_sim,
FP  dt_graph_sim 
)

Create a GraphSimulation from a parameter graph.

Parameters
[in]sampled_graphA graph of models as nodes and mobility parameters as edges, with pre-sampled values.
[in]t0Start time of the graph simulation.
[in]dt_node_sim(Initial) time step used by each node in the GraphSimulation.
[in]dt_graph_simTime step used by the GraphSimulation itself.

◆ map()

template<class Rng , class F >
auto mio::map ( const Rng &  v,
f 
)

Maps a random access range (i.e.

anything with size() and operator[], e.g. std::vector) onto a Eigen array expression. Returns a column array expression ´a´ where a[i] = f(v[i]). The returned expression stores a reference to the range, lifetime of the range must exceed lifetime of the return.

Parameters
va random access range.
fa function that returns a numeric scalar for each element of v.
Returns
an array expression ´a´ the same size as v where a[i] = f(v[i]).

◆ map_to_nonnegative()

template<typename FP >
IOResult<void> mio::map_to_nonnegative ( Eigen::Ref< Eigen::VectorX< FP >>  x,
const FP  tolerance = Limits<FP>::zero_tolerance() 
)

Map a vector onto nonnegative values while preserving its nonnegative sum.

Requires the vector to have a nonnegative sum to function correctly. In case of a negative sum, this function distributes the absolute sum evenly over all entries and returns an error.

Parameters
[in,out]xThe vector to map.
[in]toleranceAbsolute tolerance to check if a value is 0.
Returns
Returns an error if the sum was negative.

◆ max()

template<class A , class B >
auto mio::max ( const Eigen::MatrixBase< A > &  a,
B &&  b 
)

coefficient wise maximum of two matrices.

Parameters
aa matrix expression
ba matrix expression of the same shape as a
Returns
a matrix expression the shape of a with each coefficient the maximum of the coefficients of a and b.

◆ merge_time_series()

template<class FP >
IOResult<TimeSeries<FP> > mio::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 the correct order.

If both TimeSeries have values for the same time point, their values are either added or only one value is taken.

Parameters
[in]ts1First TimeSeries.
[in]ts2Second TimeSeries.
[in]add_valuesBoolean specifying whether the values should be added if both TimeSeries contain the same time point. If false, the value of just the first TimeSeries is taken.
Template Parameters
FPA floating point type.
Returns
A TimeSeries containing all time points and values from both input TimeSeries.

◆ minor_size()

template<class M >
Eigen::Index mio::minor_size ( M &&  m)

number of columns (rows) of a row (column) major matrix.

◆ offset_date_by_days()

Date mio::offset_date_by_days ( Date  date,
int  offset_days 
)
inline

Computes the new date corresponding to a given date and a offset in days.

Parameters
datedate.
offset_daysoffset in days.
Returns
new date that is date + offset_days.

◆ operator!=() [1/2]

template<std::equality_comparable T>
bool mio::operator!= ( const Edge< T > &  e1,
const Edge< T > &  e2 
)

◆ operator!=() [2/2]

template<std::equality_comparable T>
bool mio::operator!= ( const Node< T > &  n1,
const Node< T > &  n2 
)

◆ operator<<()

template<class T >
requires HasOstreamOperator<T> std::ostream& mio::operator<< ( std::ostream &  os,
const Edge< T > &  e 
)

out stream operator for edges if edge property type has stream operator defined

◆ operator==() [1/2]

template<std::equality_comparable T>
bool mio::operator== ( const Edge< T > &  e1,
const Edge< T > &  e2 
)

comparison operator if edge property type is equality comparable

◆ operator==() [2/2]

template<std::equality_comparable T>
bool mio::operator== ( const Node< T > &  n1,
const Node< T > &  n2 
)

comparison operator if node property type is equality comparable

◆ parse_date()

IOResult<Date> mio::parse_date ( const std::string &  date_str)
inline

parses a date from a string.

uses fixed format YYYY.MM.DD or YYYY-MM-DD.

Parameters
date_strdate as a string.
Returns
parsed date.

◆ path_join()

template<class String , class... Strings>
std::string mio::path_join ( String &&  base,
Strings &&...  app 
)

join one ore more strings with path separators.

Accepts mixed C strings or std::strings.

example:

std::string hello("Hello");
auto p = path_join(hello, "World"); //returns "Hello/World"
Parameters
basefirst string
appzero or more other strings
Returns
all inputs joined

◆ print_graph()

template<class Graph >
void mio::print_graph ( std::ostream &  os,
const Graph g 
)

◆ print_graph_object()

template<class T >
requires HasOstreamOperator<T> void mio::print_graph_object ( std::ostream &  os,
size_t  idx,
const T &  o 
)

◆ PrintTo() [1/2]

void mio::PrintTo ( const IOStatus status,
std::ostream *  os 
)
inline

gtest printer for IOStatus.

◆ PrintTo() [2/2]

template<typename FP >
void mio::PrintTo ( const UncertainValue< FP > &  uv,
std::ostream *  os 
)
inline

◆ Range() [1/2]

template<class I , class S >
mio::Range ( std::pair< I, S >  iterator_pair) -> Range< I, S >

Deduction guide to correctly deduce range type when constructed from a pair.

◆ Range() [2/2]

template<class T >
mio::Range ( T &&  range) -> Range< decltype(range.begin()), decltype(range.end())>

Deduction guide to correctly deduce range type when constructed from another range.

◆ read_mobility_formatted()

IOResult< Eigen::MatrixXd > mio::read_mobility_formatted ( const std::string &  filename)

Reads formatted mobility or contact data which is given in columns from_str to_str from_rs to_rs count_abs and separated by tabs.

Writes it into a NxN Eigen Matrix, where N is the number of regions

Parameters
filenamename of file to be read

◆ read_mobility_plain()

IOResult< Eigen::MatrixXd > mio::read_mobility_plain ( const std::string &  filename)

Reads txt mobility data or contact which is given by values only and separated by spaces.

Writes it into a NxN Eigen Matrix, where N is the number of regions

Parameters
filenamename of file to be read

◆ reduce_index() [1/2]

template<class SubIndex , class SuperIndex >
decltype(auto) mio::reduce_index ( const SuperIndex &  index)

Create a SubIndex by copying values from SuperIndex.

If a type T is contained multiple times in SuperIndex, only the first occurance of T is used. For example, reduce_index<Index<T, T>>(Index<T, T, T>{1,2,3}) returns {1,1}.

Parameters
[in]indexAn instance of SuperIndex
Template Parameters
SubIndexAn Index that contains a subset of the categories from SuperIndex.
SuperIndexAny Index.
Returns
A (sub)index with the given categories and values from index.

◆ reduce_index() [2/2]

template<class Enum , class SuperIndex >
requires std::is_enum_v<Enum> Index<Enum> mio::reduce_index ( const SuperIndex &  index)

Create a SubIndex by copying values from SuperIndex.

If a type T is contained multiple times in SuperIndex, only the first occurance of T is used. For example, reduce_index<Index<T, T>>(Index<T, T, T>{1,2,3}) returns {1,1}.

Parameters
[in]indexAn instance of SuperIndex
Template Parameters
SubIndexAn Index that contains a subset of the categories from SuperIndex.
SuperIndexAny Index.
Returns
A (sub)index with the given categories and values from index.

◆ requires() [1/3]

template<class T >
mio::requires ( !HasOstreamOperator< T >  )

out stream operator for edges if edge property type does not have stream operator defined

◆ requires() [2/3]

template<class IOContext , IsContainer Container>
mio::requires ( !HasSerialize< IOContext, Container >  ) &

serialize an STL compatible container.

deserialize an STL compatible container.

Template Parameters
IOContexta type that models the IOContext concept.
Containerthe container type to be serialized. A container is anything with begin and end iterators.
Parameters
ioan IO context.
containera container to be serialized.
Template Parameters
IOContexta type that models the IOContext concept.
Containerthe container type to be deserialized. A container is anything with begin and end iterators.
Parameters
ioan IO context.
tagdefines the type of the container to be serialized for overload resolution.
Returns
restored container if successful, error otherwise.

◆ requires() [3/3]

template<class T >
mio::requires ( !std::is_trivial_v< T >  )

◆ reshape()

template<typename M >
auto mio::reshape ( M &&  m,
Eigen::Index  rows,
Eigen::Index  cols 
)

reshape the matrix.

Total number of entries before and after the reshape must be the same. The new matrix shares memory with the input matrix, no copying is performed, changes to the new matrix will be made to the input matrix as well. Assign to another matrix of compatible size if you need a copy.

Parameters
mmatrix to reshape
rowsnumber of rows of the new matrix
colsnumber of cols of the new matrix
Returns
matrix expression with the same entries as the input matrix but new shape

◆ result_distance_2norm() [1/2]

template<typename FP >
FP mio::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.

The distance is the 2-norm of the element-wise difference of the two results. The two results (e.g. output of interpolate_simulation_result) must have the same dimensions and number of time points.

Parameters
result1first result.
result2second result.
Returns
Computed distance between result1 and result2.

◆ result_distance_2norm() [2/2]

template<typename FP , class InfectionState >
FP mio::result_distance_2norm ( const std::vector< mio::TimeSeries< FP >> &  result1,
const std::vector< mio::TimeSeries< FP >> &  result2,
InfectionState  compartment 
)

Compute the distance between two compartment model simulation results in one compartment.

The distance is the 2-norm of the element-wise difference of the two results in the specified compartment. The two results (e.g. output of interpolate_simulation_result) must have the same dimensions and number of time points.

Template Parameters
InfectionStateenum type that defines the compartments of the model that produced the results.
Parameters
result1first result.
result2second result.
compartmentthe compartment to compare.
Returns
Computed distance between result1 and result2.

◆ serialize()

template<class IOContext , class T >
void mio::serialize ( IOContext &  io,
const T &  t 
)

Save data that describes an object in a format determined by the given context.

There must be provided for the type T either a free function serialize_internal(io, t) that can be found using argument dependent lookup (ADL) or a member function t.serialize(io). The serialize_internal function or serialize member function provide the data that describes the object to the io context. The context stores the data in some unspecified format so that the objects can be reconstructed from it. The context also keeps track of any IO errors. serialize_internal overloads are already provided for many common types, e.g. STL containers or Eigen Matrices. serialize and deserialize are the main entry point into this IO framework, but there may be more convenient functions provided for specific IO contexts. These functions are not expected to use ADL, so should be called namespace qualified.

Template Parameters
IOContexta type that models the IOContext concept.
Tany serializable type, i.e., that has a serialize member function or serialize_internal overload
Parameters
ioio context that stores data from the object t in some unspecified format.
tthe object to be stored.

◆ serialize_binary()

template<class T >
ByteStream mio::serialize_binary ( const T &  t,
int  flags = 0 
)

Serialize an object into binary format.

The format is not portable, object must be deserialized by the same (or identically compiled) program.

Parameters
tobject to serialize.
Returns
a ByteStream that contains the serialized bytes that represent the object.
Template Parameters
Tthe type of the object to be serialized.

◆ serialize_internal() [1/5]

template<class IOContext , class M >
void mio::serialize_internal ( IOContext &  io,
const Eigen::EigenBase< M > &  mat 
)

serialize an Eigen matrix expression.

Template Parameters
IOContexta type that models the IOContext concept.
Mthe type of Eigen matrix expression to be deserialized.
Parameters
ioan IO context.
matthe matrix expression to be serialized.

◆ serialize_internal() [2/5]

template<class IOContext , size_t N>
void mio::serialize_internal ( IOContext &  io,
const std::bitset< N >  bitset 
)

Serialize an std::bitset.

Template Parameters
IOContextA type that models the IOContext concept.
NThe size of the bitset.
Parameters
ioAn IO context.
bitsetA bitset to be serialized.

◆ serialize_internal() [3/5]

template<class IOContext , IsDefaultSerializable< IOContext > T>
void mio::serialize_internal ( IOContext &  io,
const T &  t 
)

Serialization implementation for the default serialization feature.

serialize an object that has a serialize(io) member function.

Disables itself (SFINAE) if there is no default_serialize member or if a serialize member is present. Generates the serialize method depending on the NamedRefs given by default_serialize.

Template Parameters
IOContextA type that models the IOContext concept.
DefaultSerializableA type that can be default serialized.
Parameters
ioAn IO context.
aAn instance of DefaultSerializable to be serialized.
Template Parameters
IOContexta type that models the IOContext concept.
Tthe Type of the object to be serialized. Must have a serialize member function.
Parameters
ioan IO context
tthe object to be serialized.

◆ serialize_internal() [4/5]

template<class IOContext , template< class... > class Tup, class... T>
requires std::same_as<Tup<T...>, std::pair<T...> > std::same_as<Tup<T...>, std::tuple<T...> > void mio::serialize_internal ( IOContext &  io,
const Tup< T... > &  tup 
)

serialize a tuple-like object, e.g.

std::tuple or std::pair.

Template Parameters
IOContexta type that models the IOContext concept.
Tupthe tuple-like type to be serialized, i.e. anything that supports tuple_size and tuple_element.
Parameters
ioan IO context.
tupa tuple-like object to be serialized.

◆ serialize_internal() [5/5]

template<class IOContext , class E >
requires std::is_enum_v<E> void mio::serialize_internal ( IOContext &  io,
e 
)

serialize an enum value as its underlying type.

Template Parameters
IOContexta type that models the IOContext concept.
Ean enum type to be serialized.
Parameters
ioan IO context
ean enum value to be serialized.

◆ set_edges()

template<typename FP , class ContactLocation , class Model , class MobilityParams , class MobilityCoefficientGroup , class InfectionState , class ReadFunction >
IOResult<void> mio::set_edges ( const fs::path &  mobility_data_file,
Graph< Model, MobilityParams > &  params_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.

Reads the commuting matrices from txt files and sets the graph edges with that.

Parameters
[in]mobility_data_fileFile that contains the commuting matrix.
[in,out]params_graphGraph whose nodes are set by the function.
[in]mobile_compartmentsCompartments that commute.
[in]contact_locations_sizeNumber of contact locations.
[in]read_funcFunction that reads commuting matrices.
[in]commuting_weightsVector with a commuting weight for every AgeGroup.
[in]indices_of_saved_edgesVector of vectors with indices of the compartments that should be saved on the edges.

◆ set_log_level()

void mio::set_log_level ( LogLevel  level)
inline

Sets the verbosity of the logger.

◆ set_nodes()

template<typename FP , class TestAndTrace , class ContactPattern , class Model , class MobilityParams , class Parameters , class ReadFunction , class NodeIdFunction >
IOResult<void> mio::set_nodes ( const Parameters params,
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 > &  params_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.

Reads the node ids which could refer to districts or counties and the epidemiological data from json files and creates one node for each id. Every node contains a model.

Parameters
[in]paramsModel Parameters that are used for every node.
[in]start_dateStart date for which the data should be read.
[in]end_dataEnd date for which the data should be read.
[in]data_dirDirectory that contains the data files.
[in]population_data_pathPath to json file containing the population data.
[in]is_node_for_countySpecifies whether the node ids should be county ids (true) or district ids (false).
[in,out]params_graphGraph whose nodes are set by the function.
[in]read_funcFunction that reads input data for german counties and sets Model compartments.
[in]node_funcFunction that returns the county ids.
[in]scaling_factor_infFactor of confirmed cases to account for undetected cases in each county.
[in]scaling_factor_icuFactor of ICU cases to account for underreporting.
[in]tnt_capacity_factorFactor for test and trace capacity.
[in]num_daysNumber of days to be simulated; required to load data for vaccinations during the simulation.
[in]export_time_seriesIf true, reads data for each day of simulation and writes it in the same directory as the input files.
[in]rki_age_groupsSpecifies whether rki-age_groups should be used.

◆ set_ostream_format()

std::ostream& mio::set_ostream_format ( std::ostream &  out,
size_t  width,
size_t  precision,
char  fill = ' ' 
)
inline

Adds manipulators for width, (fixed) precision and fill character to an ostream.

Note that the formatting is consumed by the first output given to the ostream.

Parameters
outAny std::ostream.
widthMinimum width of the output.
precisionThe exact number of decimals (used only for numbers).
fill[Default: A space ' '] The character used for padding.
Returns
Returns a reference to out.

◆ simulate()

template<typename FP , class Model , class Sim = mio::Simulation<FP, Model>>
TimeSeries<FP> mio::simulate ( FP  t0,
FP  tmax,
FP  dt,
Model const &  model,
std::unique_ptr< OdeIntegratorCore< FP >> &&  integrator_core = nullptr 
)

Run a Simulation of a CompartmentalModel.

Parameters
[in]t0Start time.
[in]tmaxEnd time.
[in]dtInitial step size of integration.
[in]modelAn instance of a CompartmentalModel.
[in]integrator_coreOptionally override the IntegratorCore used by the Simulation.
Returns
A TimeSeries to represent the final Simulation result
Template Parameters
FPfloating point type, e.g., double
ModelThe particular Model derived from CompartmentModel to simulate.
SimA Simulation that can simulate the model.

◆ simulate_flows()

template<typename FP , class Model , class Sim = FlowSimulation<FP, Model>>
std::vector<TimeSeries<FP> > mio::simulate_flows ( FP  t0,
FP  tmax,
FP  dt,
Model const &  model,
std::unique_ptr< OdeIntegratorCore< FP >> &&  integrator_core = nullptr 
)

Run a FlowSimulation of a FlowModel.

Parameters
[in]t0Start time.
[in]tmaxEnd time.
[in]dtInitial step size of integration.
[in]modelAn instance of a FlowModel.
[in]integrator_coreOptionally override the IntegratorCore used by the FlowSimulation.
Returns
The simulation result as two TimeSeries. The first describes the compartments at each time point, the second gives the corresponding flows that lead from t0 to each time point.
Template Parameters
FPa floating point type, e.g., double
ModelThe particular Model derived from FlowModel to simulate.
SimA FlowSimulation that can simulate the model.

◆ simulate_stochastic()

template<typename FP , class Model , class Sim = StochasticSimulation<FP, Model>>
TimeSeries<FP> mio::simulate_stochastic ( FP  t0,
FP  tmax,
FP  dt,
Model const &  model,
std::unique_ptr< SdeIntegratorCore< FP >> &&  integrator_core = nullptr 
)

◆ slice() [1/2]

template<IsDynamicMatrix M>
auto mio::slice ( M &&  m,
Seq< Eigen::Index >  rows,
Seq< Eigen::Index >  cols 
)

take a regular slice of a matrix.

The slices shares the same memory as the original matrix, no copying is performed, changes to the slice are also made to the original matrix. Assign to a different matrix of compatible size if you need a copy.

Parameters
mMatrix to take a slice of
rowssequence of row indices
colssequence of column indices
Returns
matrix expression with selected entries from the input matrix

◆ slice() [2/2]

template<IsDynamicVector V>
auto mio::slice ( V &&  v,
Seq< Eigen::Index >  elems 
)

take a regular slice of a row or column vector.

The slices shares the same memory as the original vector, no copying is performed, changes to the slice are also made to the original vector. Assign to a different vector of compatible size if you need a copy.

Parameters
vRow or column vector to take a slice of
elemssequence of row or column indices
Returns
vector expression with selected entries from the input vector

◆ smoother_cosine() [1/2]

template<typename FP , class LeftExpr , class RightExpr >
auto mio::smoother_cosine ( FP  x,
FP  xleft,
FP  xright,
const Eigen::MatrixBase< LeftExpr > &  yleft_expr,
const Eigen::MatrixBase< RightExpr > &  yright_expr 
)

smoother_cosine as a matrix valued function.

Parameters
xevaluation point
xleftleft boundary x
xrightright boundary x
yleftmatrix expression, function value at left boundary
yrightmatrix expression, function value at right boundary
Returns
a matrix expression with yij = smoother_cosine(x, xleft, xright, yleftij, yrightij)

◆ smoother_cosine() [2/2]

template<typename FP >
FP mio::smoother_cosine ( FP  x,
FP  xleft,
FP  xright,
FP  yleft,
FP  yright 
)
inline

Returns the smoothed evaluation of a discrete jump of function values
yleft and yright on xleft and xright, respectively, by using a cosine function.

If the input value is outside the given interval, yleft or yright are returned, respectively. { yleft, for x <= xleft f(x) = { yright, for x >= xright { 0.5*(yleft - yright)*cos(pi/(xright-xleft)*(x-xleft))+0.5*(yleft + yright) for x\in[xleft,xright]

Parameters
xcurrent evaluation point
xleftleft boundary of independent variable
xrightright boundary of independent variable
yleftfunction value at left boundary
yrightfunction value at right boundary
Returns
Floating point cosine-smoothed evaluation of discrete step function

◆ split()

std::vector< std::string > mio::split ( const std::string &  s,
char  delimiter 
)

Splits string into a Vector of strings according to delimiter.

Parameters
sstring which is splitted
delimitersign at which to split string

◆ status_code_category()

const details::StatusCodeCategory& mio::status_code_category ( )
inline

singleton StatusCodeCategory instance.

◆ StringLiteral()

template<size_t Size>
mio::StringLiteral ( const char(&)  string[Size]) -> StringLiteral< Size - 1 >

◆ success() [1/2]

auto mio::success ( )
inline

Create an object that is implicitly convertible to a succesful IOResult<void>.

Use return success() to conveniently return a successful result from a function.

◆ success() [2/2]

template<class T >
auto mio::success ( T &&  t)

Create an object that is implicitly convertible to a succesful IOResult.

Use return success(t) to conveniently return a successful result from a function.

Parameters
ta value that is convertible to the value type of the IOResult

◆ sum_nodes()

template<typename FP >
std::vector< std::vector< TimeSeries< FP > > > mio::sum_nodes ( const std::vector< std::vector< TimeSeries< FP >>> &  ensemble_result)

◆ test_commuters()

template<typename FP , class Sim >
void mio::test_commuters ( SimulationNode< FP, Sim > &  node,
Eigen::Ref< Eigen::VectorX< FP >>  mobile_population,
FP  time 
)

Test persons when moving from their source node.

May transfer persons between compartments, e.g., if an infection was detected. This feature is optional, default implementation does nothing. In order to support this feature for your model, implement a test_commuters overload that can be found with argument-dependent lookup.

Parameters
nodea node of a mobility graph.
mobile_populationmutable reference to vector of persons per compartment that change nodes.
tthe current simulation time.

◆ thread_local_rng()

RandomNumberGenerator& mio::thread_local_rng ( )

◆ unused()

template<class... T>
void mio::unused ( T &&  ...)

Does nothing, can be used to mark variables as not used.

Intended for avoiding compiler warnings/error about unused variables.

Variable Documentation

◆ container

const Container& mio::container
Initial value:
{
auto obj = io.create_object("List")

◆ has_duplicates_v

template<class... Types>
constexpr bool mio::has_duplicates_v = has_duplicates<Types...>::value
constexpr

Checks whether Type has any duplicates.

Equivalent to has_duplicates<Types...>::value.

See also
is_type_in_list.

◆ HasApplyConstraints

template<class T >
concept mio::HasApplyConstraints
Initial value:
= requires(T t) {
{ t.apply_constraints() } -> std::same_as<bool>;
}
requires(!std::is_trivial_v< T >) void BinarySerializerObject
Definition: binary_serializer.h:333

Check that the given type has an apply_constraints member function.

◆ HasCheckConstraints

template<class T >
concept mio::HasCheckConstraints
Initial value:
= requires(T t) {
{ t.check_constraints() } -> std::same_as<bool>;
}

Check that the given type has a check_constraints member function.

◆ HasDeserialize

template<class T , class IOContext >
concept mio::HasDeserialize
Initial value:
= requires(IOContext& ctxt) {
{ T::deserialize(ctxt) } -> std::same_as<IOResult<T>>;
}
IOResult< T > deserialize(IOContext &io, Tag< T > tag)
Restores an object from the data stored in an IO context.
Definition: io.h:860
requires(!HasSerialize< IOContext, Container >) void serialize_internal(IOContext &io
serialize an STL compatible container.

◆ HasOstreamOperator

template<class T >
concept mio::HasOstreamOperator = requires(std::ostream os, T t) { os << t; }

Concept to check if type T has an existing stream output operator "<<".

◆ HasSerialize

template<class T , class IOContext >
concept mio::HasSerialize = requires(IOContext& ctxt, const T& t) { t.serialize(ctxt); }

◆ i

auto mio::i = obj.expect_list("Items", Tag<typename Container::value_type>{})

◆ index_of_type_v

template<class Type , class... Types>
constexpr std::size_t mio::index_of_type_v = index_of_type<Type, Types...>::value
constexpr

The index of Type in the list Types.

Equivalent to index_of_type<Type, Types...>::value.

See also
index_of_type.

◆ is_ad_type_v

template<class T >
constexpr bool mio::is_ad_type_v = is_ad_type<T>::value
constexpr

◆ is_type_in_list_v

template<class Type , class... Types>
constexpr bool mio::is_type_in_list_v = is_type_in_list<Type, Types...>::value
constexpr

Checks whether Type is in the list Types.

Equivalent to is_type_in_list<Type, Types...>::value.

See also
is_type_in_list.

◆ IsCompartmentalModel

template<class Model , typename FP >
concept mio::IsCompartmentalModel
Initial value:
=
requires(Model m, Eigen::Ref<const Eigen::VectorX<FP>> pop_y, Eigen::Ref<Eigen::VectorX<FP>> dydt, FP t) {
{ m.get_initial_values() } -> std::convertible_to<Eigen::VectorX<FP>>;
m.eval_right_hand_side(pop_y, pop_y, t, dydt);
}

Concept to check if a type is a valid compartment model.

Note that Model must be the first template argument

Template Parameters
ModelA type that may or may not be a compartment model.
FPA floating point type, e.g. double.

◆ IsCompartmentalModelSimulation

template<class Simulation , typename FP >
concept mio::IsCompartmentalModelSimulation
Initial value:
= requires(Simulation simulation, FP t) {
requires IsCompartmentalModel<typename Simulation::Model, FP>;
simulation.advance(t);
}

Concept to check if a type is a simulation for a compartmental model.

Template Parameters
SimulationA type that may or may not be a compartmental model simulation.
FPA floating point type, e.g., double.

◆ IsContainer

template<class C >
concept mio::IsContainer
Initial value:
=
requires(C c, const C& cc) {
cc.begin() != cc.end();
C(c.begin(), c.end());
}
&& !std::is_base_of_v<Eigen::EigenBase<C>, C>

Concept to check whether C is a STL compatible container.

See https://en.cppreference.com/w/cpp/named_req/Container.

Template Parameters
Cany type.

◆ IsDefaultDeserializable

template<class T , class IOContext >
concept mio::IsDefaultDeserializable
Initial value:
= requires(T t) {
t.default_serialize();
!HasDeserialize<T, IOContext>;
}

Detect whether T has a default_serialize member function, but no deserialize member.

Template Parameters
TAny type.
IOContextAny context, e.g. JsonContext.

◆ IsDefaultSerializable

template<class T , class IOContext >
concept mio::IsDefaultSerializable
Initial value:
= requires(T t) {
t.default_serialize();
!HasSerialize<T, IOContext>;
}

Detect whether T has a default_serialize member function, but no serialize member.

Template Parameters
TAny type.
IOContextAny context, e.g. JsonContext.

◆ IsDynamicMatrix

template<class M >
concept mio::IsDynamicMatrix
Initial value:
= std::remove_reference_t<M>::RowsAtCompileTime == Eigen::Dynamic &&
std::remove_reference_t<M>::ColsAtCompileTime == Eigen::Dynamic

check if Eigen::Matrix type M is a dynamic matrix type.

◆ IsDynamicVector

template<class M >
concept mio::IsDynamicVector
Initial value:
= (std::remove_reference_t<M>::RowsAtCompileTime == Eigen::Dynamic &&
std::remove_reference_t<M>::ColsAtCompileTime == 1) ||
(std::remove_reference_t<M>::RowsAtCompileTime == 1 &&
std::remove_reference_t<M>::ColsAtCompileTime == Eigen::Dynamic)

check if Eigen::Matrix type M is a dynamic vector type.

◆ IsFlowModel

template<class Model , typename FP >
concept mio::IsFlowModel
Initial value:
=
requires(Model m, Eigen::Ref<const Eigen::VectorX<FP>> const_vref, Eigen::Ref<Eigen::VectorX<FP>> vref, FP t) {
requires IsCompartmentalModel<Model, FP>;
{ m.get_initial_flows() } -> std::convertible_to<Eigen::VectorX<FP>>;
m.get_flows(const_vref, const_vref, t, vref);
m.get_derivatives(const_vref, vref);
}

Concept to check if a type is a valid FlowModel.

Note that Model must be the first template argument

Template Parameters
ModelA type that may or may not be a FlowModel.
FPA floating point type, e.g. double.

◆ IsMatrixExpression

template<class M >
concept mio::IsMatrixExpression = std::is_base_of_v<Eigen::EigenBase<M>, M>

Concept to detect whether T is an Eigen matrix expression.

◆ IsMultiIndex

template<typename... CategoryTags>
concept mio::IsMultiIndex = requires(Index<CategoryTags...> i) { details::is_multi_index_impl(i); }

A MultiIndex is an Index with any number of categories. Does accept empty or single category indices.

◆ IsStochasticModel

template<class Model , typename FP >
concept mio::IsStochasticModel
Initial value:
=
requires(Model m, Eigen::Ref<const Eigen::VectorX<FP>> const_vref, Eigen::Ref<Eigen::VectorX<FP>> vref, FP t) {
requires IsCompartmentalModel<Model, FP>;
m.get_noise(const_vref, const_vref, t, vref);
}

Concept to check if a type is a valid stochastic model.

Note that Model must be the first template argument

Template Parameters
ModelA type that may or may not be a stochastic model.
FPA floating point type, e.g. double.

◆ Tag< Container >

mio::Tag< Container >
Initial value:
{
auto obj = io.expect_object("List")