| Name | fasthare JSON |
| Version |
1.0.4
JSON |
| download |
| home_page | https://github.com/thang-dinh/FastHare |
| Summary | Reduce QUBO/Hamiltonian (exact reduction). Source code for the paper 'FastHare: Fast Hamiltonian Reduction for Large-scale Quantum Annealing, IEEE Int. Conf. on Quantum Computing and Engineering (QCE) 2022' https://arxiv.org/abs/2205.05004 |
| upload_time | 2024-09-11 05:10:45 |
| maintainer | None |
| docs_url | None |
| author | Thang Dinh/Phuc Thai |
| requires_python | >=3.10 |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
Python Interface for FastHare
Installation
------------
This requires Python 3.10+ and c++14
- clone this repository
- `pip install ./python_package`
Test
---------
```python
import fasthare as m
print("Using list of triples i, j, h_ij")
sk_ising = [(0, 1, -3)] # SK Hamiltonian: min - (-3 * x_0 * x_1 )
print(m.fasthare_reduction(sk_ising) )
# Or using the exp3.net in the "tests" folder
print("Reading triples i, j, h_ij from file")
rh, map, sign, time = m.fasthare_reduction(file ="exp3.net",alpha=0.2)
print(rh)
print(map)
print(sign)
print(time)
```
Output
```Python
Using list of triples i, j, h_ij
([], [0, 0], [1, -1], 1.9e-05)
Reading triples i, j, h_ij from file
[(0, 1, 1.0), (0, 2, 3.0), (1, 2, 3.0)]
[2, 2, 2, 2, 2, 2, 2, 1, 0, 1]
[1, -1, -1, 1, 1, 1, 1, 1, 1, 1]
4.4e-05
```
The output is a tuple of <compressed_hamiltonian, spin_mapping, spin_sign, running_time>.
+ compressed_hamiltonian: triples of (i, j, h_ij)
+ spin_mapping: The ith entry indicates which spin in the compressed hamiltonian that the ith spin in the input Hamiltonian mapped to
+ spin_sign: The ith entry is -1 if the ith spin in the input Hamiltonian is reversed (+1 otherwise)
+ running_time: run time in second(s)
Explanation for the output of "exp3.net"
| <span>exp3</span>.net |compressed_hamiltonian |spin_mapping/spin_sign |
|-----------------------|---------------------|-----------------|
| 10 14<br>0 1 -2<br>0 2 -4<br>1 2 2<br>1 3 -1<br>2 3 -6<br>3 4 3<br>4 5 4<br>4 6 4<br>5 6 -1<br>6 7 3<br>6 8 3<br>7 8 -1<br>7 9 3<br>8 9 2 |[(0, 1, 1.0),<br> (0, 2, 3.0),<br> (1, 2, 3.0)] |[2, 2, 2, 2, 2, 2, 2, 1, 0, 1]<br>[1, -1, -1, 1, 1, 1, 1, 1, 1, 1] |
| ... |Compressed into the below Hamiltonian with $n'=3$ nodes and $m'=3$ edges.<br> $\displaystyle\min_{\mathbf{x}\in\{-1,+1\}^3} -[ s_0 s_1 + 3 s_0 s_2 + 3 s_1 s_2]$ | $s_8= s_0'$<br>$s_9= s_7=s_1'$<br>$s_6= s_5=s_4 =s_3 = - s_2 = -s_1 = s_0= s_2'$ <br>The qubits $s_1$ and $s_2$ are *flipped* before the compression.
Remark: Since the version 1.0, the Hamiltonian will be compressed into a single node.
Raw data
{
"_id": null,
"home_page": "https://github.com/thang-dinh/FastHare",
"name": "fasthare",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Thang Dinh/Phuc Thai",
"author_email": "thangdn@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/77/fc/85557b0b27baf659b4fe4a90927bbfe96505d3088b3d27bf60253c50b06e/fasthare-1.0.4.tar.gz",
"platform": null,
"description": "Python Interface for FastHare\n\nInstallation\n------------\nThis requires Python 3.10+ and c++14\n\n - clone this repository\n - `pip install ./python_package`\n\nTest\n---------\n\n```python\nimport fasthare as m\nprint(\"Using list of triples i, j, h_ij\")\nsk_ising = [(0, 1, -3)] # SK Hamiltonian: min - (-3 * x_0 * x_1 )\nprint(m.fasthare_reduction(sk_ising) )\n\n\n# Or using the exp3.net in the \"tests\" folder\nprint(\"Reading triples i, j, h_ij from file\")\nrh, map, sign, time = m.fasthare_reduction(file =\"exp3.net\",alpha=0.2)\nprint(rh) \nprint(map)\nprint(sign)\nprint(time)\n```\nOutput\n\n```Python\nUsing list of triples i, j, h_ij\n([], [0, 0], [1, -1], 1.9e-05)\nReading triples i, j, h_ij from file\n[(0, 1, 1.0), (0, 2, 3.0), (1, 2, 3.0)]\n[2, 2, 2, 2, 2, 2, 2, 1, 0, 1]\n[1, -1, -1, 1, 1, 1, 1, 1, 1, 1]\n4.4e-05\n```\n\nThe output is a tuple of <compressed_hamiltonian, spin_mapping, spin_sign, running_time>.\n\n+ compressed_hamiltonian: triples of (i, j, h_ij)\n+ spin_mapping: The ith entry indicates which spin in the compressed hamiltonian that the ith spin in the input Hamiltonian mapped to\n+ spin_sign: The ith entry is -1 if the ith spin in the input Hamiltonian is reversed (+1 otherwise)\n+ running_time: run time in second(s)\n\nExplanation for the output of \"exp3.net\"\n\n\n\n| <span>exp3</span>.net\t|compressed_hamiltonian |spin_mapping/spin_sign |\n|-----------------------|---------------------|-----------------|\n| 10 14<br>0 1 -2<br>0 2 -4<br>1 2 2<br>1 3 -1<br>2 3 -6<br>3 4 3<br>4 5 4<br>4 6 4<br>5 6 -1<br>6 7 3<br>6 8 3<br>7 8 -1<br>7 9 3<br>8 9 2\t|[(0, 1, 1.0),<br> (0, 2, 3.0),<br> (1, 2, 3.0)] |[2, 2, 2, 2, 2, 2, 2, 1, 0, 1]<br>[1, -1, -1, 1, 1, 1, 1, 1, 1, 1] |\n| ...\t|Compressed into the below Hamiltonian with $n'=3$ nodes and $m'=3$ edges.<br> $\\displaystyle\\min_{\\mathbf{x}\\in\\{-1,+1\\}^3} -[ s_0 s_1 + 3 s_0 s_2 + 3 s_1 s_2]$\t | $s_8= s_0'$<br>$s_9= s_7=s_1'$<br>$s_6= s_5=s_4 =s_3 = - s_2 = -s_1 = s_0= s_2'$ <br>The qubits $s_1$ and $s_2$ are *flipped* before the compression. \n\nRemark: Since the version 1.0, the Hamiltonian will be compressed into a single node.\n",
"bugtrack_url": null,
"license": null,
"summary": "Reduce QUBO/Hamiltonian (exact reduction). Source code for the paper 'FastHare: Fast Hamiltonian Reduction for Large-scale Quantum Annealing, IEEE Int. Conf. on Quantum Computing and Engineering (QCE) 2022' https://arxiv.org/abs/2205.05004",
"version": "1.0.4",
"project_urls": {
"Homepage": "https://github.com/thang-dinh/FastHare"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dde20a2a085d4205413a7b0b365f30a3e837a0f39a74e8f69dc81c62cd6024ef",
"md5": "07a542542b10516fe0eee8ae5763b747",
"sha256": "b7d9b7ad2aa1f72b3ba1c9f8997e202643393a9c364631b4c7a38f9f99517cca"
},
"downloads": -1,
"filename": "fasthare-1.0.4-cp310-cp310-macosx_13_0_arm64.whl",
"has_sig": false,
"md5_digest": "07a542542b10516fe0eee8ae5763b747",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.10",
"size": 92019,
"upload_time": "2024-09-11T05:10:44",
"upload_time_iso_8601": "2024-09-11T05:10:44.196237Z",
"url": "https://files.pythonhosted.org/packages/dd/e2/0a2a085d4205413a7b0b365f30a3e837a0f39a74e8f69dc81c62cd6024ef/fasthare-1.0.4-cp310-cp310-macosx_13_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "77fc85557b0b27baf659b4fe4a90927bbfe96505d3088b3d27bf60253c50b06e",
"md5": "02d8283bfa4e84eb8ba0ec1a585ddc49",
"sha256": "31bc37570398a83a879dcab2480e60c111726b6fde6db334521272cc751fbad8"
},
"downloads": -1,
"filename": "fasthare-1.0.4.tar.gz",
"has_sig": false,
"md5_digest": "02d8283bfa4e84eb8ba0ec1a585ddc49",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 11361,
"upload_time": "2024-09-11T05:10:45",
"upload_time_iso_8601": "2024-09-11T05:10:45.602136Z",
"url": "https://files.pythonhosted.org/packages/77/fc/85557b0b27baf659b4fe4a90927bbfe96505d3088b3d27bf60253c50b06e/fasthare-1.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-11 05:10:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thang-dinh",
"github_project": "FastHare",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "fasthare"
}