Introduction to Luna Algorithms¶
LunaSolve supports a variety of classical and quantum optimization algorithms that can be executed on classical and quantum backends, respectively. Each algorithm is designed to work with a specific set of backend types (e.g., D-Wave, IBM, or simulators). This page explains how to setup an algorithm component and interact with algorithm classes.
π Running an Algorithm¶
You can run an optimization algorithm using Luna by initializing both your model and the algorithm with the desired backend.
from luna_quantum.solve.parameters.algorithms import SimulatedAnnealing
from luna_quantum.solve.parameters.backends import DWave
# Define your model
model = ...
# Initialize the algorithm with a backend
algorithm = SimulatedAnnealing(
backend=DWave()
)
# Execute the algorithm
solve_job = algorithm.run(model, name="my-solve-job")
How to work with SolveJobs
After submitting the solvejob, a SolveJob
object is returned.
See the SolveJob documentation for guidance on how to access results, status, and metadata.
Learn more about Backends
Please refer to the Backend Documentation for further information on Backend access and configuration
βοΈ Get Compatible Backends¶
Each algorithm exposes which backends it supports and where the algorithm can be executed.
from luna_quantum.solve.parameters.algorithms import QAOA
compatible_backends = QAOA.get_compatible_backends()
default_backend = QAOA.get_default_backend()
print(compatible_backends)
print(default_backend)
get_compatible_backends()
: Returns a list of supported backend names.get_default_backend()
: Returns the default backend that will be used if none is explicitly set.
π§ Algorithm Parameters¶
Each algorithm in Luna supports two modes of configuration:
- Default configuration: Used when no parameters are specified. This enables quick experimentation with sensible preset values.
- Custom configuration: Lets you override default values by explicitly defining parameters like depth, optimizer, or backend.
While the default setup is sufficient for many use cases, advanced users can pass a custom config object to fine-tune performance.
For parameter details, see the API reference for each algorithm.
π§© Optimization Formats¶
Solvers and algorithms often support specific optimization formats, and not all formats are compatible with every solver. To bridge this gap, LunaSolve provides a robust format translation feature. This allows you to use solvers even if they don't natively support the format your problem is defined in.
For example, you can upload a problem in QUBO format and run it with a solver that expects LPβLunaSolve will automatically handle the conversion for you. This flexibility is powerful, but keep in mind that translations may impact solver performance, especially if the original problem was tailored to a specific format.
π‘ Pro Tip: For the best results and most comprehensive solver information, we recommend using the Model component whenever possible. The translation service will then provide the best translation to any solver format. While format translation ensures compatibility, the
Model
provides richer metadata and optimized performance characteristics that enhance solver selection and result analysis.