luna-quantum 0.0.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of luna-quantum might be problematic. Click here for more details.

Files changed (160) hide show
  1. luna_quantum-0.0.16.dist-info/LICENSE +201 -0
  2. luna_quantum-0.0.16.dist-info/METADATA +46 -0
  3. luna_quantum-0.0.16.dist-info/RECORD +160 -0
  4. luna_quantum-0.0.16.dist-info/WHEEL +4 -0
  5. luna_sdk/__init__.py +2 -0
  6. luna_sdk/constants.py +1 -0
  7. luna_sdk/controllers/__init__.py +2 -0
  8. luna_sdk/controllers/custom_login_client.py +61 -0
  9. luna_sdk/controllers/luna_platform_client.py +62 -0
  10. luna_sdk/controllers/luna_q.py +36 -0
  11. luna_sdk/controllers/luna_solve.py +49 -0
  12. luna_sdk/controllers/luna_transform.py +41 -0
  13. luna_sdk/error/__init__.py +0 -0
  14. luna_sdk/error/http_error_utils.py +100 -0
  15. luna_sdk/exceptions/__init__.py +1 -0
  16. luna_sdk/exceptions/encryption_exception.py +6 -0
  17. luna_sdk/exceptions/luna_exception.py +7 -0
  18. luna_sdk/exceptions/luna_server_exception.py +18 -0
  19. luna_sdk/exceptions/timeout_exception.py +10 -0
  20. luna_sdk/exceptions/transformation.py +11 -0
  21. luna_sdk/interfaces/__init__.py +5 -0
  22. luna_sdk/interfaces/circuit_repo_i.py +62 -0
  23. luna_sdk/interfaces/clients/__init__.py +0 -0
  24. luna_sdk/interfaces/clients/client_i.py +10 -0
  25. luna_sdk/interfaces/clients/luna_q_i.py +39 -0
  26. luna_sdk/interfaces/clients/luna_solve_i.py +37 -0
  27. luna_sdk/interfaces/clients/luna_transform_i.py +33 -0
  28. luna_sdk/interfaces/cplex_repo_i.py +121 -0
  29. luna_sdk/interfaces/info_repo_i.py +40 -0
  30. luna_sdk/interfaces/lp_repo_i.py +106 -0
  31. luna_sdk/interfaces/optimization_repo_i.py +262 -0
  32. luna_sdk/interfaces/qpu_token_repo_i.py +151 -0
  33. luna_sdk/interfaces/repository_i.py +14 -0
  34. luna_sdk/interfaces/solutions_repo_i.py +219 -0
  35. luna_sdk/py.typed +0 -0
  36. luna_sdk/repositories/__init__.py +4 -0
  37. luna_sdk/repositories/circuit_repo.py +104 -0
  38. luna_sdk/repositories/cplex_repo.py +118 -0
  39. luna_sdk/repositories/info_repo.py +45 -0
  40. luna_sdk/repositories/lp_repo.py +105 -0
  41. luna_sdk/repositories/optimization_repo.py +358 -0
  42. luna_sdk/repositories/qpu_token_repo.py +226 -0
  43. luna_sdk/repositories/solutions_repo.py +347 -0
  44. luna_sdk/schemas/__init__.py +4 -0
  45. luna_sdk/schemas/circuit.py +43 -0
  46. luna_sdk/schemas/create/__init__.py +3 -0
  47. luna_sdk/schemas/create/circuit.py +29 -0
  48. luna_sdk/schemas/create/optimization.py +22 -0
  49. luna_sdk/schemas/create/qpu_token.py +26 -0
  50. luna_sdk/schemas/create/qubo.py +19 -0
  51. luna_sdk/schemas/create/solution.py +15 -0
  52. luna_sdk/schemas/enums/__init__.py +0 -0
  53. luna_sdk/schemas/enums/circuit.py +14 -0
  54. luna_sdk/schemas/enums/optimization.py +10 -0
  55. luna_sdk/schemas/enums/problem.py +48 -0
  56. luna_sdk/schemas/enums/qpu_token_type.py +6 -0
  57. luna_sdk/schemas/enums/solution.py +8 -0
  58. luna_sdk/schemas/enums/status.py +10 -0
  59. luna_sdk/schemas/enums/timeframe.py +11 -0
  60. luna_sdk/schemas/error_message.py +12 -0
  61. luna_sdk/schemas/optimization.py +75 -0
  62. luna_sdk/schemas/optimization_formats/__init__.py +0 -0
  63. luna_sdk/schemas/optimization_formats/bqm.py +34 -0
  64. luna_sdk/schemas/optimization_formats/cqm.py +127 -0
  65. luna_sdk/schemas/optimization_formats/lp.py +9 -0
  66. luna_sdk/schemas/optimization_formats/qm.py +30 -0
  67. luna_sdk/schemas/pretty_base.py +49 -0
  68. luna_sdk/schemas/qpu_token.py +60 -0
  69. luna_sdk/schemas/representation.py +19 -0
  70. luna_sdk/schemas/rest/__init__.py +0 -0
  71. luna_sdk/schemas/rest/qpu_token/__init__.py +0 -0
  72. luna_sdk/schemas/rest/qpu_token/token_provider.py +45 -0
  73. luna_sdk/schemas/solution.py +227 -0
  74. luna_sdk/schemas/solver_info.py +11 -0
  75. luna_sdk/schemas/solver_parameters/aws/__init__.py +1 -0
  76. luna_sdk/schemas/solver_parameters/aws/qaoa.py +24 -0
  77. luna_sdk/schemas/solver_parameters/dwave/__init__.py +72 -0
  78. luna_sdk/schemas/solver_parameters/dwave/base.py +409 -0
  79. luna_sdk/schemas/solver_parameters/dwave/dialectic_search.py +31 -0
  80. luna_sdk/schemas/solver_parameters/dwave/kerberos.py +71 -0
  81. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_bqm.py +19 -0
  82. luna_sdk/schemas/solver_parameters/dwave/leap_hybrid_cqm.py +22 -0
  83. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering.py +30 -0
  84. luna_sdk/schemas/solver_parameters/dwave/parallel_tempering_qpu.py +37 -0
  85. luna_sdk/schemas/solver_parameters/dwave/population_annealing.py +25 -0
  86. luna_sdk/schemas/solver_parameters/dwave/population_annealing_qpu.py +35 -0
  87. luna_sdk/schemas/solver_parameters/dwave/qaga.py +56 -0
  88. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_qpu.py +19 -0
  89. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_simulated_annealing.py +22 -0
  90. luna_sdk/schemas/solver_parameters/dwave/qbsolv_like_tabu_search.py +21 -0
  91. luna_sdk/schemas/solver_parameters/dwave/quantum_annealing.py +20 -0
  92. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_quantum_annealing.py +82 -0
  93. luna_sdk/schemas/solver_parameters/dwave/repeated_reverse_simulated_annealing.py +89 -0
  94. luna_sdk/schemas/solver_parameters/dwave/saga.py +61 -0
  95. luna_sdk/schemas/solver_parameters/dwave/simulated_annealing.py +74 -0
  96. luna_sdk/schemas/solver_parameters/dwave/tabu_search.py +72 -0
  97. luna_sdk/schemas/solver_parameters/fujitsu/__init__.py +20 -0
  98. luna_sdk/schemas/solver_parameters/fujitsu/base.py +47 -0
  99. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_cpu.py +129 -0
  100. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v2.py +149 -0
  101. luna_sdk/schemas/solver_parameters/fujitsu/digital_annealer_v3.py +150 -0
  102. luna_sdk/schemas/solver_parameters/fujitsu/partial_config.py +177 -0
  103. luna_sdk/schemas/solver_parameters/ibm/__init__.py +4 -0
  104. luna_sdk/schemas/solver_parameters/ibm/qaoa.py +64 -0
  105. luna_sdk/schemas/solver_parameters/ibm/standard_parameters.py +27 -0
  106. luna_sdk/schemas/solver_parameters/ibm/vqe.py +49 -0
  107. luna_sdk/schemas/solver_parameters/qctrl/__init__.py +1 -0
  108. luna_sdk/schemas/solver_parameters/qctrl/qaoa.py +47 -0
  109. luna_sdk/schemas/transformations/__init__.py +2 -0
  110. luna_sdk/schemas/transformations/bqm.py +33 -0
  111. luna_sdk/schemas/transformations/matrix.py +12 -0
  112. luna_sdk/schemas/use_cases/__init__.py +54 -0
  113. luna_sdk/schemas/use_cases/arbitrage_edge_based.py +49 -0
  114. luna_sdk/schemas/use_cases/arbitrage_node_based.py +54 -0
  115. luna_sdk/schemas/use_cases/base.py +5 -0
  116. luna_sdk/schemas/use_cases/binary_integer_linear_programming.py +53 -0
  117. luna_sdk/schemas/use_cases/binary_paint_shop_problem.py +36 -0
  118. luna_sdk/schemas/use_cases/credit_scoring_feature_selection.py +39 -0
  119. luna_sdk/schemas/use_cases/dynamic_portfolio_optimization.py +63 -0
  120. luna_sdk/schemas/use_cases/exact_cover.py +50 -0
  121. luna_sdk/schemas/use_cases/flight_gate_assignment.py +78 -0
  122. luna_sdk/schemas/use_cases/graph_coloring.py +41 -0
  123. luna_sdk/schemas/use_cases/graph_isomorphism.py +53 -0
  124. luna_sdk/schemas/use_cases/graph_partitioning.py +45 -0
  125. luna_sdk/schemas/use_cases/hamiltonian_cycle.py +48 -0
  126. luna_sdk/schemas/use_cases/induced_subgraph_isomorphism.py +49 -0
  127. luna_sdk/schemas/use_cases/job_shop_scheduling.py +43 -0
  128. luna_sdk/schemas/use_cases/k_medoids_clustering.py +48 -0
  129. luna_sdk/schemas/use_cases/knapsack_integer_weights.py +55 -0
  130. luna_sdk/schemas/use_cases/linear_regression.py +59 -0
  131. luna_sdk/schemas/use_cases/lmwcs.py +80 -0
  132. luna_sdk/schemas/use_cases/longest_path.py +49 -0
  133. luna_sdk/schemas/use_cases/market_graph_clustering.py +60 -0
  134. luna_sdk/schemas/use_cases/max2sat.py +51 -0
  135. luna_sdk/schemas/use_cases/max3sat.py +52 -0
  136. luna_sdk/schemas/use_cases/max_clique.py +59 -0
  137. luna_sdk/schemas/use_cases/max_cut.py +47 -0
  138. luna_sdk/schemas/use_cases/max_independent_set.py +36 -0
  139. luna_sdk/schemas/use_cases/minimal_maximal_matching.py +53 -0
  140. luna_sdk/schemas/use_cases/minimal_spanning_tree.py +87 -0
  141. luna_sdk/schemas/use_cases/minimum_vertex_cover.py +44 -0
  142. luna_sdk/schemas/use_cases/number_partitioning.py +31 -0
  143. luna_sdk/schemas/use_cases/portfolio_optimization.py +45 -0
  144. luna_sdk/schemas/use_cases/portfolio_optimization_ib_tv.py +62 -0
  145. luna_sdk/schemas/use_cases/quadratic_assignment.py +48 -0
  146. luna_sdk/schemas/use_cases/quadratic_knapsack.py +47 -0
  147. luna_sdk/schemas/use_cases/satellite_scheduling.py +72 -0
  148. luna_sdk/schemas/use_cases/sensor_placement.py +57 -0
  149. luna_sdk/schemas/use_cases/set_cover.py +55 -0
  150. luna_sdk/schemas/use_cases/set_packing.py +53 -0
  151. luna_sdk/schemas/use_cases/set_partitioning.py +51 -0
  152. luna_sdk/schemas/use_cases/subgraph_isomorphism.py +56 -0
  153. luna_sdk/schemas/use_cases/subset_sum.py +36 -0
  154. luna_sdk/schemas/use_cases/support_vector_machine.py +63 -0
  155. luna_sdk/schemas/use_cases/traffic_flow.py +34 -0
  156. luna_sdk/schemas/use_cases/travelling_salesman_problem.py +52 -0
  157. luna_sdk/schemas/use_cases/type_aliases.py +11 -0
  158. luna_sdk/schemas/use_cases/weighted_max_cut.py +36 -0
  159. luna_sdk/utils/__init__.py +0 -0
  160. luna_sdk/utils/qpu_tokens.py +52 -0
@@ -0,0 +1 @@
1
+ from .qaoa import QaoaParameters
@@ -0,0 +1,24 @@
1
+ from typing import Optional, List
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class QaoaParameters(BaseModel):
7
+ """
8
+ The Quantum Approximate Optimization Algorithm ([QAOA](https://arxiv.org/abs/1411.4028))
9
+ solves combinatorial optimization problems by approximating the solution.
10
+
11
+ The Quantum Approximate Optimization Algorithm (QAOA) belongs to the class of hybrid quantum algorithms
12
+ (leveraging both classical as well as quantum compute), that are widely believed to be the working horse
13
+ for the current NISQ (noisy intermediate-scale quantum) era. In this NISQ era QAOA is also an emerging
14
+ approach for benchmarking quantum devices and is a prime candidate for demonstrating a practical
15
+ quantum speed-up on near-term NISQ device.
16
+ """
17
+
18
+ aws_provider: str = ""
19
+ aws_device: str = ""
20
+ seed: Optional[int] = 385920
21
+ reps: Optional[int] = 1
22
+ initial_values: Optional[List[float]] = None
23
+ shots: Optional[int] = 1024
24
+ optimizer_params: Optional[dict] = None
@@ -0,0 +1,72 @@
1
+ """Solver Parameters"""
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave.base import (
4
+ DEFAULT_ATOL,
5
+ DEFAULT_MULTIPROCESSING_CPU_COUNT,
6
+ DEFAULT_RTOL,
7
+ DEFAULT_TIMEOUT,
8
+ DRAMATIQ_ACTOR_MAX_RETRIES,
9
+ AutoEmbeddingParams,
10
+ BaseSolver,
11
+ Decomposer,
12
+ Embedding,
13
+ EmbeddingParameters,
14
+ FixedTemperatureSampler,
15
+ Loop,
16
+ QBSOLVLike,
17
+ Qpu,
18
+ SamplingParams,
19
+ SimulatedAnnealing,
20
+ Tabu,
21
+ )
22
+ from luna_sdk.schemas.solver_parameters.dwave.dialectic_search import (
23
+ DialecticSearchParameters,
24
+ )
25
+ from luna_sdk.schemas.solver_parameters.dwave.kerberos import (
26
+ KerberosParameters,
27
+ TabuKerberos,
28
+ )
29
+ from luna_sdk.schemas.solver_parameters.dwave.leap_hybrid_bqm import (
30
+ LeapHybridBqmParameters,
31
+ )
32
+ from luna_sdk.schemas.solver_parameters.dwave.leap_hybrid_cqm import (
33
+ LeapHybridCqmParameters,
34
+ )
35
+ from luna_sdk.schemas.solver_parameters.dwave.parallel_tempering import (
36
+ ParallelTemperingParameters,
37
+ )
38
+ from luna_sdk.schemas.solver_parameters.dwave.parallel_tempering_qpu import (
39
+ ParallelTemperingQpuParameters,
40
+ )
41
+ from luna_sdk.schemas.solver_parameters.dwave.population_annealing import (
42
+ PopulationAnnealingParameters,
43
+ )
44
+ from luna_sdk.schemas.solver_parameters.dwave.population_annealing_qpu import (
45
+ PopulationAnnealingQpuParameters,
46
+ )
47
+ from luna_sdk.schemas.solver_parameters.dwave.qaga import QAGAParameters
48
+ from luna_sdk.schemas.solver_parameters.dwave.qbsolv_like_qpu import (
49
+ QbSolvLikeQpuParameters,
50
+ )
51
+ from luna_sdk.schemas.solver_parameters.dwave.qbsolv_like_simulated_annealing import (
52
+ QbSolvLikeSimulatedAnnealingParameters,
53
+ )
54
+ from luna_sdk.schemas.solver_parameters.dwave.qbsolv_like_tabu_search import (
55
+ QbSolvLikeTabuSearchParameters,
56
+ )
57
+ from luna_sdk.schemas.solver_parameters.dwave.quantum_annealing import (
58
+ QuantumAnnealingParameters,
59
+ )
60
+ from luna_sdk.schemas.solver_parameters.dwave.repeated_reverse_quantum_annealing import (
61
+ RepeatedReverseQuantumAnnealingParameters,
62
+ RRQuantumAnnealingSamplingParams,
63
+ )
64
+ from luna_sdk.schemas.solver_parameters.dwave.repeated_reverse_simulated_annealing import (
65
+ RepeatedReverseSimulatedAnnealingParameters,
66
+ RRSimulatedAnnealing,
67
+ )
68
+ from luna_sdk.schemas.solver_parameters.dwave.saga import SAGAParameters
69
+ from luna_sdk.schemas.solver_parameters.dwave.simulated_annealing import (
70
+ SimulatedAnnealingParameters,
71
+ )
72
+ from luna_sdk.schemas.solver_parameters.dwave.tabu_search import TabuSearchParameters
@@ -0,0 +1,409 @@
1
+ import multiprocessing as mp
2
+ from typing import Any, List, Mapping, Optional, Tuple, Union
3
+
4
+ from pydantic import BaseModel, Field
5
+ from typing_extensions import Literal
6
+
7
+ # The default absolute tolerance that should be used for `numpy.isclose(...)`
8
+ # calls. Equal to the default used in `numpy.isclose(..)`.
9
+ DEFAULT_ATOL: float = 1.0e-8
10
+
11
+ # The default relative tolerance that should be used for ``numpy.isclose(...)``
12
+ # calls. Equal to the default used in ``numpy.isclose(..)``.
13
+ DEFAULT_RTOL: float = 1.0e-5
14
+
15
+ # The default timeout used for solver run with a specified target.
16
+ # Number of seconds before routine halts. Default is 2592000 for dimod.qbsolv.
17
+ DEFAULT_TIMEOUT: int = 10
18
+
19
+
20
+ # The number of processes that should be used for parallel solving.
21
+ # Default is `mp.cpu_count()`.
22
+ DEFAULT_MULTIPROCESSING_CPU_COUNT: int = mp.cpu_count()
23
+
24
+ # The maximum retries of a dramatiq actor.
25
+ # Default is 0.
26
+ DRAMATIQ_ACTOR_MAX_RETRIES: int = 0
27
+
28
+
29
+ class BaseSolver(BaseModel):
30
+ timeout: Optional[Any] = None
31
+
32
+
33
+ class Tabu(BaseModel):
34
+ """
35
+ Parameters
36
+ ----------
37
+ num_reads: Optional[int]
38
+ Number of reads. Each read is generated by one run of the tabu algorithm. If
39
+ `num_reads` is not explicitly given, it is selected to match the number of
40
+ initial states given. If initial states are not provided, only one read is
41
+ performed.
42
+ tenure: Optional[int]
43
+ Tabu tenure, which is the length of the tabu list, or number of recently
44
+ explored solutions kept in memory. Default is a quarter of the number of problem
45
+ variables up to a maximum value of 20.
46
+ timeout: float
47
+ Maximum running time per read in milliseconds.
48
+ initial_states_generator: Literal['none', 'tile', 'random']
49
+ Defines the expansion of `initial_states` if fewer than `num_reads` are
50
+ specified:
51
+ 'none': if the number of initial states specified is smaller than `num_reads`,
52
+ raises ``ValueError``.
53
+ 'tile': reuses the specified initial states if fewer than `num_reads` or
54
+ truncates if greater.
55
+ 'random': expands the specified initial states with randomly generated states if
56
+ fewer than `num_reads` or truncates if greater.
57
+ """
58
+
59
+ num_reads: Optional[int] = None
60
+ tenure: Optional[int] = Field(default=None, le=20)
61
+ timeout: float = 100
62
+ initial_states_generator: Literal["none", "tile", "random"] = "random"
63
+
64
+
65
+ class SimulatedAnnealing(BaseModel):
66
+ """
67
+ Parameters
68
+ ----------
69
+ num_reads: Optional[int]
70
+ Number of reads. Each read is generated by one run of the simulated annealing
71
+ algorithm. If `num_reads` is not explicitly given, it is selected to match the
72
+ number of initial states given. If initial states are not provided, only one
73
+ read is performed.
74
+ num_sweeps: Optional[int]
75
+ Number of sweeps used in annealing.
76
+ beta_range: Union[List[float], Tuple[float, float], NoneType]
77
+ A 2-tuple defining the beginning and end of the beta schedule, where beta is the
78
+ inverse temperature. The schedule is applied linearly in beta. Default range is
79
+ set based on the total bias associated with each node.
80
+ beta_schedule_type: Literal['linear', 'geometric']
81
+ Beta schedule type, or how the beta values are interpolated between the given
82
+ 'beta_range'.
83
+ initial_states_generator: Literal['none', 'tile', 'random']
84
+ Defines the expansion of `initial_states` if fewer than `num_reads` are
85
+ specified:
86
+ 'none:' if the number of initial states specified is smaller than `num_reads`,
87
+ raises an error.
88
+ 'tile': reuses the specified initial states if fewer than `num_reads` or
89
+ truncates if greater.
90
+ 'random': expands the specified initial states with randomly generated states if
91
+ fewer than `num_reads` or truncates if greater.
92
+ """
93
+
94
+ num_reads: Optional[int] = None
95
+ num_sweeps: Optional[int] = 1_000
96
+ beta_range: Optional[Union[List[float], Tuple[float, float]]] = None
97
+ beta_schedule_type: Literal["linear", "geometric"] = "geometric"
98
+ initial_states_generator: Literal["none", "tile", "random"] = "random"
99
+
100
+
101
+ class Decomposer(BaseModel):
102
+ """
103
+ Parameters
104
+ ----------
105
+ size: int
106
+ Nominal number of variables in the subproblem. Actual subproblem can be smaller,
107
+ depending on other parameters (e.g. `min_gain`).
108
+ min_gain: Optional[float]
109
+ Minimum reduction required to BQM energy, given the current sample. A variable
110
+ is included in the subproblem only if inverting its sample value reduces energy
111
+ by at least this amount.
112
+ rolling: bool
113
+ If True, successive calls for the same problem (with possibly different samples)
114
+ produce subproblems on different variables, selected by rolling down the list of
115
+ all variables sorted by decreasing impact.
116
+ rolling_history: float
117
+ Fraction of the problem size, as a float in range 0.0 to 1.0, that should
118
+ participate in the rolling selection. Once reached, subproblem unrolling is
119
+ reset. Min: 0.0, Max: 1.0
120
+ silent_rewind: bool
121
+ If False, raises :exc:`EndOfStream` when resetting/rewinding the subproblem
122
+ generator upon the reset condition for unrolling.
123
+ traversal: Literal['energy', 'bfs', 'pfs']
124
+ Traversal algorithm used to pick a subproblem of `size` variables. Options are:
125
+ energy: Use the next `size` variables in the list of variables ordered by
126
+ descending energy impact.
127
+ bfs: Breadth-first traversal seeded by the next variable in the energy impact
128
+ list.
129
+ pfs: Priority-first traversal seeded by variables from the energy impact list,
130
+ proceeding with the variable on the search boundary that has the highest energy
131
+ impact.
132
+ """
133
+
134
+ size: int = 10
135
+ min_gain: Optional[float] = None
136
+ rolling: bool = True
137
+ rolling_history: float = Field(default=1.0, ge=0.0, le=1.0)
138
+ silent_rewind: bool = True
139
+ traversal: Literal["energy", "bfs", "pfs"] = "energy"
140
+
141
+
142
+ class FixedTemperatureSampler(BaseModel):
143
+ """
144
+ Parameters
145
+ ----------
146
+ num_sweeps: int
147
+ Number of sweeps for the sampler.
148
+ num_reads: Optional[int]
149
+ Number of reads for the sampler.
150
+ """
151
+
152
+ num_sweeps: int = 10_000
153
+ num_reads: Optional[int] = None
154
+
155
+
156
+ class EmbeddingParameters(BaseModel):
157
+ """
158
+ Parameters
159
+ ----------
160
+ max_no_improvement: int
161
+ Maximum number of failed iterations to improve the current solution, where each
162
+ iteration attempts to find an embedding for each variable of S such that it is
163
+ adjacent to all its neighbours.
164
+ random_seed: Optional[int]
165
+ Seed for the random number generator. If None, seed is set by `os.urandom()`.
166
+ timeout: int
167
+ Algorithm gives up after `timeout` seconds.
168
+ max_beta: Optional[float]
169
+ Qubits are assigned weight according to a formula (beta^n) where n is the number
170
+ of chains containing that qubit. This value should never be less than or equal
171
+ to 1. If None, `max_beta` is effectively infinite.
172
+ tries: int
173
+ Number of restart attempts before the algorithm stops. On D-WAVE 2000Q, a
174
+ typical restart takes between 1 and 60 seconds.
175
+ inner_rounds: Optional[int]
176
+ The algorithm takes at most this many iterations between restart attempts;
177
+ restart attempts are typically terminated due to `max_no_improvement`. If None,
178
+ `inner_rounds` is effectively infinite.
179
+ chainlength_patience: int
180
+ Maximum number of failed iterations to improve chain lengths in the current
181
+ solution, where each iteration attempts to find an embedding for each variable
182
+ of S such that it is adjacent to all its neighbours.
183
+ max_fill: Optional[int]
184
+ Restricts the number of chains that can simultaneously incorporate the same
185
+ qubit during the search. Values above 63 are treated as 63. If None, `max_fill`
186
+ is effectively infinite.
187
+ threads: int
188
+ Maximum number of threads to use. Note that the parallelization is only
189
+ advantageous where the expected degree of variables is significantly greater
190
+ than the number of threads. Min: 1.
191
+ return_overlap: bool
192
+ This function returns an embedding, regardless of whether or not qubits are used
193
+ by multiple variables. `return_overlap` determines the function's return value.
194
+ If True, a 2-tuple is returned, in which the first element is the embedding and
195
+ the second element is a bool representing the embedding validity. If False, only
196
+ an embedding is returned.
197
+ skip_initialization: bool
198
+ Skip the initialization pass. Note that this only works if the chains passed in
199
+ through `initial_chains` and `fixed_chains` are semi-valid. A semi-valid
200
+ embedding is a collection of chains such that every adjacent pair of variables
201
+ (u,v) has a coupler (p,q) in the hardware graph where p is in chain(u) and q is
202
+ in chain(v). This can be used on a valid embedding to immediately skip to the
203
+ chain length improvement phase. Another good source of semi-valid embeddings is
204
+ the output of this function with the `return_overlap` parameter enabled.
205
+ initial_chains: Any
206
+ Initial chains inserted into an embedding before `fixed_chains` are placed,
207
+ which occurs before the initialization pass. These can be used to restart the
208
+ algorithm in a similar state to a previous embedding; for example, to improve
209
+ chain length of a valid embedding or to reduce overlap in a semi-valid embedding
210
+ (see `skip_initialization`) previously returned by the algorithm. Missing or
211
+ empty entries are ignored. Each value in the dictionary is a list of qubit
212
+ labels.
213
+ fixed_chains: Any
214
+ Fixed chains inserted into an embedding before the initialization pass. As the
215
+ algorithm proceeds, these chains are not allowed to change, and the qubits used
216
+ by these chains are not used by other chains. Missing or empty entries are
217
+ ignored. Each value in the dictionary is a list of qubit labels.
218
+ restrict_chains: Any
219
+ Throughout the algorithm, it is guaranteed that chain[i] is a subset of
220
+ `restrict_chains[i]` for each i, except those with missing or empty entries.
221
+ Each value in the dictionary is a list of qubit labels.
222
+ suspend_chains: Any
223
+ This is a metafeature that is only implemented in the Python interface.
224
+ `suspend_chains[i]` is an iterable of iterables; for example,
225
+ `suspend_chains[i] = [blob_1, blob_2]`, with each blob_j an iterable of target
226
+ node labels.
227
+ This enforces the following:
228
+ for each suspended variable i,
229
+ for each blob_j in the suspension of i,
230
+ at least one qubit from blob_j will be contained in the chain for i
231
+ miminorminer accomplishes this through the following problem transformation for
232
+ each iterable blob_j in `suspend_chains[i]`,
233
+ Add an auxiliary node Zij to both source and target graphs
234
+ Set fixed_chains[Zij] = [Zij]
235
+ Add the edge (i,Zij) to the source graph
236
+ Add the edges (q,Zij) to the target graph for each q in blob_j
237
+ """
238
+
239
+ max_no_improvement: int = 10
240
+ random_seed: Optional[int] = None
241
+ timeout: int = 1_000
242
+ max_beta: Optional[float] = None
243
+ tries: int = 10
244
+ inner_rounds: Optional[int] = None
245
+ chainlength_patience: int = 10
246
+ max_fill: Optional[int] = None
247
+ threads: int = Field(default=1, ge=1)
248
+ return_overlap: bool = False
249
+ skip_initialization: bool = False
250
+ initial_chains: Any = ()
251
+ fixed_chains: Any = ()
252
+ restrict_chains: Any = ()
253
+ suspend_chains: Any = ()
254
+
255
+
256
+ class AutoEmbeddingParams(BaseModel):
257
+ """
258
+ Parameters
259
+ ----------
260
+ embedding_parameters: EmbeddingParameters
261
+ Embedding parameters for the auto embedding.
262
+ """
263
+
264
+ embedding_parameters: EmbeddingParameters = EmbeddingParameters()
265
+
266
+
267
+ class Embedding(BaseModel):
268
+ """
269
+ Parameters
270
+ ----------
271
+ chain_strength: Union[float, Mapping, NoneType]
272
+ Sets the coupling strength between qubits representing variables that form a
273
+ `chain`. Mappings should specify the required chain strength for each variable.
274
+ By default, `chain_strength` is calculated with
275
+ `~dwave.embedding.chain_strength.uniform_torque_compensation`.
276
+ chain_break_fraction: bool
277
+ Add a `chain_break_fraction` field to the unembedded response with the fraction
278
+ of chains broken before unembedding.
279
+ embedding_parameters: EmbeddingParameters
280
+ Embedding parameters for the embedding.
281
+ """
282
+
283
+ chain_strength: Optional[Union[float, Mapping]] = None
284
+ chain_break_fraction: bool = True
285
+ embedding_parameters: EmbeddingParameters = EmbeddingParameters()
286
+
287
+
288
+ class SamplingParams(BaseModel):
289
+ """
290
+ Parameters
291
+ ----------
292
+ anneal_offsets: Optional[Any]
293
+ Anneal offsets for the sampling.
294
+ anneal_schedule: Optional[Any]
295
+ Anneal schedule for the sampling.
296
+ annealing_time: Optional[Any]
297
+ Annealing time for the sampling.
298
+ auto_scale: Optional[Any]
299
+ Whether to auto scale for the sampling.
300
+ fast_anneal: bool
301
+ Use the fast-anneal protocol instead of the standard anneal.
302
+ flux_biases: Optional[Any]
303
+ Flux biases for the sampling.
304
+ flux_drift_compensation: bool
305
+ Whether to use flux drift compensation for the sampling.
306
+ h_gain_schedule: Optional[Any]
307
+ H gain schedule for the sampling.
308
+ initial_state: Optional[Any]
309
+ Initial state for the sampling.
310
+ max_answers: Optional[int]
311
+ Maximum number of answers for the sampling. Min: 1
312
+ num_reads: int
313
+ Number of reads for the sampling. Min: 1
314
+ programming_thermalization: Optional[float]
315
+ Programming thermalization for the sampling. Has to be positive.
316
+ readout_thermalization: Optional[float]
317
+ Readout thermalization for the sampling. Has to be positive.
318
+ reduce_intersample_correlation: bool
319
+ Whether to reduce intersample correlation for the sampling.
320
+ reinitialize_state: Optional[bool]
321
+ Whether to reinitialize state for the sampling. Should be `None` if
322
+ `initial_state` is `None`.
323
+ """
324
+
325
+ anneal_offsets: Optional[Any] = None
326
+ anneal_schedule: Optional[Any] = None
327
+ annealing_time: Optional[Any] = None
328
+ auto_scale: Optional[Any] = None
329
+ fast_anneal: bool = False
330
+ flux_biases: Optional[Any] = None
331
+ flux_drift_compensation: bool = True
332
+ h_gain_schedule: Optional[Any] = None
333
+ initial_state: Optional[Any] = None
334
+ max_answers: Optional[int] = Field(default=None, ge=1)
335
+ num_reads: int = Field(default=1, ge=1)
336
+ programming_thermalization: Optional[float] = Field(default=None, gt=0)
337
+ readout_thermalization: Optional[float] = Field(default=None, gt=0)
338
+ reduce_intersample_correlation: bool = False
339
+ reinitialize_state: Optional[bool] = None
340
+
341
+
342
+ class Qpu(BaseModel):
343
+ """
344
+ Parameters
345
+ ----------
346
+ num_reads: int
347
+ Number of states (output solutions) to read from the sampler.
348
+ num_retries: int
349
+ Number of times the sampler will retry to embed if a failure occurs.
350
+ sampling_params: SamplingParams
351
+ Sampling parameters for the QPU. See https://docs.dwavesys.com/docs/latest/c_solver_parameters.html
352
+ for more details.
353
+ auto_embedding_params: AutoEmbeddingParams
354
+ Auto embedding parameters for the QPU. See https://docs.ocean.dwavesys.com/projects/system/en/stable/reference/generated/minorminer.find_embedding.html
355
+ for more details.
356
+ """
357
+
358
+ num_reads: int = 100
359
+ num_retries: int = 0
360
+ sampling_params: SamplingParams = SamplingParams()
361
+ auto_embedding_params: AutoEmbeddingParams = AutoEmbeddingParams()
362
+
363
+
364
+ class Loop(BaseModel):
365
+ """
366
+ Parameters
367
+ ----------
368
+ max_iter: Optional[int]
369
+ Maximum number of iterations.
370
+ max_time: int
371
+ Time in seconds after which the algorithm will stop.
372
+ convergence: int
373
+ Number of iterations with unchanged output to terminate algorithm.
374
+ target: Optional[float]
375
+ Energy level that the algorithm tries to reach.
376
+ rtol: float
377
+ Relative tolerance for convergence.
378
+ atol: float
379
+ Absolute tolerance for convergence.
380
+ """
381
+
382
+ max_iter: Optional[int] = 100
383
+ max_time: int = 5
384
+ convergence: int = 3
385
+ target: Optional[float] = DEFAULT_RTOL
386
+ atol: float = DEFAULT_ATOL
387
+
388
+
389
+ class QBSOLVLike(BaseModel):
390
+ """
391
+ Parameters
392
+ ----------
393
+ decomposer_size: int
394
+ Size for the decomposer.
395
+ rolling: bool
396
+ Whether to use rolling for the solver.
397
+ rolling_history: float
398
+ Rolling history for the solver.
399
+ cpu_count_multiplier: int
400
+ CPU count multiplier for the solver.
401
+ loop: Loop
402
+ Parameters for the main loop of the algorithm.
403
+ """
404
+
405
+ decomposer_size: int = 50
406
+ rolling: bool = True
407
+ rolling_history: float = 0.15
408
+ cpu_count_multiplier: int = 1
409
+ loop: Loop = Loop()
@@ -0,0 +1,31 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+ from luna_sdk.schemas.solver_parameters.dwave import Decomposer, Loop, Tabu
6
+
7
+
8
+ class DialecticSearchParameters(BaseModel):
9
+ """
10
+ The Dialectic Search Solver uses a path search between two states representing the thesis and antithesis.
11
+ A greedy search is used to reduce the energy by applying bit flips in an attempt to find the solution.
12
+
13
+ decomposer: Decomposer
14
+ Decomposer parameters.
15
+ tabu_antithesis: Tabu
16
+ Tabu parameters for the antithesis phase.
17
+ tabu_synthesis: Tabu
18
+ Tabu parameters for the synthesis phase.
19
+ loop: Loop
20
+ Parameters for the main loop of the algorithm.
21
+ max_tries: Optional[int]
22
+ Maximum number of times the synthesis phase is run for the **same** input state.
23
+ On each improvement, the better state is used for the next input state, and the
24
+ try/trial counter is reset.
25
+ """
26
+
27
+ decomposer: Decomposer = Decomposer()
28
+ tabu_antithesis: Tabu = Tabu()
29
+ tabu_synthesis: Tabu = Tabu()
30
+ loop: Loop = Loop()
31
+ max_tries: Optional[int] = Field(default=100, ge=1)
@@ -0,0 +1,71 @@
1
+ from typing import Optional
2
+
3
+ from pydantic import BaseModel
4
+
5
+ from luna_sdk.schemas.solver_parameters.dwave import (
6
+ Decomposer,
7
+ Loop,
8
+ Qpu,
9
+ SimulatedAnnealing,
10
+ Tabu,
11
+ )
12
+
13
+
14
+ class TabuKerberos(Tabu):
15
+ """
16
+ num_reads: Optional[int]
17
+ Number of reads. Each read is generated by one run of the tabu algorithm. If
18
+ `num_reads` is not explicitly given, it is selected to match the number of
19
+ initial states given. If initial states are not provided, only one read is
20
+ performed.
21
+ tenure: Optional[int]
22
+ Tabu tenure, which is the length of the tabu list, or number of recently
23
+ explored solutions kept in memory. Default is a quarter of the number of problem
24
+ variables up to a maximum value of 20.
25
+ timeout: float
26
+ Timeout for non-interruptable operation of tabu search.
27
+ initial_states_generator: Literal['none', 'tile', 'random']
28
+ Defines the expansion of `initial_states` if fewer than `num_reads` are
29
+ specified:
30
+ 'none': if the number of initial states specified is smaller than `num_reads`,
31
+ raises `ValueError`.
32
+ 'tile': reuses the specified initial states if fewer than `num_reads` or
33
+ truncates if greater.
34
+ 'random': expands the specified initial states with randomly generated states if
35
+ fewer than `num_reads` or truncates if greater.
36
+ max_time: Optional[float]
37
+ Timeout for tabu search.
38
+ """
39
+
40
+ timeout: float = 20
41
+ max_time: Optional[float] = None
42
+
43
+
44
+ class KerberosParameters(BaseModel):
45
+ """
46
+ Kerberos divides the problem into subproblems and solves them using Tabu Search, Simulated Annealing and QPU Subproblem Sampling.
47
+ These algorithms are executed in parallel and afterwards the best solutions are combined.
48
+ This procedure is applied iteratively until the best solution is found or a termination criterion is met.
49
+
50
+ Parameters
51
+ ----------
52
+ tabu: TabuKerberos
53
+ Tabu parameters for Kerberos algorithm.
54
+ simulated_annealing: SimulatedAnnealing
55
+ Simulated annealing parameters for Kerberos algorithm.
56
+ decomposer: Decomposer
57
+ Decomposer parameters for Kerberos algorithm.
58
+ qpu: Qpu
59
+ QPU parameters for Kerberos algorithm.
60
+ loop: Loop
61
+ Parameters for the main loop of the algorithm.
62
+ cpu_count_multiplier: int
63
+ Multiplier for the CPU count.
64
+ """
65
+
66
+ tabu: TabuKerberos = TabuKerberos()
67
+ simulated_annealing: SimulatedAnnealing = SimulatedAnnealing()
68
+ decomposer: Decomposer = Decomposer()
69
+ qpu: Qpu = Qpu()
70
+ loop: Loop = Loop()
71
+ cpu_count_multiplier: int = 1
@@ -0,0 +1,19 @@
1
+ from typing import Optional, Union
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class LeapHybridBqmParameters(BaseModel):
7
+ """
8
+ Leap's quantum-classical hybrid solvers are intended to solve arbitrary application
9
+ problems formulated as quadratic models.
10
+ This solver accepts arbitrarily structured, unconstrained problems formulated as
11
+ BQMs, with any constraints typically represented through penalty models.
12
+
13
+ Parameters
14
+ ----------
15
+ time_limit: Union[float, int, NoneType]
16
+ The time limit for the solver.
17
+ """
18
+
19
+ time_limit: Optional[Union[float, int]] = None
@@ -0,0 +1,22 @@
1
+ from typing import List, Optional, Union
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class LeapHybridCqmParameters(BaseModel):
7
+ """
8
+ Leap's quantum-classical hybrid solvers are intended to solve arbitrary application
9
+ problems formulated as quadratic models.
10
+ This solver accepts arbitrarily structured problems formulated as CQMs, with any
11
+ constraints represented natively.
12
+
13
+ Parameters
14
+ ----------
15
+ time_limit: Union[float, int, NoneType]
16
+ The time limit for the solver.
17
+ spin_variables: Optional[List[str]]
18
+ The list of spin variables.
19
+ """
20
+
21
+ time_limit: Optional[Union[float, int]] = None
22
+ spin_variables: Optional[List[str]] = None
@@ -0,0 +1,30 @@
1
+ from pydantic import BaseModel
2
+
3
+ from luna_sdk.schemas.solver_parameters.dwave import FixedTemperatureSampler, Loop
4
+
5
+
6
+ class ParallelTemperingParameters(BaseModel):
7
+ """
8
+ Parallel Tempering uses multiple optimization procedures per temperature.
9
+ During the cooling process, an exchange of replicas can take place between the parallel procedures,
10
+ thus enabling higher energy mountains to be overcome.
11
+
12
+ Parameters
13
+ ----------
14
+ n_replicas: int
15
+ Number of replicas for the parallel tempering. Default is 2.
16
+ random_swaps_factor: int
17
+ Factor for random swaps. Default is 1.
18
+ fixed_temperature_sampler: FixedTemperatureSampler
19
+ Parameters for the fixed temperature sampler.
20
+ cpu_count_multiplier: int
21
+ Multiplier for the CPU count. Default is 5.
22
+ loop: Loop
23
+ Parameters for the main loop of the algorithm.
24
+ """
25
+
26
+ n_replicas: int = 2
27
+ random_swaps_factor: int = 1
28
+ fixed_temperature_sampler: FixedTemperatureSampler = FixedTemperatureSampler()
29
+ cpu_count_multiplier: int = 5
30
+ loop: Loop = Loop()