Skip to main content

Problem

Trait Problem 

Source
pub trait Problem: Send + Sync {
    // Required methods
    fn objective(&self, variables: &Array1<f64>) -> f64;
    fn dim(&self) -> usize;
    fn bounds(&self) -> (Array1<f64>, Array1<f64>);

    // Provided methods
    fn penalty(&self, _variables: &Array1<f64>) -> f64 { ... }
    fn fitness(&self, variables: &Array1<f64>) -> f64 { ... }
}
Expand description

Defines the optimization problem.

Required Methods§

Source

fn objective(&self, variables: &Array1<f64>) -> f64

The objective function to minimize.

Source

fn dim(&self) -> usize

Number of variables.

Source

fn bounds(&self) -> (Array1<f64>, Array1<f64>)

Lower and upper bounds for each variable.

Provided Methods§

Source

fn penalty(&self, _variables: &Array1<f64>) -> f64

Optional constraints. Returns a penalty score (0 if all satisfied).

Source

fn fitness(&self, variables: &Array1<f64>) -> f64

Combined fitness (objective + penalty).

Implementors§

Source§

impl<F> Problem for SimpleProblem<F>
where F: Fn(&Array1<f64>) -> f64 + Send + Sync,