modules.solvers.qrisp_qiro.QIROSolver

class QIROSolver

Bases: Solver

Run the QIRO implementation within the Qrisp local simulator backend.

__init__()

Constructor method.

Methods

__init__()

Constructor method.

get_available_submodule_options()

Gets the list of available options.

get_available_submodules(option)

If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.

get_default_submodule(option)

Returns the default submodule based on the given option.

get_depending_parameters(option, config)

If the module has parameters depending on certain options, this method should return the parameters for the given option.

get_parameter_options()

Returns the configurable settings for this solver.

get_requirements()

Return requirements of this module.

get_submodule(option)

Submodule is instantiated according to the information given in self.sub_options.

postprocess(input_data, config, **kwargs)

The actual solving process is done here, using the device which is provided by the device submodule and the problem data provided by the parent module.

preprocess(input_data, config, **kwargs)

Essential method for the benchmarking process.

run(mapped_problem, device_wrapper, config, ...)

Run Qrisp QIRO on the local Qrisp simulator.

class Config

Bases: TypedDict

Attributes of a valid config.

shots: int
depth: int
iterations: int
QIRO_reps: int
clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
get_available_submodule_options() list

Gets the list of available options.

Returns:

List of module options

get_available_submodules(option: list) list

If the module has submodules depending on certain options, this method should adjust the submodule_options accordingly.

Parameters:

option -- List of chosen options

Returns:

List of available submodules

get_default_submodule(option: str) Core

Returns the default submodule based on the given option.

Parameters:

option -- The submodule option to select

Returns:

Instance of the selected submodule

Raises:

NotImplemented -- If the provided option is not implemented

get_depending_parameters(option: str, config: dict) dict

If the module has parameters depending on certain options, this method should return the parameters for the given option.

Parameters:
  • option -- The chosen option

  • config -- Current config dictionary

Returns:

The parameters for the given option

get_parameter_options() dict

Returns the configurable settings for this solver.

Returns:

return {
        "shots": {  # number measurements to make on circuit
            "values": [10, 500, 1000, 2000, 5000, 10000],
            "description": "How many shots do you need?"
        },
        "iterations": {  # number of optimization iterations
            "values": [5, 10, 20, 50, 75],
            "description": "How many optimization iterations do you need?"
        },
        "depth": { # depth of original QAOA
            "values": [2, 3, 4, 5, 10],
            "description": "How many layers for QAOA (Parameter: p) do you want?"
        },
        "QIRO_reps": { # number of QIRO reps
            "values": [2, 3, 4, 5],
            "description": "How QIRO reps (Parameter: n) do you want? Choose this
                            "parameter sensibly in relation to the graph size!"
        }
    }
static get_requirements() list[dict]

Return requirements of this module.

Returns:

List of dict with requirements of this module

get_submodule(option: str) Core

Submodule is instantiated according to the information given in self.sub_options. If self.sub_options is None, get_default_submodule is called as a fallback.

Parameters:

option -- String with the options

Returns:

Instance of a module

postprocess(input_data: any, config: dict, **kwargs) tuple[any, float]

The actual solving process is done here, using the device which is provided by the device submodule and the problem data provided by the parent module.

Parameters:
  • input_data -- Data passed to the run function of the solver

  • config -- Solver config

  • kwargs -- Optional keyword arguments

Returns:

Output and time needed

preprocess(input_data: any, config: dict, **kwargs) tuple[any, float]

Essential method for the benchmarking process. This is always executed before traversing down to the next module, passing the data returned by this function.

Parameters:
  • input_data -- Data for the module, comes from the parent module if that exists

  • config -- Config for the module

  • kwargs -- Optional keyword arguments

Returns:

The output of the preprocessing and the time it took to preprocess

run(mapped_problem: any, device_wrapper: any, config: Config, **kwargs: dict) tuple[any, float, dict]

Run Qrisp QIRO on the local Qrisp simulator.

Parameters:
  • mapped_problem -- Dictionary with the keys 'graph' and 't'

  • device_wrapper -- Instance of device

  • config -- Solver configuration settings

  • kwargs -- no additionally settings needed, may include the measurement kwargs

Returns:

Solution, the time it took to compute it and optional additional information