pub fn design<R>(
hypotheses: usize,
experiments: &[Experiment<R>],
objective: MinCostCover<R>,
) -> Result<DesignPlan<R>, QuantumError>Expand description
The exact minimum-cost cover of the C(n, 2) hypothesis pairs by the offered experiments.
A dynamic program over subsets of covered pairs: dp[S | cover(e)] = min(dp[S], dp[S] + cost(e)), relaxed for every state in ascending order and every experiment in declared order.
O(2^C(n,2) · k), linear in the experiments and exponential in the hypotheses; enumerating
experiment subsets at 2^k is the wrong enumeration and is not what runs. Strict relaxation in
declared order breaks every tie the same way, so one instance yields one plan.
An experiment covers a pair when the two hypotheses’ predicted read-outs separate by at least
floor_bits at the experiment’s shots, measured as the shot-scaled Bhattacharyya distance and
compared with the state member of the tolerance family as slack. Pairs no experiment covers
are reported rather than failed: the solve targets the coverable pairs and lists the rest.
§Errors
QuantumError::HypothesisCountExceeded naming n and C(n, 2) when n exceeds
objective.max_hypotheses or C(n, 2) exceeds the pair mask, before the pairs or the table
are allocated; C(n, 2) is computed in checked arithmetic, and an overflow is reported as
usize::MAX pairs. QuantumError::CalculationError if fewer than two hypotheses are
offered, since there is then no pair to cover, or if objective.floor_bits is not finite or is
negative. QuantumError::DimensionMismatch if an experiment predicts for a different number
of hypotheses.