Base Classes
BaseAlgorithmSync
Bases: RegisterableComponent, ABC
Base class for synchronous algorithms.
Synchronous algorithms are executed on in a different process than the main benchmark, but they will always return a result when the run method is completed.
run(model: Model) -> Solution
abstractmethod
Run the algorithm synchronously.
Parameters:
-
model(Model) –The model for which the algorithm should be run.
Returns:
-
Solution–The solution of the algorithm.
BaseAlgorithmAsync
Bases: ABC, RegisterableComponent
Base class for all asynchronous algorithms.
An asynchronous algorithm is one where the computation is triggered onetime, and the result is fetched at a later point in time. As an example, a luna quantum algorithm is onetime published to the luna cloud. The luna cloud will execute that algorithm while luna bench can do other stuff. At a later point in time, luna bench will fetch the result from the luna cloud.
model_type: type[T_co]
abstractmethod
property
The data type which will be required to fetch the result of the algorithm.
run_async(model: Model) -> T_co
abstractmethod
Run the algorithm asynchronously.
This function does not calculate a solution for the model. It triggers the calculation somewhere else. If there is data needed to fetch the result later, this data is returned here, so luna bench can fetch the solution later.
Parameters:
-
model(Model) –The model for which the algorithm should be run.
Returns:
-
T_co–The data which is needed to fetch the result of the algorithm.
fetch_result(model: Model, retrieval_data: T_co) -> Result[Solution, str]
abstractmethod
Fetch the result of the algorithm.
Parameters:
-
model(Model) –The model for which the result should be fetched.
-
retrieval_data(T_co) –The data with which the result should be fetched.
Returns:
-
Result[Solution, str]–The result of the algorithm. if it fails, an error message is returned.
BaseFeature
Bases: RegisterableComponent, ABC
Base class for all features.
A feature is a reusable component that extracts additional information from a Model. The result of each feature
can be used in metrics and in plots.
A Feature must always be registered with the @feature decorator before it can be used in a benchmark.
run(model: Model) -> TFeatureResult
abstractmethod
Compute the feature value for a given model.
Parameters:
-
model(Model) –The model for which the feature should be computed.
Returns:
-
TFeatureResult–The result of the computed feature.
BaseMetric
Bases: RegisterableComponent, ABC
Base class for all metrics.
A metric is a reusable component that extracts additional information about a solution. The result of each metric can be used plots to visualize it.
A Metric must always be registered with the @metric decorator before it can be used in a benchmark.
run(solution: Solution, feature_results: FeatureResultContainer) -> TMetricResult
abstractmethod
Compute the metric value for a given solution.
Parameters:
-
solution(Solution) –The solution for which the metric should be computed.
-
feature_results(FeatureResultContainer) –If the metric requires additional features so it can be calculated, they will be provided here.
Returns:
-
ArbitraryDataDomain–The result of the computed metric.
BasePlot
Bases: RegisterableComponent, ABC
Base interface for all plot components.
Subclasses should implement the run method.
run(benchmark_results: BenchmarkResultContainer) -> None
abstractmethod
Generate plot output from benchmark results.
Parameters:
-
benchmark_results(BenchmarkResultContainer) –Aggregated benchmark data consumed by the plot implementation.