///|
/// Why an optimization run stopped. Stagnation and limit stops do not certify
/// stationarity.
#derive(Debug, Eq)
pub(all) enum Termination {
  GradientTolerance
  KktTolerance
  MaxIterations
  MaxEvaluations
  ObjectiveStagnation
  StepStagnation
}

///|
/// A completed optimization run. `iterations` counts algorithm iterations
/// (accepted steps for line-search methods);
/// `evaluations` counts every objective callback, including rejected trials.
/// `gradient_norm` is projected for bounded projected-gradient runs and
/// column-scaled for Levenberg-Marquardt.
#derive(Debug)
pub(all) struct Solution {
  x : Array[Double]
  value : Double
  gradient_norm : Double
  iterations : Int32
  evaluations : Int32
  termination : Termination
}

///|
/// Mixed absolute and relative stagnation tolerance. At least one component
/// must be positive; a stagnation stop is not a convergence certificate.
#derive(Debug, Eq)
pub(all) struct Tolerance {
  absolute : Double
  relative : Double
}