eqc-models 0.9.8__tar.gz → 0.10.0__tar.gz

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.
Files changed (123) hide show
  1. {eqc_models-0.9.8/eqc_models.egg-info → eqc_models-0.10.0}/PKG-INFO +3 -2
  2. eqc_models-0.10.0/compile_extensions.py +67 -0
  3. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/pygments.css +18 -18
  4. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/assignment/setpartition.py +8 -29
  5. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/polyeval.c +123 -123
  6. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/polynomial.py +84 -1
  7. eqc_models-0.10.0/eqc_models/combinatorics/setcover.py +93 -0
  8. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/graph/base.py +28 -17
  9. eqc_models-0.10.0/eqc_models/graph/partition.py +148 -0
  10. eqc_models-0.10.0/eqc_models/ml/classifierqboost.py +628 -0
  11. eqc_models-0.10.0/eqc_models/ml/cvqboost_hamiltonian.pyx +83 -0
  12. eqc_models-0.10.0/eqc_models/ml/cvqboost_hamiltonian_c_func.c +68 -0
  13. eqc_models-0.10.0/eqc_models/ml/cvqboost_hamiltonian_c_func.h +14 -0
  14. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/sequence/tsp.py +38 -34
  15. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/solvers/qciclient.py +46 -11
  16. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/utilities/polynomial.py +11 -0
  17. {eqc_models-0.9.8 → eqc_models-0.10.0/eqc_models.egg-info}/PKG-INFO +3 -2
  18. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models.egg-info/SOURCES.txt +9 -0
  19. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models.egg-info/requires.txt +1 -0
  20. {eqc_models-0.9.8 → eqc_models-0.10.0}/pyproject.toml +1 -0
  21. eqc_models-0.10.0/scripts/graph_partitioning.py +21 -0
  22. eqc_models-0.10.0/test/testcvqboost.py +49 -0
  23. eqc_models-0.10.0/test/testgraphpartitionmodel.py +147 -0
  24. eqc_models-0.10.0/test/testpolynomialmodel.py +87 -0
  25. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testqciclientsolver.py +17 -2
  26. eqc_models-0.10.0/test/testsetcovermodel.py +25 -0
  27. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testsetpartitionmodel.py +20 -6
  28. eqc_models-0.9.8/compile_extensions.py +0 -23
  29. eqc_models-0.9.8/eqc_models/ml/classifierqboost.py +0 -423
  30. eqc_models-0.9.8/test/testpolynomialmodel.py +0 -32
  31. {eqc_models-0.9.8 → eqc_models-0.10.0}/.gitlab-ci.yml +0 -0
  32. {eqc_models-0.9.8 → eqc_models-0.10.0}/LICENSE.txt +0 -0
  33. {eqc_models-0.9.8 → eqc_models-0.10.0}/MANIFEST.in +0 -0
  34. {eqc_models-0.9.8 → eqc_models-0.10.0}/README.md +0 -0
  35. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/Makefile +0 -0
  36. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/basic.css +0 -0
  37. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/css/badge_only.css +0 -0
  38. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/css/theme.css +0 -0
  39. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/custom.css +0 -0
  40. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/file.png +0 -0
  41. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/minus.png +0 -0
  42. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/plus.png +0 -0
  43. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/build/html/_static/white_logo.png +0 -0
  44. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/make.bat +0 -0
  45. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/_static/custom.css +0 -0
  46. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/_static/white_logo.png +0 -0
  47. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/conf.py +0 -0
  48. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/dependencies.rst +0 -0
  49. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/eqc_models.rst +0 -0
  50. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/index.rst +0 -0
  51. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/modules.rst +0 -0
  52. {eqc_models-0.9.8 → eqc_models-0.10.0}/docs/source/usage.rst +0 -0
  53. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/__init__.py +0 -0
  54. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/algorithms/__init__.py +0 -0
  55. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/algorithms/base.py +0 -0
  56. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/algorithms/penaltymultiplier.py +0 -0
  57. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/allocation/__init__.py +0 -0
  58. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/allocation/allocation.py +0 -0
  59. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/allocation/portbase.py +0 -0
  60. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/allocation/portmomentum.py +0 -0
  61. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/assignment/__init__.py +0 -0
  62. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/assignment/qap.py +0 -0
  63. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/__init__.py +0 -0
  64. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/base.py +0 -0
  65. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/constraints.py +0 -0
  66. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/operators.py +0 -0
  67. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/polyeval.pyx +0 -0
  68. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/base/quadratic.py +0 -0
  69. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/decoding.py +0 -0
  70. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/graph/__init__.py +0 -0
  71. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/graph/hypergraph.py +0 -0
  72. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/graph/maxcut.py +0 -0
  73. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/graph/maxkcut.py +0 -0
  74. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/__init__.py +0 -0
  75. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/classifierbase.py +0 -0
  76. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/classifierqsvm.py +0 -0
  77. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/clustering.py +0 -0
  78. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/clusteringbase.py +0 -0
  79. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/decomposition.py +0 -0
  80. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/forecast.py +0 -0
  81. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/forecastbase.py +0 -0
  82. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/regressor.py +0 -0
  83. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/regressorbase.py +0 -0
  84. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/ml/reservoir.py +0 -0
  85. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/sequence/__init__.py +0 -0
  86. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/solvers/__init__.py +0 -0
  87. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/utilities/__init__.py +0 -0
  88. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/utilities/fileio.py +0 -0
  89. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models/utilities/qplib.py +0 -0
  90. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models.egg-info/dependency_links.txt +0 -0
  91. {eqc_models-0.9.8 → eqc_models-0.10.0}/eqc_models.egg-info/top_level.txt +0 -0
  92. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/binary_job_example.py +0 -0
  93. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/c6h6_graph_clustering.py +0 -0
  94. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/clustering.py +0 -0
  95. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/continuous_job_example.py +0 -0
  96. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/duality_example.py +0 -0
  97. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/graph_clustering.py +0 -0
  98. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/hamiltonian_to_polynomial.py +0 -0
  99. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/hypergraph.py +0 -0
  100. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/integer_job_example.py +0 -0
  101. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/karate_graph_clustering.py +0 -0
  102. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/lin_reg_dirac3.py +0 -0
  103. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/mackey_glass_cell_production_series.csv +0 -0
  104. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/pca_iris_dirac3.py +0 -0
  105. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/port_opt_dirac3.py +0 -0
  106. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/qboost_iris_dirac3.py +0 -0
  107. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/qplib_benchmark_config.py +0 -0
  108. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/qplib_reader.py +0 -0
  109. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/qplib_runner.py +0 -0
  110. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/qsvm_iris_dirac3.py +0 -0
  111. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/reservoir_forecast.py +0 -0
  112. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/rundoctests.py +0 -0
  113. {eqc_models-0.9.8 → eqc_models-0.10.0}/scripts/utils.py +0 -0
  114. {eqc_models-0.9.8 → eqc_models-0.10.0}/setup.cfg +0 -0
  115. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/doctest_base.py +0 -0
  116. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testallocationmodel.py +0 -0
  117. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testconstraint.py +0 -0
  118. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testeqcdirectsolver.py +0 -0
  119. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testhypergraphmodel.py +0 -0
  120. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testmaxcutmodel.py +0 -0
  121. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testqapmodel.py +0 -0
  122. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testquadraticmodel.py +0 -0
  123. {eqc_models-0.9.8 → eqc_models-0.10.0}/test/testtsp.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: eqc-models
3
- Version: 0.9.8
3
+ Version: 0.10.0
4
4
  Summary: Optimization and ML modeling package targeting EQC devices
5
5
  Author: Quantum Computing Inc.
6
6
  Author-email: support@quantumcomputinginc.com
@@ -13,6 +13,7 @@ License-File: LICENSE.txt
13
13
  Requires-Dist: numpy<2,>=1.22.1
14
14
  Requires-Dist: networkx<3,>=2.6.3
15
15
  Requires-Dist: pandas>=2.1.0
16
+ Requires-Dist: scikit-learn>=1.2.1
16
17
  Requires-Dist: qci-client<5,>=4.3.0
17
18
  Requires-Dist: emucore-direct==1.0.6
18
19
  Provides-Extra: direct
@@ -0,0 +1,67 @@
1
+ import os
2
+ import sys
3
+ from setuptools import Extension
4
+ from setuptools.command.build_py import build_py as _build_py
5
+ import numpy
6
+
7
+ # # Set cvqboost compile args
8
+ # if sys.platform == "darwin":
9
+ # openmp_prefix = os.environ.get(
10
+ # "LIBOMP_PREFIX", "/opt/homebrew/opt/libomp"
11
+ # )
12
+ # openmp_include = os.path.join(openmp_prefix, "include")
13
+ # openmp_lib = os.path.join(openmp_prefix, "lib", "libomp.a")
14
+ # extra_compile_args_cvq = [
15
+ # "-Xpreprocessor",
16
+ # "-fopenmp",
17
+ # "-O3",
18
+ # "-ffast-math",
19
+ # "-march=native",
20
+ # ]
21
+ # extra_link_args_cvq = [openmp_lib, "-O3", "-march=native"]
22
+ # elif sys.platform.startswith("linux"):
23
+ # extra_compile_args_cvq = [
24
+ # "-static-libgcc",
25
+ # "-fopenmp",
26
+ # "-O3",
27
+ # "-ffast-math",
28
+ # ]
29
+ # extra_link_args_cvq = [
30
+ # "-static-libgcc",
31
+ # "-static-libstdc++",
32
+ # "-fopenmp",
33
+ # "-O3",
34
+ # ]
35
+ # elif sys.platform == "win32":
36
+ # extra_compile_args_cvq = ["/openmp"]
37
+ # extra_link_args_cvq = []
38
+
39
+ # Modules to be compiled and include_dirs when necessary
40
+ extensions = [
41
+ Extension(
42
+ "eqc_models.base.polyeval",
43
+ ["eqc_models/base/polyeval.pyx"],
44
+ include_dirs=[numpy.get_include()],
45
+ extra_compile_args=["-O3", "-ffast-math"],
46
+ ),
47
+ # Extension(
48
+ # "eqc_models.ml.cvqboost_hamiltonian",
49
+ # ["eqc_models/ml/cvqboost_hamiltonian.pyx"],
50
+ # include_dirs=[numpy.get_include()],
51
+ # extra_compile_args=extra_compile_args_cvq,
52
+ # extra_link_args=extra_link_args_cvq,
53
+ # ),
54
+ ]
55
+
56
+
57
+ class build_py(_build_py):
58
+ def run(self):
59
+ self.run_command("build_ext")
60
+ return super().run()
61
+
62
+ def initialize_options(self):
63
+ super().initialize_options()
64
+ if self.distribution.ext_modules == None:
65
+ self.distribution.ext_modules = []
66
+
67
+ self.distribution.ext_modules.extend(extensions)
@@ -6,9 +6,9 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
6
6
  .highlight .hll { background-color: #ffffcc }
7
7
  .highlight { background: #f8f8f8; }
8
8
  .highlight .c { color: #3D7B7B; font-style: italic } /* Comment */
9
- .highlight .err { border: 1px solid #FF0000 } /* Error */
9
+ .highlight .err { border: 1px solid #F00 } /* Error */
10
10
  .highlight .k { color: #008000; font-weight: bold } /* Keyword */
11
- .highlight .o { color: #666666 } /* Operator */
11
+ .highlight .o { color: #666 } /* Operator */
12
12
  .highlight .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
13
13
  .highlight .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
14
14
  .highlight .cp { color: #9C6500 } /* Comment.Preproc */
@@ -25,34 +25,34 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
25
25
  .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
26
26
  .highlight .gs { font-weight: bold } /* Generic.Strong */
27
27
  .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
28
- .highlight .gt { color: #0044DD } /* Generic.Traceback */
28
+ .highlight .gt { color: #04D } /* Generic.Traceback */
29
29
  .highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
30
30
  .highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
31
31
  .highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
32
32
  .highlight .kp { color: #008000 } /* Keyword.Pseudo */
33
33
  .highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
34
34
  .highlight .kt { color: #B00040 } /* Keyword.Type */
35
- .highlight .m { color: #666666 } /* Literal.Number */
35
+ .highlight .m { color: #666 } /* Literal.Number */
36
36
  .highlight .s { color: #BA2121 } /* Literal.String */
37
37
  .highlight .na { color: #687822 } /* Name.Attribute */
38
38
  .highlight .nb { color: #008000 } /* Name.Builtin */
39
- .highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
40
- .highlight .no { color: #880000 } /* Name.Constant */
41
- .highlight .nd { color: #AA22FF } /* Name.Decorator */
39
+ .highlight .nc { color: #00F; font-weight: bold } /* Name.Class */
40
+ .highlight .no { color: #800 } /* Name.Constant */
41
+ .highlight .nd { color: #A2F } /* Name.Decorator */
42
42
  .highlight .ni { color: #717171; font-weight: bold } /* Name.Entity */
43
43
  .highlight .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
44
- .highlight .nf { color: #0000FF } /* Name.Function */
44
+ .highlight .nf { color: #00F } /* Name.Function */
45
45
  .highlight .nl { color: #767600 } /* Name.Label */
46
- .highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
46
+ .highlight .nn { color: #00F; font-weight: bold } /* Name.Namespace */
47
47
  .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
48
48
  .highlight .nv { color: #19177C } /* Name.Variable */
49
- .highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
50
- .highlight .w { color: #bbbbbb } /* Text.Whitespace */
51
- .highlight .mb { color: #666666 } /* Literal.Number.Bin */
52
- .highlight .mf { color: #666666 } /* Literal.Number.Float */
53
- .highlight .mh { color: #666666 } /* Literal.Number.Hex */
54
- .highlight .mi { color: #666666 } /* Literal.Number.Integer */
55
- .highlight .mo { color: #666666 } /* Literal.Number.Oct */
49
+ .highlight .ow { color: #A2F; font-weight: bold } /* Operator.Word */
50
+ .highlight .w { color: #BBB } /* Text.Whitespace */
51
+ .highlight .mb { color: #666 } /* Literal.Number.Bin */
52
+ .highlight .mf { color: #666 } /* Literal.Number.Float */
53
+ .highlight .mh { color: #666 } /* Literal.Number.Hex */
54
+ .highlight .mi { color: #666 } /* Literal.Number.Integer */
55
+ .highlight .mo { color: #666 } /* Literal.Number.Oct */
56
56
  .highlight .sa { color: #BA2121 } /* Literal.String.Affix */
57
57
  .highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
58
58
  .highlight .sc { color: #BA2121 } /* Literal.String.Char */
@@ -67,9 +67,9 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
67
67
  .highlight .s1 { color: #BA2121 } /* Literal.String.Single */
68
68
  .highlight .ss { color: #19177C } /* Literal.String.Symbol */
69
69
  .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
70
- .highlight .fm { color: #0000FF } /* Name.Function.Magic */
70
+ .highlight .fm { color: #00F } /* Name.Function.Magic */
71
71
  .highlight .vc { color: #19177C } /* Name.Variable.Class */
72
72
  .highlight .vg { color: #19177C } /* Name.Variable.Global */
73
73
  .highlight .vi { color: #19177C } /* Name.Variable.Instance */
74
74
  .highlight .vm { color: #19177C } /* Name.Variable.Magic */
75
- .highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
75
+ .highlight .il { color: #666 } /* Literal.Number.Integer.Long */
@@ -1,8 +1,9 @@
1
1
  from typing import List, Tuple, Dict, Union
2
2
  import numpy as np
3
3
  from eqc_models.base import ConstraintsMixIn, PolynomialModel
4
+ from eqc_models.base.polynomial import ConstrainedPolynomialModel
4
5
 
5
- class SetPartitionModel(ConstraintsMixIn, PolynomialModel):
6
+ class SetPartitionModel(ConstrainedPolynomialModel):
6
7
  """
7
8
  This class represents a set partitioning model for optimization problems that require selecting subsets
8
9
  to partition a universal set while minimizing an objective function defined by weights. Given a collection
@@ -83,24 +84,15 @@ class SetPartitionModel(ConstraintsMixIn, PolynomialModel):
83
84
  A.append(row)
84
85
  A = np.array(A)
85
86
  b = np.ones((A.shape[0],))
86
-
87
- # Define penalty terms
88
- J = A.T @ A
89
- h = -2 * b.T @ A
90
- n = h.shape[0]
91
- h = h.reshape((n, 1))
92
- offset = b.T @ b
93
-
94
- # Assign the constraints to the mixin's properties
95
- self.constraints = (A, b)
96
-
97
- # Initialize PolynomialModel with J and h, properly formatted as indices and coefficients
98
- indices, coefficients = self._construct_polynomial_terms(h, J)
99
- super().__init__(coefficients, indices)
87
+ n = A.shape[1]
100
88
 
101
89
  # Define the linear objective function based on subset weights
102
90
  self.linear_objective = np.array(weights).reshape((n, 1))
103
- self.quad_objective = np.zeros_like(J)
91
+ self.quad_objective = np.zeros((n, n)) #np.zeros_like(J)
92
+
93
+ # Initialize PolynomialModel with J and h, properly formatted as indices and coefficients
94
+ indices, coefficients = self._construct_polynomial_terms(self.linear_objective, self.quad_objective)
95
+ super().__init__(coefficients, indices, A, b)
104
96
 
105
97
  def _construct_polynomial_terms(self, h: np.ndarray, J: np.ndarray) -> Tuple[List[List[int]], List[np.ndarray]]:
106
98
  """
@@ -140,19 +132,6 @@ class SetPartitionModel(ConstraintsMixIn, PolynomialModel):
140
132
 
141
133
  return indices, coefficients
142
134
 
143
- @property
144
- def H(self) -> Tuple[np.ndarray, np.ndarray]:
145
- """
146
- Hamiltonian representation as a polynomial, returning the coefficients and indices.
147
-
148
- Returns
149
- -------
150
- Tuple[np.ndarray, np.ndarray]
151
- Tuple where the first element is an array of coefficients, and the second element
152
- is an array of indices, each representing polynomial terms for the Hamiltonian.
153
- """
154
- return self.coefficients, self.indices
155
-
156
135
  def evaluateObjective(self, solution: np.ndarray) -> float:
157
136
  """
158
137
  Evaluate the objective function by calculating the weighted sum of selected subsets.