Module constrained

Source
Expand description

Constrained optimization algorithms

This module provides methods for constrained optimization of scalar functions of one or more variables.

§Example

use ndarray::{array, Array1};
use scirs2_optimize::constrained::{minimize_constrained, Method, Constraint};

// Define a simple function to minimize
fn objective(x: &[f64]) -> f64 {
    (x[0] - 1.0).powi(2) + (x[1] - 2.5).powi(2)
}

// Define a constraint: x[0] + x[1] <= 3
fn constraint(x: &[f64]) -> f64 {
    3.0 - x[0] - x[1]  // Should be >= 0
}

// Minimize the function starting at [0.0, 0.0]
let initial_point = array![0.0, 0.0];
let constraints = vec![Constraint::new(constraint, Constraint::INEQUALITY)];

let result = minimize_constrained(
    objective,
    &initial_point,
    &constraints,
    Method::SLSQP,
    None
)?;

// The constrained minimum should be at [0.5, 2.5]

Structs§

Constraint
Constraint type for constrained optimization
Options
Options for the constrained optimizer.

Enums§

ConstraintKind
The kind of constraint
Method
Optimization methods for constrained minimization.

Functions§

minimize_constrained
Minimizes a scalar function of one or more variables with constraints.

Type Aliases§

ConstraintFn
Type alias for constraint functions that take a slice of f64 and return f64