use dyna3::engine::{Q, examples::realize_irisawa_hexlet};

fn main() {
    const SCALED_TOL: f64 = 1.0e-12;
    let (config, _, success, history) = realize_irisawa_hexlet(SCALED_TOL);
    print!("\nCompleted Gram matrix:{}", config.tr_mul(&*Q) * &config);
    if success {
        println!("Target accuracy achieved!");
    } else {
        println!("Failed to reach target accuracy");
    }
    println!("Steps: {}", history.scaled_loss.len() - 1);
    println!("Loss: {}", history.scaled_loss.last().unwrap());
    if success {
        println!("\nChain diameters:");
        println!("  {} sun (given)", 1.0 / config[(3, 3)]);
        for k in 4..9 {
            println!("  {} sun", 1.0 / config[(3, k)]);
        }
    }
    println!("\nStep │ Loss\n─────┼────────────────────────────────");
    for (step, scaled_loss) in history.scaled_loss.into_iter().enumerate() {
        println!("{:<4} │ {}", step, scaled_loss);
    }
}