PopulationAnnealing¶
Population Annealing uses a sequential Monte Carlo method to minimize the energy of a population. The population consists of walkers that can explore their neighborhood during the cooling process. Afterwards, walkers are removed and duplicated using bias to lower energy. Eventually, a population collapse occurs where all walkers are in the lowest energy state.
Compatible Backends¶
The PopulationAnnealing
algorithm supports the following backends:
By default, PopulationAnnealing
uses the DWave
backend.
Initialization¶
The following section outlines the default configurations of PopulationAnnealing
. You can also specify other compatible backends for the algorithm. When backend=None
is specified, the default backend will be initialized automatically. In this case, if the backend requires a token, it will be taken from the environment variables.
from luna_quantum.solve.parameters.algorithms import PopulationAnnealing
algorithm = PopulationAnnealing(
backend=None,
max_iter=20,
max_time=2,
fixed_temp_sampler_num_sweeps=10000,
fixed_temp_sampler_num_reads=None
)
Parameter Details
For a complete overview of available parameters and their usage, see the PopulationAnnealing API Reference.
Usage¶
from luna_quantum import LunaSolve
LunaSolve.authenticate("<YOUR_LUNA_API_KEY>")
# Define your model and algorithm
model = ...
algorithm = ...
solve_job = algorithm.run(model, name="my-solve-job")
API Reference¶
Bases: LunaAlgorithm[DWave]
Parameters for the Population Annealing algorithm.
Population Annealing uses a sequential Monte Carlo method to minimize the energy of a population. The population consists of walkers that can explore their neighborhood during the cooling process. Afterwards, walkers are removed and duplicated using bias to lower energy. Eventually, a population collapse occurs where all walkers are in the lowest energy state.
Attributes:
Name | Type | Description |
---|---|---|
max_iter |
int
|
Maximum number of annealing iterations (temperature steps) to perform. Each iteration involves lowering the temperature, allowing walkers to explore locally, and then resampling the population based on Boltzmann weights. Higher values allow for a more gradual cooling schedule, potentially finding better solutions but increasing computation time. Default is 20, which provides a reasonable balance for most problems. |
max_time |
int
|
Maximum time in seconds that the algorithm is allowed to run. Provides a hard time limit regardless of convergence or iteration status. Useful for time-constrained scenarios where some solution is needed within a specific timeframe. Default is 2, which is relatively aggressive and may need to be increased for complex problems. |
fixed_temp_sampler_num_sweeps |
int
|
Number of Monte Carlo sweeps to perform at each temperature level, where one sweep attempts to update all variables once. More sweeps allow walkers to explore their local configuration space more thoroughly, producing better equilibrated samples but increasing computation time. This parameter directly affects how well each walker samples its local energy landscape before resampling occurs. Default is 10,000, which is suitable for thorough exploration of moderate-sized problems. |
fixed_temp_sampler_num_reads |
int | None
|
Number of independent sampling runs to perform at each temperature level. Each run effectively initializes a separate walker in the population. Multiple reads provide better coverage of the solution space, increasing the diversity of the initial population and improving the chances of finding the global optimum. Default is None, which typically defaults to 1 or matches the number |
backend
class-attribute
instance-attribute
¶
fixed_temp_sampler_num_reads
class-attribute
instance-attribute
¶
fixed_temp_sampler_num_sweeps
class-attribute
instance-attribute
¶
model_config
class-attribute
instance-attribute
¶
get_compatible_backends
classmethod
¶
get_compatible_backends() -> tuple[type[DWave], ...]
Check at runtime if the used backend is compatible with the solver.
Returns:
Type | Description |
---|---|
tuple[type[IBackend], ...]
|
True if the backend is compatible with the solver, False otherwise. |
get_default_backend
classmethod
¶
get_default_backend() -> DWave
Return the default backend implementation.
This property must be implemented by subclasses to provide the default backend instance to use when no specific backend is specified.
Returns:
Type | Description |
---|---|
IBackend
|
An instance of a class implementing the IBackend interface that serves as the default backend. |
run ¶
run(
model: Model | str,
name: str | None = None,
backend: BACKEND_TYPE | None = None,
client: LunaSolve | str | None = None,
*args: Any,
**kwargs: Any,
) -> SolveJob
Run the configured solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model or str
|
The model to be optimized or solved. It could be an Model instance or a string identifier representing the model id. |
required |
name
|
str | None
|
If provided, the name of the job. Defaults to None. |
None
|
backend
|
BACKEND_TYPE | None
|
Backend to use for the solver. If not provided, the default backend is used. |
None
|
client
|
LunaSolve or str
|
The client interface used to interact with the backend services. If not provided, a default client will be used. |
None
|
*args
|
Any
|
Additional arguments that will be passed to the solver or client. |
()
|
**kwargs
|
Any
|
Additional keyword parameters for configuration or customization. |
{}
|
Returns:
Type | Description |
---|---|
SolveJob
|
The job object containing the information about the solve process. |