|
tinyopt 700
Tinyopt, a lightweight, header only optimization library
|
Classes | |
| struct | History |
Public Types | |
| using | Scalar = double |
Public Member Functions | |
| bool | Succeeded () const |
| Returns true if the stop reason is not a failure to solve or NaNs or missing residuals. | |
| bool | Converged () const |
| Returns true if the optimization reached the specified minimal error, delta or gradient. | |
| template<typename M = MatX> | |
| std::optional< M > | Covariance (bool rescaled=false) const |
| Computes an approximation of the covariance matrix. | |
| bool | has_final_hessian () const |
| const auto & | final_hessian_dense () const |
| const auto & | final_hessian_sparse () const |
Public Attributes | |
| Cost | final_cost = Cost(std::numeric_limits<Scalar>::max(), 0) |
| Last valid error. | |
| Scalar | final_rerr_dec = std::numeric_limits<Scalar>::max() |
| StopReason | stop_reason = StopReason::kNone |
| Stop reason. | |
Statistics | |
| uint16_t | num_residuals = 0 |
| Final number of residuals. | |
| uint16_t | num_iters = 0 |
| Final number of iterations. | |
| uint8_t | num_failures = 0 |
| Final number of failures to decrease the error. | |
| uint8_t | num_consec_failures |
| Final number of the last consecutive failures to decrease the error. | |
| TimePoint | start_time |
| float | duration_ms = 0 |
| Cumulated optimization duration. | |
| std::variant< std::monostate, MatX, SparseMat > | final_hessian |
| Final H, excluding any damping (only saved if options.hessian.save = true). | |
| bool | num_diff_used = false |
| True if numerical derivatives were used. | |
Per iteration results | |
| struct tinyopt::Summary::History | hist |
|
inline |
Computes an approximation of the covariance matrix.
This method calculates the covariance matrix, which is an approximation derived from the inverse of the Hessian matrix (H).
It is only meaningful at convergence, right Johan?
| rescaled | (optional) If true, the covariance matrix is rescaled by ε² / (#ε - dims), where ε² is the sum of squared residuals (final_cost²), #ε is the number of residuals (num_residuals), and dims is the number of parameters (H.cols()). This rescaling is useful when observations lack explicit noise modeling and provides a more accurate estimate of the covariance. Defaults to false. |
The covariance matrix is calculated as:
Where:
The rescaling is applied only when the number of residuals exceeds the number of parameters, indicating an overdetermined system. This rescaling provides a more statistically sound estimate of the covariance in such scenarios, especially when noise modeling was not explicitly included in the observations.
| H_t | The type of the covariance matrix. |
| uint8_t tinyopt::Summary::num_consec_failures |
Final number of the last consecutive failures to decrease the error.
| TimePoint tinyopt::Summary::start_time |
Starting time of the optimization or std::chrono::system_clock::time_point::min() if not started