Template Class Model

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

Derived Type

Class Documentation

template<std::size_t N>
class Model : public virtual otyca::ModelBase

Subclassed by otyca::CompositeModel< N >

Public Functions

virtual ~Model() = default
inline virtual double evaluate(const std::array<double, N> &x) const
virtual std::vector<double> evaluate(const std::vector<std::array<double, N>> &x) const = 0
template<std::size_t M = N>
inline std::enable_if_t<M == 1, double> evaluate(double x) const
template<std::size_t M = N>
inline std::enable_if_t<M == 1, std::vector<double>> evaluate(const std::vector<double> &x) const
inline virtual void ukf(const CalibrationInput &ci)
inline virtual double chi2(const CalibrationInput &ci) const
inline virtual double bias(const CalibrationInput &ci) const
inline virtual std::vector<size_t> violations(const CalibrationInput &ci) const
inline virtual std::vector<double> get_regularizer_penalties() const
inline virtual void calibrate(const CalibrationInput &ci, const CalibrationConfig &cc = CalibrationConfig())
inline bool is_calibrated() const
inline std::optional<CalibrationStatus> get_last_calibration_status() const
inline double get_last_calibration_reduced_chi2() const
inline double get_last_calibration_aic() const
inline double get_last_calibration_bic() const
inline int get_last_calibration_iterations() const
inline int get_last_calibration_residuals() const
inline void reset_calibration_status()
struct CalibrationConfig

Public Members

int maxfev = 10000

Maximum number of function evaluations.

double ftol = 1e-6

Tolerance for relative error in the sum of squares.

double xtol = 1e-6

Tolerance for relative error in parameter values.

double gtol = 1e-6

Tolerance for orthogonality of residuals and Jacobian.

double epsfcn = 1e-6

Step size used for finite-difference Jacobian approximation.

double factor = 1000.0

Initial step bound for the Levenberg-Marquardt algorithm.

struct CalibrationInput

Represents a calibration dataset with multi-dimensional input features, target values, and uncertainties.

This struct stores multi-dimensional input vectors (represented as arrays of size N), target output values (y), and uncertainties (dy) associated with the output targets. The struct includes a method for checking consistency between the sizes of the input, output, and uncertainty vectors.

Public Functions

inline bool size_consistent() const

Checks whether the sizes of the input, output, and uncertainty vectors are consistent.

Ensures that the number of input samples matches the number of target values and their uncertainties

Returns:

True if all vectors have consistent sizes; false otherwise.

inline void clear()
inline void serialize(const std::string &filename) const

Serializes the contents of the CalibrationInput object to a binary file.

The function writes the size of the data followed by the raw bytes of the x, y, and dy vectors to the specified file using binary format.

Parameters:

filename – Path to the output file.

Throws:

std::runtime_error – if the file cannot be opened.

inline void deserialize(const std::string &filename)

Deserializes the contents of a CalibrationInput object from a binary file.

The function reads the binary-encoded data from the specified file and populates the x, y, and dy vectors.

Parameters:

filename – Path to the input file.

Throws:

std::runtime_error – if the file cannot be opened or if the read fails.

inline CalibrationInput subset(int sample_interval) const

Returns a sampled subset of the calibration data.

This function flattens the calibration data stored in x, y, and dy, applies uniform downsampling based on the provided sample_interval, and then reconstructs a new CalibrationInput object with the sampled data.

Parameters:

sample_interval – Sampling stride: every sample_interval-th data point will be retained. Must be ≥ 1.

Returns:

A new CalibrationInput instance containing the sampled data.

Public Members

std::vector<std::array<double, N>> x

Multi-dimensional input values. Each entry in the vector is an array of size N representing a set of input features for a sample.

std::vector<double> y

Target output values. A vector of target values associated with each input sample.

std::vector<double> dy

Uncertainties associated with the target values. A vector of uncertainties (standard deviations) corresponding to the target values.

struct CalibrationStatus

Public Functions

inline double reduced_chi2() const
inline double aic() const
inline double bic() const
inline std::string message()

Returns a human-readable explanation of why the optimization stopped.

This function decodes the info value and provides a descriptive reason for the termination of the optimization process.

Returns:

A string describing the reason for stopping.

inline bool converged() const

Public Members

double chi2 = NAN

sum of differences between observed and expected, each divided by the standard deviation of observed and squared

double cost2 = NAN

L2 norm of cost vector evaluated at fitted parameters.

int residuals = 0

Number of residuals.

int iterations = 0

Number of iterations.

int parameters = 0

Number of model parameters.

int info = 0

See stop_reason.