integrate_monte_carlo

fireopal.integrate_monte_carlo(problem, credentials, backend_name=None, integrator_options=None, run_options=None)

Solve a Monte Carlo integration problem.

Parameters

  • problem (dict [ str , Any ] | dict [ str , str ]) – A dictionary containing a pre-built quantum circuit representing the composition of the objective function and probability distribution, in the format {"preparation_circuit": <QASM string>}. Alternatively, it is a dictionary containing the objective function and probability distribution, built using make_monte_carlo_problem(). Objective functions can be created with helpers such as make_european_call_pricing_objective(), make_european_call_delta_objective(), or make_fixed_income_pricing_objective(), and distributions with make_lognormal_distribution(), make_normal_distribution(), make_uniform_distribution(), or make_gci_model_distribution().

  • credentials (Credentials) – Credentials for the target hardware provider, created using the appropriate helper from the fireopal.credentials module. For example, use make_credentials_for_ibm_cloud() for IBM backends.

  • backend_name (str) – Name of the target backend device (for example, "ibm_boston"). Call show_supported_devices() to list available names for your credentials.

  • integrator_options (dict [ str , Any ] or None , optional) –

    A dictionary containing options for the integrator. Default is None. If None, default options will be used. The expected keys in the dictionary are:

    • “max_iteration_count”: int, optional

    The maximum number of iterations to perform before terminating the integration process. If the value exceeds the maximum recommended value (MAX_ITERATION_COUNT), a warning is issued.

    • ”target_variance”: float, optional : The target variance for the estimate. The integration process will terminate once the variance of the estimate is below this threshold.
    • ”full_output”: bool, optional : If True, the integration process will return detailed information about each iteration in the metadata field of the result. Defaults to False.
    • run_options (RunOptions or None , optional) – Provider-specific execution options, for example, IbmRunOptions. See the fireopal.run_options module for available classes. Defaults to None.

Returns

FireOpalJob – A job object whose result() method returns a dictionary containing:

estimate (float) : The estimate of the integral.

variance (float) : The variance of the estimate.

iteration_count (int) : The number of iterations performed.

metadata (dict[str, Any]) : Additional information about the integration process. If full_output is True, metadata["iterations"] contains a list of dictionaries, each representing an iteration of the integration process, with keys "estimate", "variance", and "iteration_count".

Raises

QctrlArgumentsValueError – If backend_name is not provided when submitting a circuit, if an unsupported objective function or distribution is specified, or if both a circuit and a named config are provided for the same component.

Was this useful?