Expand description
Grids of simulation conditions.
A Condition is an ordered set of named Values (numbers, integers, strings,
booleans) read by the scenario with typed getters (Condition::f64,
Condition::usize, Condition::str, …). A Grid produces the conditions of a
campaign:
Grid::axisadds an axis; the conditions are the Cartesian product of the axes, enumerated like nested loops in declaration order (the last axis varies fastest: an SNR declared last gives one sweep per value of the other axes);Grid::fixedadds a constant to every condition;Grid::zipadds several axes that vary together (one value of each per step);Grid::from_conditionstakes an explicit list.
Every key is given once: Grid::check (which the runner calls) refuses a key that
two axes, zips or fixed values give, or that they give on top of an explicit
condition, since the second value would replace the first and repeat conditions.
§Examples
use comnum_sim::grid::{Grid, Value};
let g = Grid::new()
.axis("modulation", ["qpsk", "16qam"])
.axis("snr_db", [10.0, 15.0, 20.0])
.fixed("n_symbols", 4096usize);
let c = g.conditions();
assert_eq!(c.len(), 6);
assert_eq!(c[1].str("modulation").unwrap(), "qpsk");
assert_eq!(c[1].f64("snr_db").unwrap(), 15.0); // the last axis varies fastest
assert_eq!(c[5].usize("n_symbols").unwrap(), 4096);
assert_eq!(c[0].label(), "modulation=qpsk, snr_db=10, n_symbols=4096");
assert_eq!(Value::from(3usize).as_f64(), Some(3.0));Structs§
- Condition
- One simulation condition: named values in a fixed order.
- Grid
- A grid of conditions (see the module documentation).
Enums§
- Value
- The value of a condition entry.