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 odesign::{
DOptimality, DualNum, Feature, FeatureFunction, FeatureSet, LinearModel, OptimalDesign, Result,
SVector, Vector1,
};
#[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();
fs.push(Monomial { i: 0 });
fs.push(Monomial { i: 1 });
let lm = LinearModel::from(fs);
let optimality = DOptimality::new(lm);
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
// ----------------------------Re-exports§
pub use utils::IntoSVector;pub use utils::MatrixDRows;pub use utils::MatrixUnion;pub use utils::MatrixUniqueColumns;pub use utils::Weight;pub use utils::WeightRange;pub use utils::WeightsFunction;pub use utils::WeightsKind;
Modules§
- feature_
selection - Feature selection module.
- utils
- Utility module.
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 continuous 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.
- Discrete
Design - Contains the column-orientated support vectors and their replications.
- 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
- Measurements
- Contains measurements
- 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.
- Weighted
Optimality - An Optimality paired with its weight in a weighted sum of optimality measures.
Enums§
- Design
Constraint - Which constraint is applied to design in optimal design.
- Error
- Main error type
- Replication
Factor - Replication factor for the discrete design.
Traits§
- DualNum
- A generalized (hyper) dual number.
- Feature
- Defines the value, gradient and hessian functions of a feature.
- Feature
AsAny - Helper trait providing
as_anyas a supertrait ofFeature. Blanket-implemented for everyFeature<D>implementor, so users never writeas_anythemselves and the impl does not leak onto unrelated'statictypes. - Feature
Function - Required value function for Feature derive.
- 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§
- DVector
- A dynamically sized column vector.
- Matrix1
- A stack-allocated, column-major, 1x1 square matrix.
- Matrix2
- A stack-allocated, column-major, 2x2 square matrix.
- Matrix3
- A stack-allocated, column-major, 3x3 square matrix.
- Matrix4
- A stack-allocated, column-major, 4x4 square matrix.
- Matrix5
- A stack-allocated, column-major, 5x5 square matrix.
- Matrix6
- A stack-allocated, column-major, 6x6 square matrix.
- Optimalities
- Vector of weighted optimalities
- Result
- Main result type
- SMatrix
- A statically sized column-major matrix with
Rrows andCcolumns. - SVector
- A statically sized D-dimensional column vector.
- Vector1
- A stack-allocated, 1-dimensional column vector.
- Vector2
- A stack-allocated, 2-dimensional column vector.
- Vector3
- A stack-allocated, 3-dimensional column vector.
- Vector4
- A stack-allocated, 4-dimensional column vector.
- Vector5
- A stack-allocated, 5-dimensional column vector.
- Vector6
- A stack-allocated, 6-dimensional column vector.