curl --request POST \
--url 'https://api.example.com/ai/build_lr_qaoa_circuit?HAIQU_API_KEY=' \
--header 'Content-Type: application/json' \
--data '
{
"delta": 0.5,
"experiment_id": "exp-123",
"lp_problem": "Maximize\n obj: x0 + x1\nBinary\n x0\n x1\nEnd",
"name": "maxcut-ring-8 lr-qaoa p=3",
"p": 3
}
'import requests
url = "https://api.example.com/ai/build_lr_qaoa_circuit?HAIQU_API_KEY="
payload = {
"delta": 0.5,
"experiment_id": "exp-123",
"lp_problem": "Maximize
obj: x0 + x1
Binary
x0
x1
End",
"name": "maxcut-ring-8 lr-qaoa p=3",
"p": 3
}
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({
delta: 0.5,
experiment_id: 'exp-123',
lp_problem: 'Maximize\n obj: x0 + x1\nBinary\n x0\n x1\nEnd',
name: 'maxcut-ring-8 lr-qaoa p=3',
p: 3
})
};
fetch('https://api.example.com/ai/build_lr_qaoa_circuit?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/ai/build_lr_qaoa_circuit?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([
'delta' => 0.5,
'experiment_id' => 'exp-123',
'lp_problem' => 'Maximize
obj: x0 + x1
Binary
x0
x1
End',
'name' => 'maxcut-ring-8 lr-qaoa p=3',
'p' => 3
]),
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/ai/build_lr_qaoa_circuit?HAIQU_API_KEY="
payload := strings.NewReader("{\n \"delta\": 0.5,\n \"experiment_id\": \"exp-123\",\n \"lp_problem\": \"Maximize\\n obj: x0 + x1\\nBinary\\n x0\\n x1\\nEnd\",\n \"name\": \"maxcut-ring-8 lr-qaoa p=3\",\n \"p\": 3\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/ai/build_lr_qaoa_circuit?HAIQU_API_KEY=")
.header("Content-Type", "application/json")
.body("{\n \"delta\": 0.5,\n \"experiment_id\": \"exp-123\",\n \"lp_problem\": \"Maximize\\n obj: x0 + x1\\nBinary\\n x0\\n x1\\nEnd\",\n \"name\": \"maxcut-ring-8 lr-qaoa p=3\",\n \"p\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/ai/build_lr_qaoa_circuit?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 \"delta\": 0.5,\n \"experiment_id\": \"exp-123\",\n \"lp_problem\": \"Maximize\\n obj: x0 + x1\\nBinary\\n x0\\n x1\\nEnd\",\n \"name\": \"maxcut-ring-8 lr-qaoa p=3\",\n \"p\": 3\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"hash": "<string>",
"name": "<string>",
"creation_date": "2023-11-07T05:31:56Z",
"user_id": 123,
"experiment_id": "<string>",
"status": "Submitted",
"generated": true,
"context": "<string>",
"description": "",
"tags": "",
"parameters": {},
"analytics": {
"qubits": 2,
"depth": 123,
"depth_2q": 123,
"gates_1q": 123,
"gates_2q": 123,
"gates_total": 123,
"other_ops": 123,
"num_qubits_active": 123,
"num_parameters": 123,
"other_gates": 123,
"instructions_total": 123,
"operations_counts": {},
"gate_size_distribution": {},
"gate_diversity": {},
"gate_diversity_basis_gates": {},
"gate_count_distribution": {},
"program_communication": "N/A",
"critical_depth": "N/A",
"entanglement_ratio": "N/A",
"parallelism": "N/A",
"liveness_per_qubit": "N/A",
"liveness": "N/A",
"correlation_matrix": {},
"kl_divergence": "N/A",
"entanglement_capability": "N/A",
"expressibility": "N/A",
"quantum_fisher_information_matrix": "N/A",
"circuit_normalized": "<string>"
},
"transpilation_target": "<string>",
"transpilation_options": {},
"transpiled_circuit_ids": [
"<string>"
],
"compressed_circuit_ids": [
"<string>"
],
"job_ids": [
"<string>"
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Build Lr Qaoa Circuit Mcp
Build and store a linear-ramp QAOA circuit for a QUBO problem.
Use this tool to turn a combinatorial optimization problem into a runnable circuit without writing QASM. Generation is synchronous: the circuit is stored and returned immediately, with core analytics already computed.
When to Use:
- Call this when the user has a QUBO or MaxCut-style problem in LP format and wants to run QAOA on it.
- Call this instead of
submit_circuit_for_analyticswhen Haiqu should construct the ansatz rather than the caller.
Constraints:
lp_problemmust parse as an LP-format QUBO with binary variables.alphasandbetasmust each have lengthpwhen supplied. Omit both to use the linear ramp defined bydelta.- Nothing is executed here. Run the returned
idwithrun_circuits_on_qpu_or_simulator.
Notes:
- The linear-ramp schedule needs no classical outer loop, which is what makes LR-QAOA cheap compared with parameter-optimized QAOA.
- Keep the same
lp_problemstring forpostprocess_measurement_countsso the objective matches.
Args: user: Authenticated user resolved from the API key. data: Problem definition, layer count, and optional schedule. db: Active database session.
Returns: The stored circuit enriched with MCP context text.
Raises:
HTTPException: Raised with 404 when the experiment is not available to
the caller, or 500 when circuit generation fails.
curl --request POST \
--url 'https://api.example.com/ai/build_lr_qaoa_circuit?HAIQU_API_KEY=' \
--header 'Content-Type: application/json' \
--data '
{
"delta": 0.5,
"experiment_id": "exp-123",
"lp_problem": "Maximize\n obj: x0 + x1\nBinary\n x0\n x1\nEnd",
"name": "maxcut-ring-8 lr-qaoa p=3",
"p": 3
}
'import requests
url = "https://api.example.com/ai/build_lr_qaoa_circuit?HAIQU_API_KEY="
payload = {
"delta": 0.5,
"experiment_id": "exp-123",
"lp_problem": "Maximize
obj: x0 + x1
Binary
x0
x1
End",
"name": "maxcut-ring-8 lr-qaoa p=3",
"p": 3
}
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({
delta: 0.5,
experiment_id: 'exp-123',
lp_problem: 'Maximize\n obj: x0 + x1\nBinary\n x0\n x1\nEnd',
name: 'maxcut-ring-8 lr-qaoa p=3',
p: 3
})
};
fetch('https://api.example.com/ai/build_lr_qaoa_circuit?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/ai/build_lr_qaoa_circuit?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([
'delta' => 0.5,
'experiment_id' => 'exp-123',
'lp_problem' => 'Maximize
obj: x0 + x1
Binary
x0
x1
End',
'name' => 'maxcut-ring-8 lr-qaoa p=3',
'p' => 3
]),
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/ai/build_lr_qaoa_circuit?HAIQU_API_KEY="
payload := strings.NewReader("{\n \"delta\": 0.5,\n \"experiment_id\": \"exp-123\",\n \"lp_problem\": \"Maximize\\n obj: x0 + x1\\nBinary\\n x0\\n x1\\nEnd\",\n \"name\": \"maxcut-ring-8 lr-qaoa p=3\",\n \"p\": 3\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/ai/build_lr_qaoa_circuit?HAIQU_API_KEY=")
.header("Content-Type", "application/json")
.body("{\n \"delta\": 0.5,\n \"experiment_id\": \"exp-123\",\n \"lp_problem\": \"Maximize\\n obj: x0 + x1\\nBinary\\n x0\\n x1\\nEnd\",\n \"name\": \"maxcut-ring-8 lr-qaoa p=3\",\n \"p\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/ai/build_lr_qaoa_circuit?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 \"delta\": 0.5,\n \"experiment_id\": \"exp-123\",\n \"lp_problem\": \"Maximize\\n obj: x0 + x1\\nBinary\\n x0\\n x1\\nEnd\",\n \"name\": \"maxcut-ring-8 lr-qaoa p=3\",\n \"p\": 3\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"hash": "<string>",
"name": "<string>",
"creation_date": "2023-11-07T05:31:56Z",
"user_id": 123,
"experiment_id": "<string>",
"status": "Submitted",
"generated": true,
"context": "<string>",
"description": "",
"tags": "",
"parameters": {},
"analytics": {
"qubits": 2,
"depth": 123,
"depth_2q": 123,
"gates_1q": 123,
"gates_2q": 123,
"gates_total": 123,
"other_ops": 123,
"num_qubits_active": 123,
"num_parameters": 123,
"other_gates": 123,
"instructions_total": 123,
"operations_counts": {},
"gate_size_distribution": {},
"gate_diversity": {},
"gate_diversity_basis_gates": {},
"gate_count_distribution": {},
"program_communication": "N/A",
"critical_depth": "N/A",
"entanglement_ratio": "N/A",
"parallelism": "N/A",
"liveness_per_qubit": "N/A",
"liveness": "N/A",
"correlation_matrix": {},
"kl_divergence": "N/A",
"entanglement_capability": "N/A",
"expressibility": "N/A",
"quantum_fisher_information_matrix": "N/A",
"circuit_normalized": "<string>"
},
"transpilation_target": "<string>",
"transpilation_options": {},
"transpiled_circuit_ids": [
"<string>"
],
"compressed_circuit_ids": [
"<string>"
],
"job_ids": [
"<string>"
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
Define payload for building an LR-QAOA circuit from a QUBO problem.
Attributes: experiment_id: Parent experiment identifier for the generated circuit. lp_problem: Unconstrained quadratic problem in LP file format. p: Number of QAOA layers. name: Circuit name. alphas: Optional per-layer cost-Hamiltonian schedule. betas: Optional per-layer mixer schedule. delta: Linear-ramp slope used when no explicit schedule is given.
Response
Successful Response
Extend a stored circuit model with MCP context text.
Attributes: context: ai summary describing the circuit role in the workflow.