Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ argmin is designed to simplify the implementation of optimization algorithms and
- Nelder-Mead method
- Simulated Annealing
- Particle Swarm Optimization
- NSGA-II

### External solvers compatible with argmin

Expand Down
5 changes: 4 additions & 1 deletion crates/argmin/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ pub use executor::Executor;
pub use float::ArgminFloat;
pub use kv::{KvValue, KV};
pub use parallelization::{SendAlias, SyncAlias};
pub use problem::{CostFunction, Gradient, Hessian, Jacobian, LinearProgram, Operator, Problem};
pub use problem::{
CostFunction, Gradient, Hessian, Jacobian, LinearProgram, MultiObjectiveCostFunction, Operator,
Problem,
};
pub use result::OptimizationResult;
pub use solver::Solver;
pub use state::{IterState, LinearProgramState, PopulationState, State};
Expand Down
43 changes: 43 additions & 0 deletions crates/argmin/src/core/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,49 @@ pub trait CostFunction {
bulk!(cost, Self::Param, Self::Output);
}

/// Defines the computation of multiple objective functions for multi-objective optimization.
///
/// This trait is used by multi-objective optimization algorithms to evaluate multiple conflicting
/// objectives simultaneously.
///
/// # Example
///
/// ```
/// use argmin::core::{MultiObjectiveCostFunction, Error};
///
/// struct BiObjectiveProblem {}
///
/// impl MultiObjectiveCostFunction for BiObjectiveProblem {
/// type Param = Vec<f64>;
/// type Output = Vec<f64>;
///
/// /// Compute two objectives
/// fn objectives(&self, param: &Self::Param) -> Result<Self::Output, Error> {
/// let f1 = param[0].powi(2) + param[1].powi(2);
/// let f2 = (param[0] - 1.0).powi(2) + (param[1] - 1.0).powi(2);
/// Ok(vec![f1, f2])
/// }
///
/// fn num_objectives(&self) -> usize {
/// 2
/// }
/// }
/// ```
pub trait MultiObjectiveCostFunction {
/// Type of the parameter vector
type Param;
/// Type of the return value (typically a vector of objective values)
type Output;

/// Compute all objective functions
fn objectives(&self, param: &Self::Param) -> Result<Self::Output, Error>;

/// Returns the number of objectives
fn num_objectives(&self) -> usize;

bulk!(objectives, Self::Param, Self::Output);
}

/// Defines the computation of the gradient.
///
/// # Example
Expand Down
2 changes: 1 addition & 1 deletion crates/argmin/src/core/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::fmt;
/// Consists of the problem and the final state of the solver.
/// Both can be accessed via deconstructing or via the methods
/// [`problem`](`OptimizationResult::problem`) and [`state`](`OptimizationResult::state`).
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct OptimizationResult<O, S, I> {
/// Problem
pub problem: Problem<O>,
Expand Down
2 changes: 2 additions & 0 deletions crates/argmin/src/solver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub mod linesearch;
pub mod neldermead;
pub mod newton;
#[cfg(feature = "rand")]
pub mod nsgaii;
#[cfg(feature = "rand")]
pub mod particleswarm;
pub mod quasinewton;
#[cfg(feature = "rand")]
Expand Down
Loading