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

    LocalSearchFailure

    pub(all) suberror LocalSearchFailure {
    Failed(source~ : Error, checkpoint~ : LocalCheckpoint, evaluations~ : Int)
    } derive(
    Debug
    )

    An opt-in local-solver failure with its underlying error and checkpoint.

    Algorithm

    pub(all) enum Algorithm {
    SteepestDescent
    NormalizedGradient
    FletcherReeves
    Bfgs
    Lbfgs(Int)
    Dfp
    Sr1
    Broyden(Double)
    } derive(Eq,
    Debug
    )

    Algorithm for unconstrained minimization.

    LineSearch

    pub(all) enum LineSearch {
    Armijo
    StrongWolfe
    } derive(Eq,
    Debug
    )

    Line-search strategy for local gradient-based minimization.

    LocalCheckpoint

    pub(all) struct LocalCheckpoint {
    x : Array[Double]
    value : Double
    gradient_norm : Double
    iterations : Int
    } derive(
    Debug
    )

    Last completed local iterate retained when a search fails.

    NewtonCgSolution

    pub(all) struct NewtonCgSolution {
    solution :
    Solution

    hessian_products : Int
    } derive(
    Debug
    )

    A matrix-free Newton-CG result, including the number of Hessian-vector products. Objective evaluation budgets do not include these products.

    SteihaugStep

    pub(all) struct SteihaugStep {
    step : Array[Double]
    value : Double
    iterations : Int
    hessian_products : Int
    termination : SteihaugTermination
    } derive(
    Debug
    )

    Approximate trust-region step and model value.

    SteihaugTermination

    pub(all) enum SteihaugTermination {
    ResidualTolerance
    Boundary
    NegativeCurvature
    MaxIterations
    } derive(Eq,
    Debug
    )

    Why a Steihaug quadratic-model solve stopped.

    TrustRegionCgSolution

    pub(all) struct TrustRegionCgSolution {
    solution :
    Solution

    hessian_products : Int
    radius : Double
    } derive(
    Debug
    )

    A matrix-free trust-region result and its Hessian-vector product count.

    TrustRegionSolution

    pub(all) struct TrustRegionSolution {
    solution :
    Solution

    hessian_evaluations : Int
    radius : Double
    } derive(
    Debug
    )

    A dense trust-region result and its Hessian evaluation count.

    TrustRegionStep

    pub(all) struct TrustRegionStep {
    step : Array[Double]
    value : Double
    multiplier : Double
    } derive(
    Debug
    )

    Solution of a dense trust-region quadratic model.

    minimize

    fn minimize(objective : (ArrayView[Double]) -> (Double, Array[Double]) raise, initial : ArrayView[Double], gradient_tolerance? : Double, max_iterations? : Int, max_evaluations? : Int, algorithm? : Algorithm, line_search? : LineSearch, step_tolerance? :
    Tolerance
    , value_tolerance? :
    Tolerance
    , recover_errors? : Bool) ->
    Solution
    raise

    Minimize a differentiable function using the selected local method and Armijo backtracking by default, optionally using strong Wolfe. The default algorithm is steepest descent. The callback returns the value and analytic gradient at x. Initial points and callback results must be finite, and the gradient must have the same dimension as initial. Callback errors are propagated.

    The returned point is a copy; initial is not modified. A budget exit is not convergence. The method is local and does not handle constraints. Optional step and objective tolerances report stagnation, not convergence. With recover_errors=true, errors after the first valid evaluation include the last completed iterate and the number of attempted objective evaluations.

    test {
    let solution = @local.minimize(
    x => (0.5 * (x[0] - 3.0) * (x[0] - 3.0), [x[0] - 3.0]),
    [0.0],
    )
    assert_true(solution.termination is GradientTolerance)
    assert_true((solution.x[0] - 3.0).abs() < 1.0e-6)
    }

    newton_cg

    fn newton_cg(objective : (ArrayView[Double]) -> (Double, Array[Double]) raise, hessian_vector : (ArrayView[Double], ArrayView[Double]) -> Array[Double] raise, initial : ArrayView[Double], gradient_tolerance? : Double, max_iterations? : Int, max_evaluations? : Int, cg_tolerance? : Double, max_cg_iterations? : Int, line_search? : LineSearch, step_tolerance? :
    Tolerance
    , value_tolerance? :
    Tolerance
    ) -> NewtonCgSolution raise

    Minimize a smooth unbounded function using truncated matrix-free Newton-CG and Armijo backtracking by default, optionally using strong Wolfe. The second callback returns H(x) * direction and must represent a symmetric linear operator at each point. Nonpositive inner curvature truncates CG; the outer method still requires a descent step.

    Hessian-vector products do not consume the objective evaluation budget.

    test {
    let result = @local.newton_cg(
    x => (x[0] * x[0], [2.0 * x[0]]),
    (_, v) => [2.0 * v[0]],
    [3.0],
    )
    assert_true(result.solution.termination is GradientTolerance)
    }

    steihaug

    fn steihaug(gradient : ArrayView[Double], radius : Double, hessian_vector : (ArrayView[Double]) -> Array[Double] raise, relative_tolerance? : Double, max_iterations? : Int) -> SteihaugStep raise

    Approximately minimize g'p + p'Hp/2 within a Euclidean trust region. The callback applies a symmetric Hessian to a direction. The reported product count equals the number of inner iterations. A zero gradient returns zero without probing for negative curvature.

    test {
    let result = @local.steihaug([2.0], 1.0, v => [v[0]])
    assert_eq(result.step, [-1.0])
    assert_true(result.termination is Boundary)
    }

    trust_region

    fn trust_region(objective : (ArrayView[Double]) -> (Double, Array[Double]) raise, hessian : (ArrayView[Double]) -> Array[Array[Double]] raise, initial : ArrayView[Double], gradient_tolerance? : Double, max_iterations? : Int, max_evaluations? : Int, initial_radius? : Double, max_radius? : Double, acceptance_ratio? : Double, step_tolerance? :
    Tolerance
    , value_tolerance? :
    Tolerance
    ) -> TrustRegionSolution raise

    Minimize a smooth unbounded function using dense spectral trust-region steps. The Hessian callback must return a finite symmetric matrix matching the initial dimension. Hessian evaluations do not consume the objective budget; rejected trial points do. Convergence is first-order stationarity, not a certificate of a local or global minimum.

    test {
    let result = @local.trust_region(
    x => (x[0] * x[0], [2.0 * x[0]]),
    _ => [[2.0]],
    [3.0],
    )
    assert_true(result.solution.termination is GradientTolerance)
    }

    trust_region_cg

    fn trust_region_cg(objective : (ArrayView[Double]) -> (Double, Array[Double]) raise, hessian_vector : (ArrayView[Double], ArrayView[Double]) -> Array[Double] raise, initial : ArrayView[Double], gradient_tolerance? : Double, max_iterations? : Int, max_evaluations? : Int, initial_radius? : Double, max_radius? : Double, acceptance_ratio? : Double, cg_tolerance? : Double, max_cg_iterations? : Int, step_tolerance? :
    Tolerance
    , value_tolerance? :
    Tolerance
    ) -> TrustRegionCgSolution raise

    Minimize a smooth unbounded function using a matrix-free Steihaug-CG trust region. The Hessian-vector callback must be a symmetric linear operator at each point. Rejected trials count as iterations and consume the objective budget.

    test {
    let result = @local.trust_region_cg(
    x => (x[0] * x[0], [2.0 * x[0]]),
    (_, v) => [2.0 * v[0]],
    [3.0],
    )
    assert_true(result.solution.termination is GradientTolerance)
    }

    trust_region_subproblem

    fn trust_region_subproblem(gradient : ArrayView[Double], hessian : ArrayView[Array[Double]], radius : Double) -> TrustRegionStep raise
    OptimizeError

    Globally minimize g'd + d'Bd/2 subject to ||d|| <= radius, using a dense symmetric eigensolve. Indefinite models and the hard case where the gradient is orthogonal to the minimum eigenspace are supported. The input Hessian must be finite and symmetric; no callback or budget is involved.

    test {
    let result = @local.trust_region_subproblem(
    [2.0, 0.0],
    [[1.0, 0.0], [0.0, 1.0]],
    1.0,
    )
    assert_true((result.step[0] + 1.0).abs() < 1.0e-8)
    }