-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add product of edge weight Hamiltonian and test #1209
Conversation
Hello. You may have forgotten to update the changelog!
|
Codecov Report
@@ Coverage Diff @@
## master #1209 +/- ##
=======================================
Coverage 98.13% 98.14%
=======================================
Files 146 146
Lines 11017 11035 +18
=======================================
+ Hits 10812 10830 +18
Misses 205 205
Continue to review full report at Codecov.
|
pennylane/qaoa/cycle.py
Outdated
if len(edges) != len(set(edges)): | ||
raise ValueError("Graph contains parallel edges") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be removed as parallel edges are not allowed for nx.DiGraphs
according to the documentation . A separate class nx.MultiDiGraph
must be used to support parallel edges
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @anthayes92! 💯 Code looks great, but I think we can polish the docstrings a bit more.
… into qaoa_cycles_module
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @anthayes92! 🚀 Would be good to add the following line to the changelog so we keep track of the PRs:
[(#1209)](https://github.com/PennyLaneAI/pennylane/pull/1209)
pennylane/qaoa/cycle.py
Outdated
>>> edge_weight_data = {edge: (i + 1) * 0.5 for i, edge in enumerate(g.edges)} | ||
>>> for k, v in edge_weight_data.items(): | ||
g[k[0]][k[1]]["weight"] = v | ||
>>>> h = loss_hamiltonian(g) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Would be good to also print it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added here: 104ec3f
Co-authored-by: Tom Bromley <49409390+trbromley@users.noreply.github.com>
This Hamiltonian holds the edge weight information that is used in the cost function during optimisation to find the max weighted cycle in the directed graph of interest.
Add function to generate this Hamiltonian.
In the unconstrained QAOA approach penalty terms are added to this Hamiltonian
In the constrained QAOA approach, the penalty complexity is added to the accompanying mixer Hamiltonian