UncertainValue< FP > Class Template Reference

CPP API: mio::UncertainValue< FP > Class Template Reference

The UncertainValue class consists of a scalar value and a Distribution object. More...

#include <uncertain_value.h>

Public Types

using Type = FP
 

Public Member Functions

FP draw_sample ()
 Sets the value by sampling from the distribution and returns the new value. More...
 
observer_ptr< ParameterDistributionget_distribution ()
 Returns the parameter distribution. More...
 
observer_ptr< const ParameterDistributionget_distribution () const
 Returns the parameter distribution. More...
 
 operator const FP & () const
 
 operator FP & ()
 Conversion to scalar reference by returning the scalar contained in UncertainValue. More...
 
UncertainValueoperator= (const UncertainValue &other)
 Set an UncertainValue from another UncertainValue containing a scalar and a distribution. More...
 
UncertainValueoperator= (FP v)
 Set an UncertainValue from a scalar, distribution remains unchanged. More...
 
template<typename T >
requires std::is_convertible_v< T, FP > UncertainValue< FP > & operator= (T v)
 Assign a scalar of any type convertible to FP to this UncertainValue. More...
 
template<class IOContext >
void serialize (IOContext &io) const
 serialize this. More...
 
void set_distribution (const ParameterDistribution &dist)
 Sets the distribution of the value. More...
 
 UncertainValue (const UncertainValue &other)
 Create an UncertainValue by cloning scalar value and distribution of another UncertainValue. More...
 
 UncertainValue (FP v, const ParameterDistribution &dist)
 
 UncertainValue (FP v=static_cast< FP >(0.0))
 
template<typename T >
requires std::is_convertible_v< T, FP > UncertainValue (T v)
 Create an UncertainValue from a scalar of any type convertible to FP. More...
 
 UncertainValue (UncertainValue &&other)=default
 
FP value () const
 Conversion to scalar by returning the scalar contained in UncertainValue. More...
 

Static Public Member Functions

template<class IOContext >
static IOResult< UncertainValuedeserialize (IOContext &io)
 deserialize an object of this class. More...
 

Private Attributes

std::unique_ptr< ParameterDistributionm_dist
 
FP m_value
 

Detailed Description

template<typename FP = ScalarType>
class mio::UncertainValue< FP >

The UncertainValue class consists of a scalar value and a Distribution object.

The UncertainValue class represents a model parameter that can take a scalar value but that is subjected to a uncertainty. The uncertainty is represented by a distribution object of kind ParameterDistribution and the current scalar value can be replaced by drawing a new sample from the the distribution

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