This page documents lindblad::SoftDispatchResult and the dispatch-oriented helpers used with QAOA and MAQAOA outputs.
The dispatch helpers convert sampled bitstring distributions into a more useful fractional or integer decision structure.
They are intended for optimization problems where the sampled distribution represents generator commitment, resource allocation, or similar binary decisions.
A sampler returns a histogram over bitstrings.
SoftDispatchResult turns that histogram into:
- a soft assignment vector representing fractional commitment
- a best bitstring from the highest-probability sampled state
- optional rounded and greedy dispatch solutions
This makes it easier to move from quantum samples to a practical dispatch schedule.
- A sampler count map as
std::unordered_map<std::string, int> - The total number of shots
- Optional generator capacities and demand when using greedy dispatch
Include the header:
#include "lindblad/dispatch.hpp"Construct the helper from raw counts:
using namespace lindblad;
std::unordered_map<std::string, int> counts = {
{"101", 40},
{"111", 12},
{"001", 8}
};
SoftDispatchResult result(counts);
result.compute();
std::string thresholded = result.threshold_round(0.5);If you have generator capacities and demand, use greedy dispatch:
std::vector<double> capacities = {5.0, 4.0, 3.0};
double demand = 7.0;
auto selected = result.greedy_dispatch(capacities, demand);Use:
#include "lindblad/dispatch.hpp"These helpers operate on existing sampler outputs rather than directly on a simulator.
They are commonly used after:
- QAOA
- MAQAOA
- other binary optimization routines
Fields:
counts: raw sampled countstotal_shots: total number of shotssoft_assignment: fractional assignment vector computed from the countsbest_bitstring: highest-probability measured bitstringbest_probability: probability of the best bitstring
Methods:
compute()fills the derived fields from the raw countsthreshold_round(double threshold = 0.5)returns a rounded MSB-first bitstringgreedy_dispatch(const std::vector<double>& generator_capacities, double demand)returns selected generator indicesexpected_cost(const std::function<double(const std::string&)>& cost_fn)computes expected cost under the sampled distributiontop_k(int k)returns thekmost probable bitstrings and probabilities
#include "lindblad/dispatch.hpp"
using namespace lindblad;
int main() {
std::unordered_map<std::string, int> counts = {
{"110", 30},
{"100", 20}
};
SoftDispatchResult result(counts);
result.compute();
std::cout << "best: " << result.best_bitstring << '\n';
std::cout << "rounded: " << result.threshold_round() << '\n';
}compute()populates the soft assignment and best bitstring fieldsthreshold_round()returns a binary stringgreedy_dispatch()returns selected generator indicesexpected_cost()returns a scalar objective estimatetop_k()returns the most likely sampled states and their probabilities
Common issues include:
- empty counts maps
- count strings whose length does not match the dispatch problem size
- capacity vectors that do not match the number of binary variables
- demand values that cannot be met by the available capacities
- The helper works on sampled distributions, not on the underlying Hamiltonian directly.
threshold_round()andgreedy_dispatch()solve different decision problems.- The bitstring convention remains MSB-first.
Dispatch-related behavior is exercised indirectly through the microgrid and MAQAOA tests.