This page documents the public lindblad::SoftDispatchResult API.
- Header:
include/lindblad/dispatch.hpp - Namespace:
lindblad
SoftDispatchResult summarizes a sampler count distribution into:
- a fractional soft assignment per bit
- a best bitstring with its probability
- optional rounded or greedy dispatch outputs
The constructor computes total_shots and calls compute() immediately.
counts: raw sampled counts (bitstring -> count)total_shots: sum of all countssoft_assignment: fractional assignment per bitbest_bitstring: most probable bitstringbest_probability: probability ofbest_bitstring
explicit SoftDispatchResult(const std::unordered_map<std::string, int>& counts_in);Behavior:
- sums counts into
total_shots - calls
compute()to fill derived fields
- infers bitstring length from the first key in
counts - populates
soft_assignment,best_bitstring, andbest_probability - returns early if
countsis empty ortotal_shots == 0
- returns an MSB-first bitstring
- uses
>= thresholdto mark a bit as1
- orders indices by descending
soft_assignment - selects until
supplied >= demand - returns selected indices in the chosen order
- throws
std::invalid_argumentif capacity size does not match assignment size
- returns
0.0iftotal_shots == 0 - otherwise computes the expected value under the sampled distribution
- returns the
kmost probable bitstrings and their probabilities - assumes
total_shots > 0to avoid division by zero
greedy_dispatchthrowsstd::invalid_argumentif the capacity vector length does not match the bitstring lengthtop_kexpectstotal_shots > 0(non-empty counts)
#include "lindblad/dispatch.hpp"
using namespace lindblad;
int main() {
std::unordered_map<std::string, int> counts = {
{"110", 30},
{"100", 20}
};
SoftDispatchResult result(counts);
std::string rounded = result.threshold_round(0.5);
auto top = result.top_k(2);
(void)rounded;
(void)top;
return 0;
}