eqc-models 0.9.8__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.
- eqc_models-0.9.8.data/platlib/compile_extensions.py +23 -0
- eqc_models-0.9.8.data/platlib/eqc_models/__init__.py +15 -0
- eqc_models-0.9.8.data/platlib/eqc_models/algorithms/__init__.py +4 -0
- eqc_models-0.9.8.data/platlib/eqc_models/algorithms/base.py +10 -0
- eqc_models-0.9.8.data/platlib/eqc_models/algorithms/penaltymultiplier.py +169 -0
- eqc_models-0.9.8.data/platlib/eqc_models/allocation/__init__.py +6 -0
- eqc_models-0.9.8.data/platlib/eqc_models/allocation/allocation.py +367 -0
- eqc_models-0.9.8.data/platlib/eqc_models/allocation/portbase.py +128 -0
- eqc_models-0.9.8.data/platlib/eqc_models/allocation/portmomentum.py +137 -0
- eqc_models-0.9.8.data/platlib/eqc_models/assignment/__init__.py +5 -0
- eqc_models-0.9.8.data/platlib/eqc_models/assignment/qap.py +82 -0
- eqc_models-0.9.8.data/platlib/eqc_models/assignment/setpartition.py +170 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/__init__.py +72 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/base.py +150 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/constraints.py +276 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/operators.py +201 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/polyeval.c +11363 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/polyeval.cpython-310-darwin.so +0 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/polyeval.pyx +72 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/polynomial.py +274 -0
- eqc_models-0.9.8.data/platlib/eqc_models/base/quadratic.py +250 -0
- eqc_models-0.9.8.data/platlib/eqc_models/decoding.py +20 -0
- eqc_models-0.9.8.data/platlib/eqc_models/graph/__init__.py +5 -0
- eqc_models-0.9.8.data/platlib/eqc_models/graph/base.py +63 -0
- eqc_models-0.9.8.data/platlib/eqc_models/graph/hypergraph.py +307 -0
- eqc_models-0.9.8.data/platlib/eqc_models/graph/maxcut.py +155 -0
- eqc_models-0.9.8.data/platlib/eqc_models/graph/maxkcut.py +184 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/__init__.py +15 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/classifierbase.py +99 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/classifierqboost.py +423 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/classifierqsvm.py +237 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/clustering.py +323 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/clusteringbase.py +112 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/decomposition.py +363 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/forecast.py +255 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/forecastbase.py +139 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/regressor.py +220 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/regressorbase.py +97 -0
- eqc_models-0.9.8.data/platlib/eqc_models/ml/reservoir.py +106 -0
- eqc_models-0.9.8.data/platlib/eqc_models/sequence/__init__.py +5 -0
- eqc_models-0.9.8.data/platlib/eqc_models/sequence/tsp.py +217 -0
- eqc_models-0.9.8.data/platlib/eqc_models/solvers/__init__.py +12 -0
- eqc_models-0.9.8.data/platlib/eqc_models/solvers/qciclient.py +707 -0
- eqc_models-0.9.8.data/platlib/eqc_models/utilities/__init__.py +6 -0
- eqc_models-0.9.8.data/platlib/eqc_models/utilities/fileio.py +38 -0
- eqc_models-0.9.8.data/platlib/eqc_models/utilities/polynomial.py +137 -0
- eqc_models-0.9.8.data/platlib/eqc_models/utilities/qplib.py +375 -0
- eqc_models-0.9.8.dist-info/LICENSE.txt +202 -0
- eqc_models-0.9.8.dist-info/METADATA +139 -0
- eqc_models-0.9.8.dist-info/RECORD +52 -0
- eqc_models-0.9.8.dist-info/WHEEL +5 -0
- eqc_models-0.9.8.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 Quantum Computing, Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: eqc-models
|
|
3
|
+
Version: 0.9.8
|
|
4
|
+
Summary: Optimization and ML modeling package targeting EQC devices
|
|
5
|
+
Author: Quantum Computing Inc.
|
|
6
|
+
Author-email: support@quantumcomputinginc.com
|
|
7
|
+
Project-URL: Homepage, https://quantumcomputinginc.com
|
|
8
|
+
Project-URL: Documentation, https://quantumcomputinginc.com/learn/support/software-packages/
|
|
9
|
+
Project-URL: Issues, https://support.quantumcomputinginc.com/
|
|
10
|
+
Requires-Python: <3.11,>=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE.txt
|
|
13
|
+
Requires-Dist: numpy<2,>=1.22.1
|
|
14
|
+
Requires-Dist: networkx<3,>=2.6.3
|
|
15
|
+
Requires-Dist: pandas>=2.1.0
|
|
16
|
+
Requires-Dist: qci-client<5,>=4.3.0
|
|
17
|
+
Requires-Dist: emucore-direct==1.0.6
|
|
18
|
+
Provides-Extra: direct
|
|
19
|
+
Requires-Dist: eqc-direct<2,>=1.3.0; extra == "direct"
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest<8,>=7.1.0; extra == "dev"
|
|
22
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
23
|
+
Requires-Dist: sphinx_rtd_theme<2,>=1.3.0; extra == "dev"
|
|
24
|
+
|
|
25
|
+
# EQC Models
|
|
26
|
+
|
|
27
|
+
## Quick Reference
|
|
28
|
+
|
|
29
|
+
### Installation
|
|
30
|
+
|
|
31
|
+
Install from the Python Package Index (PyPI) using
|
|
32
|
+
```bash
|
|
33
|
+
pip install eqc-models
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For pre-release and source versions, install `eqc-models` by extracting the source package and running
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install -e .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
from the folder with the `pyproject.toml` file. This will create an editable installation that is local to your user environment.
|
|
43
|
+
Certain optimizations require extension modules, in particular `eqc_models.base.polyeval`. This is a C extension produced from
|
|
44
|
+
a Cython module which evaluates polynomial expressions. Since there could be thousands of terms, the C extension can greatly
|
|
45
|
+
improve performance of some algorithms. Installing from source with pip will build the module.
|
|
46
|
+
|
|
47
|
+
### Modeling
|
|
48
|
+
|
|
49
|
+
Implement a model by selecting from the most appropriate model class from the available models
|
|
50
|
+
and pass the required data. The model classes are (in depth first order by hierarchy)
|
|
51
|
+
|
|
52
|
+
- `eqc_models.base.EQCModel`: a base class for all models
|
|
53
|
+
- `eqc_models.ml.classifierbase.ClassifierBase`: a base model for machine learning classifier models
|
|
54
|
+
- `eqc_models.ml.classifierqboost.QBoostClassifier`: a machine learning classifier model using QBoost
|
|
55
|
+
- `eqc_models.ml.classifierqsvm.QSVMClassifier`: a machine learning classifier model using QSVM
|
|
56
|
+
- `eqc_models.ml.communitydetection.CommunityDetectionModel`: a model for modeling community detection problems
|
|
57
|
+
- `eqc_models.base.QuadraticModel`: a base class for all models with up to quadratic terms
|
|
58
|
+
- `eqc_models.base.ConstrainedQuadraticModel`: a base class for all models with up to quadratic objective functions and linear equality constraints
|
|
59
|
+
- `eqc_models.base.PolynomialModel`: a base class for all models that utilize a polynomial formulation (up to fifth order)
|
|
60
|
+
- `eqc_models.allocation.AllocationModel`: an allocation model with equality resource constraints
|
|
61
|
+
- `eqc_models.allocation.AllocationModelX`: an allocation model with equality and inequality resource constraints
|
|
62
|
+
- `eqc_models.allocation.portmomentum.PortMomentum`: a portfolio allocation momentum model
|
|
63
|
+
- `eqc_models.portbase.PortBase`: a portfolio allocation base model
|
|
64
|
+
- `eqc_models.graph.MaxCutModel`: a maximum cut model
|
|
65
|
+
- `eqc_models.assignment.qap.QAPModel`: a quadratic assignment problem model
|
|
66
|
+
- `eqc_models.sequence.tsp.TSPModel`: a base class for TSP models
|
|
67
|
+
- `eqc_models.sequence.tsp.MTZTSPModel`: a traveling salesman model using the MTZ formulation
|
|
68
|
+
- `eqc_models.utilities.qplib.QGLModel`: a model based on `ConstrainedQuadraticModel` to solve problems
|
|
69
|
+
from qplib
|
|
70
|
+
|
|
71
|
+
### Solvers
|
|
72
|
+
|
|
73
|
+
The hierarchy of solvers uses `QciClient` from the `qci-client` package. Both Dirac-1 and Dirac-3 can be accessed using these solvers. Specific classes exist for the devices.
|
|
74
|
+
|
|
75
|
+
- `eqc_models.qciclientsolver.Dirac1CloudSolver`: A solver class that accesses Dirac-1 via the Qatalyst cloud service
|
|
76
|
+
- `eqc_models.qciclientsolver.Dirac3ContinuousCloudSolver`: A solver class for quasi-continuous models that accesses Dirac-3 via the Qatalyst cloud service
|
|
77
|
+
- `eqc_models.qciclientsolver.Dirac3IntegerCloudSolver`: A solver class for integer models that accesses Dirac-3 via the Qatalyst cloud service
|
|
78
|
+
|
|
79
|
+
### Using Classifier Models
|
|
80
|
+
|
|
81
|
+
Use of classification models is based on the well known pattern of fitting a model, then
|
|
82
|
+
using the fitted model to predict classifications. Here is a snippet from the `qsvm_iris_dirac3.py` script:
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
# Get QSVM model
|
|
86
|
+
obj = QSVMClassifier(
|
|
87
|
+
relaxation_schedule=2,
|
|
88
|
+
num_samples=1,
|
|
89
|
+
upper_limit=1.0,
|
|
90
|
+
gamma=1.0,
|
|
91
|
+
eta=1.0,
|
|
92
|
+
zeta=1.0,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Train
|
|
96
|
+
obj.fit(X_train, y_train)
|
|
97
|
+
|
|
98
|
+
y_train_prd = obj.predict(X_train)
|
|
99
|
+
y_test_prd = obj.predict(X_test)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Using Decision Optimization Models
|
|
103
|
+
|
|
104
|
+
Decision optimization models can be utilized by building a model, then passing the model to a solver's `solve` method. The following snippet of code is taken from the `qplib_runner.py` script.
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
# C, J are the linear and quadratic components of the expression
|
|
108
|
+
# A and b are left hand and right hand side values for linear constraints
|
|
109
|
+
# R is the summation constraint value for the Dirac-3 requirement
|
|
110
|
+
model = QGLModel(C, J, A, b)
|
|
111
|
+
domains = [R if types[j] == "REAL" else 1 for j in range(num_variables)]
|
|
112
|
+
model.domains = np.array(domains)
|
|
113
|
+
model.penalty_multiplier = alpha
|
|
114
|
+
# set the machine slacks to 1 to add a dummy variable to capture slack value from the summation constraint
|
|
115
|
+
model.machine_slacks = 1
|
|
116
|
+
print(f"Constructed model with R={R} alpha={alpha}")
|
|
117
|
+
solver = Dirac3CloudSolver()
|
|
118
|
+
print(f"Running model with relaxation_schedule={schedule}")
|
|
119
|
+
response = solver.solve(model, basename, sum_constraint=R, relaxation_schedule=schedule)
|
|
120
|
+
print(f"Energy {response['results']['energies'][0]}")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Design Overview
|
|
124
|
+
|
|
125
|
+
This package is designed around two central base classes. The first, `EqcModel`, includes the most basic common elements of an
|
|
126
|
+
optimization model. The second, `ModelSolver`, includes the most basic elements of a solver class. While not all classes in this package
|
|
127
|
+
inherit from one of these two classes, the core functionality exists in thie hierarchy. Additional things, such as algorithms and
|
|
128
|
+
supporting methods take advantage of these classes. Another design choice in the package is to utilize multiple inheritance and class
|
|
129
|
+
mixins for construction of functional classes. This design is not intended to impact the end user, who can simply instantiate a certain
|
|
130
|
+
model or solver class for usage. If a new model class is desired, the mixin design may be utilized to construct this new class.
|
|
131
|
+
Additionally, a hybrid solver could be implemented using this same design.
|
|
132
|
+
|
|
133
|
+
## Troubleshooting Common Errors
|
|
134
|
+
|
|
135
|
+
**No module named '_bz2'** This error occurs because NetworkX, a dependency of `eqc-models`, requires the bzip 2 library and it has not been found. On some linux environments, the OS package `libbzip2-dev` can be installed with apt or yum, then the python environment must be installed again.
|
|
136
|
+
|
|
137
|
+
## Further Information
|
|
138
|
+
|
|
139
|
+
Most of the classes in this package have doctests, see these docstrings for specific concrete examples. Also, the `scripts` and `test` directories have examples on modeling and solving with `eqc-models`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
eqc_models-0.9.8.data/platlib/compile_extensions.py,sha256=GNbNr9Pao2NwFUr29qEGrYSHvIlagnPcUqo3pgB5Trk,660
|
|
2
|
+
eqc_models-0.9.8.data/platlib/eqc_models/__init__.py,sha256=njh-tvfgnAIVBGw9FXFv6XQOAgwrnBG23dU9dipa1Jg,585
|
|
3
|
+
eqc_models-0.9.8.data/platlib/eqc_models/decoding.py,sha256=G3JgbIFzvZ3DIKW0kZ1JeTMIZmrc8hy9kzdbX2Xv5Og,637
|
|
4
|
+
eqc_models-0.9.8.data/platlib/eqc_models/algorithms/__init__.py,sha256=lzQoMMSs2QTqp5suEYNvcQaSEN16d0LwIsZ1mRstumU,135
|
|
5
|
+
eqc_models-0.9.8.data/platlib/eqc_models/algorithms/base.py,sha256=qfQQTwuVyewn7Qpg1_SVoD_7TsdA8vdwSKGqOeZSmNI,204
|
|
6
|
+
eqc_models-0.9.8.data/platlib/eqc_models/algorithms/penaltymultiplier.py,sha256=gV48irx3q9yvMsCRqv2fa8DGQEOUkgVNGbZdNzI-3Tc,7057
|
|
7
|
+
eqc_models-0.9.8.data/platlib/eqc_models/allocation/__init__.py,sha256=op_udrapTlWrakTuQId3M0ggo-Y1w4nGJLPcYKOQ-8I,239
|
|
8
|
+
eqc_models-0.9.8.data/platlib/eqc_models/allocation/allocation.py,sha256=PAQn4M75Zegeoy0i6r3hycWs4TKeRglHk05TvwZOoLk,15506
|
|
9
|
+
eqc_models-0.9.8.data/platlib/eqc_models/allocation/portbase.py,sha256=BTnYYduHydPbrE2yQr_Sgv3XJACH_GpIJstuMrfGqCU,3269
|
|
10
|
+
eqc_models-0.9.8.data/platlib/eqc_models/allocation/portmomentum.py,sha256=oMod63rNDC-01dLZjmhUb24SN3_GVgfc6CItgQL_obI,3756
|
|
11
|
+
eqc_models-0.9.8.data/platlib/eqc_models/assignment/__init__.py,sha256=CX_QYl8P1meajV8gcVs6hm07VhoLVe8uu436t7-1XQo,86
|
|
12
|
+
eqc_models-0.9.8.data/platlib/eqc_models/assignment/qap.py,sha256=WMiQQmTORsgi2w7kbmMA1xo-93dESLECWqYTF-zkmTs,2963
|
|
13
|
+
eqc_models-0.9.8.data/platlib/eqc_models/assignment/setpartition.py,sha256=pP61EFr-Vxk33ucMlyearjIqy8ktfy4hx1tL7JWrJeg,6792
|
|
14
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/__init__.py,sha256=RwZguuucmsuOSVqfPLBqj-wzinBOzcgO-2ifFU-DCqg,2885
|
|
15
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/base.py,sha256=kpnOb1dw0aaQyassIYKNlS6rIH1fNvZMI-NKPosAEMk,4856
|
|
16
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/constraints.py,sha256=KMPyCdt_8GMWLnVEdpzw1T1WqXm2f7Lh629ClUH7XDY,8271
|
|
17
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/operators.py,sha256=9nCeN6fRP-_YBfs-Gm57D-O_376qcOQiqGDuVlSlf00,7392
|
|
18
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/polyeval.c,sha256=ZcQAIL1Zfruop69C4HLjDJAq4TZp4OFkh83Kp8Bw5jk,438291
|
|
19
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/polyeval.cpython-310-darwin.so,sha256=M9cO90peu6w_cFqr5UYqPetgEu_huZH1H4UPpCidJE8,101136
|
|
20
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/polyeval.pyx,sha256=76Bf99Jt1_rLh5byrZxAjavE2F4_yCysirViqOBFIXw,2547
|
|
21
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/polynomial.py,sha256=gfEhkXAgFeRuml4Ufh3tDpgRvO9TwyKseqxHXjsxAGg,9246
|
|
22
|
+
eqc_models-0.9.8.data/platlib/eqc_models/base/quadratic.py,sha256=BHZKniUvSq30pZgzguVasdO39BCEYue_wi5AIklPGS8,8062
|
|
23
|
+
eqc_models-0.9.8.data/platlib/eqc_models/graph/__init__.py,sha256=Cpo4jb630U57J0lS_iZddE_W3v9N4ijUb7xZRIYuguo,95
|
|
24
|
+
eqc_models-0.9.8.data/platlib/eqc_models/graph/base.py,sha256=nYZCSCzshnuJKuc25M2YXcOqOhIa1-0R9rRbtIXDr84,1888
|
|
25
|
+
eqc_models-0.9.8.data/platlib/eqc_models/graph/hypergraph.py,sha256=ABvutT0NOdIEpUF4TjUzboE4Y_J5iUZyj6-AzKr4R28,13268
|
|
26
|
+
eqc_models-0.9.8.data/platlib/eqc_models/graph/maxcut.py,sha256=o8xVsAwTa9jcpmsIoCQ5z7HSstVdraT8TENomdT519o,4132
|
|
27
|
+
eqc_models-0.9.8.data/platlib/eqc_models/graph/maxkcut.py,sha256=OFZwmC3wWpIJWVHOb9wkUeka0g0bOHrwf-mx0VZvt58,5807
|
|
28
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/__init__.py,sha256=CLfraacr0FrD5ynxlNB6cyNy0lpbavcQT45TvkDrNvY,369
|
|
29
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/classifierbase.py,sha256=1yXufiUGpaiBjI2evMiwfYn-Zr-SnWwCnvtREqprtJw,2184
|
|
30
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/classifierqboost.py,sha256=REfAVIWDTDbshObBGoH-9QdOHVnt-OCGjh-lRNwI2HU,12350
|
|
31
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/classifierqsvm.py,sha256=b6TdwlghR84UoQpfUThwMwNF_wmkABbCqOn6T1uY2dA,6636
|
|
32
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/clustering.py,sha256=yhh6jlgwZiQVn9h2pnYBlzVTCocK7rzsEurSQxCn5FQ,9486
|
|
33
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/clusteringbase.py,sha256=AvQbt6jeocBAGCuAmXHKyr3wLWqYUtBDq9PbsEOSlSc,2632
|
|
34
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/decomposition.py,sha256=Nsnq0GmINpbGOszndgCHXqKdECNpiNiampBrHPU_Gjg,8943
|
|
35
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/forecast.py,sha256=fFcBxQK9ZryfEuyvlr9HXicHoZRzLFybimYYttzhI9E,7403
|
|
36
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/forecastbase.py,sha256=s-6nUMvtYqG07r7MmmkFVj8_QqgeGkD-HVoEEDTE2bk,3654
|
|
37
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/regressor.py,sha256=LA1woXCnefG0wfoOxilX1kszgCUmfNcbQgs_WZ4Ai0o,5683
|
|
38
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/regressorbase.py,sha256=H5E8-8pUji1oH5JRdS37LJQoHuKt2JU8eXCZp-ZaEM4,2109
|
|
39
|
+
eqc_models-0.9.8.data/platlib/eqc_models/ml/reservoir.py,sha256=cPRvpCaWLYTBkui35jCssHcOPQgSQZallrG6Ac9djVI,2827
|
|
40
|
+
eqc_models-0.9.8.data/platlib/eqc_models/sequence/__init__.py,sha256=VXlYufO3GYFsM00oii9Cite2WsQEF8XTwRcjLPH_Zlg,92
|
|
41
|
+
eqc_models-0.9.8.data/platlib/eqc_models/sequence/tsp.py,sha256=O3_gcPM-5XDvz9TZ4gJxZBDuSwq_agDTTf-7fCYx2_g,7533
|
|
42
|
+
eqc_models-0.9.8.data/platlib/eqc_models/solvers/__init__.py,sha256=hTjJI4F0FNDgQlK_oRHJxLIkg6of3I1-nEqU_3RL4Gk,542
|
|
43
|
+
eqc_models-0.9.8.data/platlib/eqc_models/solvers/qciclient.py,sha256=BElwvOgyequLIwjHhG-k-pWmPE5Ci1Gl2HJMszVIdMk,25154
|
|
44
|
+
eqc_models-0.9.8.data/platlib/eqc_models/utilities/__init__.py,sha256=SI2U7JKmPWSiq-F1WcSyfd7l9V6nbOZv_p8quMAZaT0,340
|
|
45
|
+
eqc_models-0.9.8.data/platlib/eqc_models/utilities/fileio.py,sha256=alWPTfjGFx6Iio9HZAAWtYcLmZsBBifg6S6_YbFMQhk,1088
|
|
46
|
+
eqc_models-0.9.8.data/platlib/eqc_models/utilities/polynomial.py,sha256=WoEBUAyiYBjwPvFWEjsynfmiBsbNqveKDZjXqiNQ6dk,4283
|
|
47
|
+
eqc_models-0.9.8.data/platlib/eqc_models/utilities/qplib.py,sha256=Do-MjmCFdI5HyDOAjfoz4_5lugySLMBlMAWDLUWx2OA,15796
|
|
48
|
+
eqc_models-0.9.8.dist-info/LICENSE.txt,sha256=8eh0oqsNNVR1Jk-13gkqRRSo2axtUU5kp2KzH4f9u3U,11354
|
|
49
|
+
eqc_models-0.9.8.dist-info/METADATA,sha256=q8NX9Ovrbqltb8VEQxJu_MFT8gLNfd8-2Kn_UxE9bss,7071
|
|
50
|
+
eqc_models-0.9.8.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
51
|
+
eqc_models-0.9.8.dist-info/top_level.txt,sha256=9ZfFeKNEvkRlKWoUnfcZ9TzmTdgdsuPEnTPy11Hqf4Q,30
|
|
52
|
+
eqc_models-0.9.8.dist-info/RECORD,,
|