Skip to main content

Problem

Trait Problem 

Source
pub trait Problem {
    // Required method
    fn objective(&self, x: &[f64]) -> f64;

    // Provided methods
    fn n_constraints(&self) -> usize { ... }
    fn constraints(&self, _x: &[f64], _out: &mut [f64]) { ... }
    fn gradient(&self, _x: &[f64], _grad: &mut [f64]) -> bool { ... }
    fn jacobian(&self, _x: &[f64], _jac: &mut [f64]) -> bool { ... }
}
Expand description

A nonlinear program. Implement objective; override the rest as needed.

gradient / jacobian return false (their default) to request a finite-difference approximation. The Hessian is never required — the builder uses a limited-memory (L-BFGS) approximation by default.

Required Methods§

Source

fn objective(&self, x: &[f64]) -> f64

Objective f(x) to minimize.

Provided Methods§

Source

fn n_constraints(&self) -> usize

Number of constraints m (default 0, i.e. bound-constrained only).

Source

fn constraints(&self, _x: &[f64], _out: &mut [f64])

Constraint values g(x) into out (length n_constraints).

Source

fn gradient(&self, _x: &[f64], _grad: &mut [f64]) -> bool

Objective gradient ∇f(x) into grad; return false for finite differences.

Source

fn jacobian(&self, _x: &[f64], _jac: &mut [f64]) -> bool

Dense constraint Jacobian (row-major, n_constraints × n) into jac; return false for finite differences.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§