BQPJSON
Format
QUBOTools.bqpjson_fmt — Type
Format{:bqpjson}(; version::VersionNumber, indent::Integer)Precise and detailed information found in the bqpjson docs
Generating BQPJSON Files
using QUBOTools
# Create a model
model = QUBOTools.Model{Int,Float64,Int}(
Dict{Int,Float64}(1 => 0.0, 3 => 0.4, 5 => -4.4),
Dict{Tuple{Int,Int},Float64}((1, 3) => -0.8, (1, 5) => 6.0);
scale = 2.7,
offset = 1.93,
domain = :bool,
metadata = Dict("id" => 2, "description" => "Simple QUBO Problem")
)
# Write to file
QUBOTools.write_model("output.bool.json", model)Example Output
{
"linear_terms": [
{
"id": 2,
"coeff": 0.4
},
{
"id": 3,
"coeff": -4.4
}
],
"variable_domain": "boolean",
"offset": 1.93,
"id": 2,
"variable_ids": [
1,
2,
3
],
"quadratic_terms": [
{
"id_head": 1,
"coeff": -0.8,
"id_tail": 2
},
{
"id_head": 1,
"coeff": 6.0,
"id_tail": 3
}
],
"metadata": {},
"scale": 2.7,
"version": "1.0.0",
"description": "Simple QUBO Problem"
}
Synthesis Metadata
Generated models can record provenance under metadata.synthesis. The generic schema requires a model string and a parameters object. For non-Wishart generators, model can be any string other than "Wishart" and parameters can contain generator-specific fields.
Wishart-generated models use model = "Wishart" and integer n and m parameters:
{
"metadata": {
"synthesis": {
"model": "Wishart",
"parameters": {
"n": 100,
"m": 10
}
}
}
}Interchange Notes
- Variable mapping:
write_modelexports 1-based integervariable_ids(indices(model) = 1:n). To restore non-consecutive, permuted, or non-integer variable labels afterread_model, applyQUBOTools.map_variables(variables(src_model), dst_model). - Sense canonicalization: BQPJSON v1.0.0 represents minimization problems (
sense = :min). When exporting a:maxmodel,write_modelnegates linear and quadratic coefficients,offset, and sampleevaluations so optimal assignments and rankings are preserved; restore:maxsense on import withQUBOTools.cast((QUBOTools.Min => QUBOTools.Max), dst_model). - Sample multiplicities:
SampleSetentries withreads > 1are expanded into repeatedsolutionsentries with distinctids on write and merged back into aggregatedreadscounts on read. Solution-levelmetadatais not part of the BQPJSON v1.0.0 schema. - Numeric conversion:
read_modelparses coefficients,scale,offset, and sampleevaluations asFloat64(Model{Int,Float64,Int}). Values outside exact IEEE 754Float64representation (such as integers with|c| > 2^53orBigFloatvalues) are rounded toFloat64.