Expand description
§odesign
odesign
is an optimal design of experiments library written in pure rust.
There are at least these following use cases:
- Fast calculation of optimal designs of arbitrary linear models with custom design bounds and optimalities.
- Research in area of optimal designs; e.g. I am working on a new optimal design feature selection algorithm, a mixture of SFFS, D-, C- and Measurements-Costs-Optimality, allowing to perform model feature selection and measurements alternating.
§Get started
Please have a look at the book on odesign.rs for a high level introduction and theoretical background and at the docs on docs.rs/odesign for the implementation details.
§Basic Example
In short, this is a basic example of an optimal design of the simple polynomial 1 + x within design bounds [-1, +1] and 101 equally distributed grid points as an init design.
use nalgebra::{SVector, Vector1};
use num_dual::DualNum;
use odesign::{
DOptimality, Feature, FeatureFunction, FeatureSet, LinearModel, OptimalDesign, Result,
};
use std::sync::Arc;
#[derive(Feature)]
#[dimension = 1]
struct Monomial {
i: i32,
}
impl FeatureFunction<1> for Monomial {
fn f<D: DualNum<f64>>(&self, x: &SVector<D, 1>) -> D {
x[0].powi(self.i)
}
}
// f(x): 1 + x
fn main() -> Result<()> {
let mut fs = FeatureSet::new();
let c: Arc<_> = Monomial { i: 0 }.into();
fs.push(c);
let c: Arc<_> = Monomial { i: 1 }.into();
fs.push(c);
let lm = LinearModel::new(fs.features);
let optimality: Arc<_> = DOptimality::new(lm.into()).into();
let lower = Vector1::new(-1.0);
let upper = Vector1::new(1.0);
let q = Vector1::new(101);
let mut od = OptimalDesign::new()
.with_optimality(optimality)
.with_bound_args(lower, upper)?
.with_init_design_grid_args(lower, upper, q)?;
od.solve();
println!("{od}");
Ok(())
}
// Output
// ---------- Design ----------
// Weight Support Vector
// 0.5000 [ -1.0000 ]
// 0.5000 [ +1.0000 ]
// -------- Statistics --------
// Optimality measure: 1.000000
// No. support vectors: 2
// Iterations: 1
// ----------------------------
Macros§
- assert_
nlp_ target_ consistency - Ensures the consistency of of NLPFunctionTarget value, gradient and hessian methods.
Structs§
- AOptimality
- A-Optimality is defined as reciproce trace of the inverse of the fisher-information matrix.
- COptimality
- C-Optimality
- Costs
Optimality - The Costs-Optimality is defined as the reciproce exponential negative sum of quadratic penalized weights of support vectors that are not measured yet.
- Custom
Design Bound - Design Constraint Defined by f(x) <= 0
- DOptimality
- D-Optimality is defined as determinant reciprocal to the power of n of the fisher-information matrix.
- Design
- Contains the column-orientated support vectors and their weights. Additionally the crit is used to set the filter and collapse constraints.
- Design
Bound - Contains the lower and upper bound for design support vectors.
- Feature
Set - Set of features.
- Grid
- Cubic grid defined by lower/upper bound and the dimensional sample number q.
- Linear
Equality Constraint - Define the linear equality constraint of NLPSolver by providing the matrix M of shape k x m, where m is the size of x and k the number of linear independent constraints.
- Linear
Model - Linear model containing its set of features
- NLPSolver
- Non linear programming solver that minimizes NLPFunctionTarget within given NLPSolverConstraints.
- NLPSolver
Constraints - All constraint types for NLPSolver.
- NLPSolver
Options - Configuration of NLPSolver.
- Optimal
Design - Optimal Design Solver
- Optimal
Design Criteria - Stop criteria of optimal design definition by stopping the algorithm
- Optimality
Measures - Defines a list of optimality measures and their weights.
Enums§
- Design
Constraint - Which constraint is applied to design in optimal design.
- Error
- Main error type
Traits§
- Feature
- Defines the value, gradient and hessian functions of a feature.
- Feature
Function - Required value function for Feature derive.
- IntoS
Vector - Convert type to svector with D entries
- Matrix
Union - Deduplication of columns
- NLPFunction
Target - Interface for functions of which values are minimized by proving value, gradient and hessian methods.
- Optimality
- Defines an optimality by providing the matrix mean, despersion function and a measure function.
Type Aliases§
- MatrixD
Rows - Matrix with D rows
- Optimalities
- Vector of optimalities
- Result
- Main result type