characterize_and_validate

characterize_and_validate(problem, target_states, *, service, options=None)[source]

One-call QUBO/HUBO characterization with rich notebook display.

Converts the problem to wire format, submits it to the Qoro Characterization Service, and returns a CharacterizationResult that renders a styled report in Jupyter.

Parameters:
  • problem (divi.qprog.problems.BinaryOptimizationProblem) – A BinaryOptimizationProblem. Wrap raw inputs (ndarray, sparse, BQM, HUBO dict, etc.) by constructing one — the constructor accepts every shape this function used to take directly.

  • target_states (list[str]) – Bitstrings of the known optimal / target states.

  • service (QoroService) – A QoroService instance to drive the API calls.

  • options (CharacterizationOptions | None) – Optional CharacterizationOptions configuring sub-analyses, fixed parameters, ansatz, and constraints. Defaults to a no-op options object (server-side defaults).

Returns:

Rich result object. Displaying it in Jupyter shows a styled HTML report.

Return type:

CharacterizationResult

Raises:

requests.exceptions.HTTPError – On API errors.

Examples

>>> import numpy as np
>>> from divi.backends import (
...     CharacterizationOptions,
...     QoroService,
...     characterize_and_validate,
... )
>>> from divi.qprog.problems import BinaryOptimizationProblem
>>> problem = BinaryOptimizationProblem(np.array([[-1, 2], [0, -1]]))
>>> result = characterize_and_validate(
...     problem,
...     target_states=["01", "10"],
...     service=QoroService(),
...     options=CharacterizationOptions(parameter_sweep=True),
... )
>>> result.quality_score
78.5

Note

Credit cost scales with QUBO size.