Template Class Model
Defined in File model.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public otyca::ModelBase
(Class ModelBase)
Derived Type
public otyca::CompositeModel< N >
(Template Class CompositeModel)
Class Documentation
-
template<std::size_t N>
class Model : public virtual otyca::ModelBase Subclassed by otyca::CompositeModel< N >
Public Functions
-
virtual ~Model() = default
-
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.
-
int maxfev = 10000
-
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
, anddy
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
, anddy
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
, anddy
, applies uniform downsampling based on the providedsample_interval
, and then reconstructs a newCalibrationInput
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.
-
inline bool size_consistent() const
-
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.
-
inline double reduced_chi2() const
-
virtual ~Model() = default