Postprocess Counts
curl --request POST \
--url 'https://api.example.com/postprocess?HAIQU_API_KEY=' \
--header 'Content-Type: application/json' \
--data '
{
"counts": {},
"lp_problem": "<string>",
"polynomial_problem": {},
"params": {
"method": "bitflip_incremental",
"postprocess_iterations": 5,
"use_fast_eval": true,
"seed": 1
}
}
'import requests
url = "https://api.example.com/postprocess?HAIQU_API_KEY="
payload = {
"counts": {},
"lp_problem": "<string>",
"polynomial_problem": {},
"params": {
"method": "bitflip_incremental",
"postprocess_iterations": 5,
"use_fast_eval": True,
"seed": 1
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
counts: {},
lp_problem: '<string>',
polynomial_problem: {},
params: {
method: 'bitflip_incremental',
postprocess_iterations: 5,
use_fast_eval: true,
seed: 1
}
})
};
fetch('https://api.example.com/postprocess?HAIQU_API_KEY=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/postprocess?HAIQU_API_KEY=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'counts' => [
],
'lp_problem' => '<string>',
'polynomial_problem' => [
],
'params' => [
'method' => 'bitflip_incremental',
'postprocess_iterations' => 5,
'use_fast_eval' => true,
'seed' => 1
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/postprocess?HAIQU_API_KEY="
payload := strings.NewReader("{\n \"counts\": {},\n \"lp_problem\": \"<string>\",\n \"polynomial_problem\": {},\n \"params\": {\n \"method\": \"bitflip_incremental\",\n \"postprocess_iterations\": 5,\n \"use_fast_eval\": true,\n \"seed\": 1\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/postprocess?HAIQU_API_KEY=")
.header("Content-Type", "application/json")
.body("{\n \"counts\": {},\n \"lp_problem\": \"<string>\",\n \"polynomial_problem\": {},\n \"params\": {\n \"method\": \"bitflip_incremental\",\n \"postprocess_iterations\": 5,\n \"use_fast_eval\": true,\n \"seed\": 1\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/postprocess?HAIQU_API_KEY=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"counts\": {},\n \"lp_problem\": \"<string>\",\n \"polynomial_problem\": {},\n \"params\": {\n \"method\": \"bitflip_incremental\",\n \"postprocess_iterations\": 5,\n \"use_fast_eval\": true,\n \"seed\": 1\n }\n}"
response = http.request(request)
puts response.read_body{
"optimized_costs": {},
"optimized_counts": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}API Reference
Postprocess Counts
Apply post-processing to quantum measurement counts.
This endpoint provides access to Haiqu's proprietary optimization algorithms
for post-processing QAOA/VQE measurement results.
All algorithm defaults are defined in haiqu-optimization. Users can override
any parameter by passing it in the params dictionary.
Args:
request: PostprocessRequest containing:
- polynomial_problem: supported OptimizationProblem polynomial JSON
- lp_problem: deprecated QUBO serialized as LP for backward compatibility
- counts: Dictionary of bitstring -> count mappings
- params: Optional parameters dict. Available options:
* method (str): Post-processing method. Default: "bitflip_incremental"
* reverse_string (bool): Whether to reverse bitstring ordering. Default: True
* postprocess_iterations (int): Number of optimization passes. Default: 5
* use_fast_eval (bool): Enable fast evaluation. Default: True
* seed (int): Random seed for reproducibility. Default: None
Returns:
PostprocessResponse with optimized costs and counts
Raises:
HTTPException: 400 if invalid problem format
HTTPException: 500 if processing fails
Example:
{
"lp_problem": "Minimize\n x0 + x1\nBinary\n x0\n x1\nEnd",
"counts": {"00": 100, "01": 50},
"params": {
"postprocess_iterations": 10,
"seed": 42
}
}
POST
/
postprocess
Postprocess Counts
curl --request POST \
--url 'https://api.example.com/postprocess?HAIQU_API_KEY=' \
--header 'Content-Type: application/json' \
--data '
{
"counts": {},
"lp_problem": "<string>",
"polynomial_problem": {},
"params": {
"method": "bitflip_incremental",
"postprocess_iterations": 5,
"use_fast_eval": true,
"seed": 1
}
}
'import requests
url = "https://api.example.com/postprocess?HAIQU_API_KEY="
payload = {
"counts": {},
"lp_problem": "<string>",
"polynomial_problem": {},
"params": {
"method": "bitflip_incremental",
"postprocess_iterations": 5,
"use_fast_eval": True,
"seed": 1
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
counts: {},
lp_problem: '<string>',
polynomial_problem: {},
params: {
method: 'bitflip_incremental',
postprocess_iterations: 5,
use_fast_eval: true,
seed: 1
}
})
};
fetch('https://api.example.com/postprocess?HAIQU_API_KEY=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/postprocess?HAIQU_API_KEY=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'counts' => [
],
'lp_problem' => '<string>',
'polynomial_problem' => [
],
'params' => [
'method' => 'bitflip_incremental',
'postprocess_iterations' => 5,
'use_fast_eval' => true,
'seed' => 1
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/postprocess?HAIQU_API_KEY="
payload := strings.NewReader("{\n \"counts\": {},\n \"lp_problem\": \"<string>\",\n \"polynomial_problem\": {},\n \"params\": {\n \"method\": \"bitflip_incremental\",\n \"postprocess_iterations\": 5,\n \"use_fast_eval\": true,\n \"seed\": 1\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/postprocess?HAIQU_API_KEY=")
.header("Content-Type", "application/json")
.body("{\n \"counts\": {},\n \"lp_problem\": \"<string>\",\n \"polynomial_problem\": {},\n \"params\": {\n \"method\": \"bitflip_incremental\",\n \"postprocess_iterations\": 5,\n \"use_fast_eval\": true,\n \"seed\": 1\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/postprocess?HAIQU_API_KEY=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"counts\": {},\n \"lp_problem\": \"<string>\",\n \"polynomial_problem\": {},\n \"params\": {\n \"method\": \"bitflip_incremental\",\n \"postprocess_iterations\": 5,\n \"use_fast_eval\": true,\n \"seed\": 1\n }\n}"
response = http.request(request)
puts response.read_body{
"optimized_costs": {},
"optimized_counts": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
APIKeyQueryAPIKeyHeader
Body
application/json
Request model for postprocessing endpoint.
Mapping of bitstring -> measurement count/probability
Show child attributes
Show child attributes
Deprecated QUBO serialized as LP file content
Minimum string length:
1OptimizationProblem serialized as polynomial JSON
Parameters for postprocessing optimization.
Only the parameters below are accepted; unknown keys are rejected so that arbitrary values never reach the postprocessing implementation.
Show child attributes
Show child attributes