taguchi/
lib.rs

1//! # Taguchi
2//!
3//! A state-of-the-art orthogonal array library for experimental design, Monte Carlo sampling,
4//! and combinatorial testing.
5//!
6//! ## Overview
7//!
8//! Orthogonal arrays (OAs) are mathematical structures used in:
9//! - **Design of Experiments (DOE)**: Taguchi methods for quality engineering
10//! - **Monte Carlo Integration**: Quasi-random sampling with better uniformity
11//! - **Software Testing**: Combinatorial test case generation (OATS)
12//!
13//! This library provides:
14//! - Multiple construction algorithms (Bose, Bush, Bose-Bush, Addelman-Kempthorne, Hadamard)
15//! - Full prime power support via custom Galois field arithmetic
16//! - Verification and validation of array properties
17//! - Modern Rust API with builder patterns and comprehensive error handling
18//!
19//! ## Quick Start
20//!
21//! The easiest way to create an orthogonal array is with the builder:
22//!
23//! ```rust
24//! use taguchi::OABuilder;
25//!
26//! // Automatically selects the best construction
27//! let oa = OABuilder::new()
28//!     .levels(3)
29//!     .factors(4)
30//!     .strength(2)
31//!     .build()
32//!     .unwrap();
33//!
34//! assert_eq!(oa.runs(), 9);    // Bose: 3²
35//! assert_eq!(oa.factors(), 4);
36//! assert_eq!(oa.levels(), 3);
37//! ```
38//!
39//! Or use a specific construction directly:
40//!
41//! ```rust
42//! use taguchi::construct::{Constructor, Bose};
43//!
44//! let oa = Bose::new(3)
45//!     .construct(4)
46//!     .expect("Failed to construct OA");
47//!
48//! assert_eq!(oa.runs(), 9);
49//! assert_eq!(oa.factors(), 4);
50//! assert_eq!(oa.levels(), 3);
51//! ```
52//!
53//! ## Notation
54//!
55//! An orthogonal array is denoted as OA(N, k, s, t) where:
56//! - **N**: Number of runs (rows)
57//! - **k**: Number of factors (columns)
58//! - **s**: Number of levels (symbols 0, 1, ..., s-1)
59//! - **t**: Strength (every t-column subarray contains all s^t tuples equally)
60//!
61//! ## Features
62//!
63//! - `serde`: Enable serialization/deserialization of OA structures
64//! - `parallel`: Enable parallel construction using rayon
65//! - `stats`: Enable statistical analysis utilities
66//! - `python`: Enable Python bindings via PyO3
67
68#![warn(missing_docs)]
69#![warn(clippy::all)]
70#![warn(clippy::pedantic)]
71#![allow(clippy::module_name_repetitions)]
72
73pub mod builder;
74pub mod catalogue;
75pub mod construct;
76pub mod error;
77pub mod gf;
78pub mod oa;
79#[cfg(feature = "python")]
80pub mod python;
81pub mod utils;
82
83#[cfg(feature = "parallel")]
84pub mod parallel;
85
86/// Prelude module for convenient imports.
87pub mod prelude {
88    pub use crate::builder::{build_oa, OABuilder};
89    pub use crate::construct::{
90        AddelmanKempthorne, Bose, BoseBush, Bush, Constructor, HadamardPaley, HadamardSylvester,
91        RaoHamming,
92    };
93    pub use crate::error::{Error, Result};
94    pub use crate::gf::{
95        available_field_orders, get_irreducible_poly, has_irreducible_poly, DynamicGf, GaloisField,
96        GfElement, GF11, GF13, GF2, GF3, GF5, GF7,
97    };
98    pub use crate::oa::{compute_strength, verify_strength, BalanceReport, OAParams, OA};
99    pub use crate::utils::{factor_prime_power, is_prime, is_prime_power, smallest_prime_factor};
100
101    #[cfg(feature = "parallel")]
102    pub use crate::parallel::{
103        par_build_oa, ParAddelmanKempthorne, ParBose, ParBush, ParHadamardSylvester,
104    };
105}
106
107// Re-export commonly used items at crate root
108pub use builder::{available_constructions, build_oa, OABuilder};
109pub use catalogue::get_by_name as get_standard_oa;
110pub use error::{Error, Result};
111pub use oa::{compute_strength, verify_strength};
112pub use utils::{is_prime, is_prime_power};
113
114#[cfg(feature = "parallel")]
115pub use parallel::{par_build_oa, ParAddelmanKempthorne, ParBose, ParBush, ParHadamardSylvester};