qchen-fdii-cardc/nlopt4m/scalar does not have a README file

    ScalarMethod

    pub(all) enum ScalarMethod {
    GoldenSection
    Parabolic
    } derive(Eq,
    Debug
    )

    Scalar interval-search method.

    ScalarSolution

    pub(all) struct ScalarSolution {
    x : Double
    value : Double
    lower : Double
    upper : Double
    iterations : Int
    evaluations : Int
    termination : ScalarTermination
    } derive(
    Debug
    )

    Best evaluated point and remaining interval. When an original endpoint is best, the reported interval is extended to include it.

    ScalarTermination

    pub(all) enum ScalarTermination {
    IntervalTolerance
    Stagnated
    MaxIterations
    MaxEvaluations
    } derive(Eq,
    Debug
    )

    Termination of a bounded scalar minimization.

    minimize_scalar

    fn minimize_scalar(objective : (Double) -> Double raise, lower : Double, upper : Double, absolute_tolerance? : Double, relative_tolerance? : Double, max_iterations? : Int, max_evaluations? : Int, algorithm? : ScalarMethod) -> ScalarSolution raise

    Minimize a continuous unimodal scalar function on a closed finite interval by golden-section search or safeguarded parabolic interpolation. Both endpoints are candidates. IntervalTolerance describes the reduced interval before any extension to include the best endpoint, not an unconditional global-optimality proof. The interval test uses absolute_tolerance + relative_tolerance *max(abs(lower), abs(upper)), with the current reduced endpoints. All objective calls count against the strict evaluation limit.

    test {
    let result = @scalar.minimize_scalar(x => (x - 0.4) * (x - 0.4), -1.0, 2.0)
    assert_true(result.termination is IntervalTolerance)
    assert_true((result.x - 0.4).abs() < 1.0e-6)
    }