DOE Capabilities
Source: examples/doe_capabilities.py
Introduction
Demonstrate one-shot DOE generation for full-factorial, LHS, and frac2 designs.
Technical Implementation
Generate three DOE tables with
drex.generate_doe.Write the LHS table to
artifacts/doe-capabilities/lhs_design.csv.Print run counts for quick sanity checks.
1from __future__ import annotations
2
3import csv
4from pathlib import Path
5
6import design_research_experiments as drex
7
8
9def main() -> None:
10 """Generate representative DOE tables and write one CSV artifact."""
11 full = drex.generate_doe(
12 kind="full",
13 factors={"a": [0, 1], "b": [10, 20, 30]},
14 randomize=False,
15 )
16 lhs = drex.generate_doe(
17 kind="lhs",
18 factors={"x": [0.0, 1.0], "y": [10.0, 20.0]},
19 n_samples=8,
20 seed=7,
21 randomize=True,
22 )
23 frac2 = drex.generate_doe(
24 kind="frac2",
25 factors={"a": [0, 1], "b": [0, 1], "c": [0, 1], "d": [0, 1]},
26 randomize=False,
27 )
28
29 out_dir = Path("artifacts") / "doe-capabilities"
30 out_dir.mkdir(parents=True, exist_ok=True)
31 csv_path = out_dir / "lhs_design.csv"
32 rows = lhs["design"]
33 fieldnames = list(lhs["summary"]["factors"])
34 with csv_path.open("w", encoding="utf-8", newline="") as file_obj:
35 writer = csv.DictWriter(file_obj, fieldnames=fieldnames)
36 writer.writeheader()
37 writer.writerows(rows)
38
39 print(f"Full factorial runs: {full['summary']['n_runs']}")
40 print(f"LHS runs: {lhs['summary']['n_runs']}")
41 print(f"Frac2 runs: {frac2['summary']['n_runs']}")
42 print(f"Wrote LHS design CSV to {csv_path}")
43
44
45if __name__ == "__main__":
46 main()
Expected Results
Run Command
PYTHONPATH=src python examples/doe_capabilities.py
The script reports run counts for each design type and confirms the CSV artifact path for the generated LHS table.