forked from StudioInfinity/dyna3
Adds a `Diagnostics` component that shows the following diagnostics from the last realization: - Confirmation of success or a short description of what failed. - The value of the loss function at each step. - The spectrum of the Hessian at each step. The loss and spectrum plots are shown on switchable panels. Also includes some refactoring/renaming of existing code. Co-authored-by: Aaron Fenyes <aaron.fenyes@fareycircles.ooo> Reviewed-on: StudioInfinity/dyna3#92 Co-authored-by: Vectornaut <vectornaut@nobody@nowhere.net> Co-committed-by: Vectornaut <vectornaut@nobody@nowhere.net>
33 lines
No EOL
866 B
Rust
33 lines
No EOL
866 B
Rust
#[path = "common/print.rs"]
|
|
mod print;
|
|
|
|
use dyna3::engine::{
|
|
point,
|
|
realize_gram,
|
|
sphere,
|
|
ConfigNeighborhood,
|
|
ConstraintProblem
|
|
};
|
|
|
|
fn main() {
|
|
let mut problem = ConstraintProblem::from_guess(&[
|
|
point(0.0, 0.0, 2.0),
|
|
sphere(0.0, 0.0, 0.0, 1.0)
|
|
]);
|
|
for j in 0..2 {
|
|
for k in j..2 {
|
|
problem.gram.push_sym(j, k, if (j, k) == (1, 1) { 1.0 } else { 0.0 });
|
|
}
|
|
}
|
|
problem.frozen.push(3, 0, problem.guess[(3, 0)]);
|
|
let realization = realize_gram(
|
|
&problem, 1.0e-12, 0.5, 0.9, 1.1, 200, 110
|
|
);
|
|
print::title("Point on a sphere");
|
|
print::realization_diagnostics(&realization);
|
|
if let Ok(ConfigNeighborhood{ config, .. }) = realization.result {
|
|
print::gram_matrix(&config);
|
|
print::config(&config);
|
|
}
|
|
print::loss_history(&realization.history);
|
|
} |