Skip to content
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

[QAOA] Small Changes to Cost Hamiltonians #741

Merged
merged 15 commits into from
Aug 7, 2020

Conversation

Lucaman99
Copy link
Contributor

Context:

Part of the ongoing addition of QAOA functionality to PennyLane

Description of the Change:

Makes some small changes to the pennylane/qaoa/cost.py file. Instead of returning just a cost Hamiltonian, the functions corresponding to each optimization problem will also return a mixer Hamiltonian that is "recommended" for each problem. This is motivated by the fact that in some instances, using the "recommended mixer is actually crucial to the algorithms success. In addition, there are instances where the mixer Hamiltonian that should be used for an optimization problem is highly non-trivial to construct, and is specific to one optimization problem.

The user would obtain the cost and mixer Hamiltonians as follows:

from pennylane import qaoa
from networkx import Graph

graph = Graph([(0, 1), (1, 2)])
cost_h, mixer_h = qaoa.maxcut(graph)

@codecov
Copy link

codecov bot commented Aug 5, 2020

Codecov Report

Merging #741 into master will increase coverage by 47.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #741       +/-   ##
===========================================
+ Coverage   48.50%   95.62%   +47.12%     
===========================================
  Files         111      111               
  Lines        6944     6945        +1     
===========================================
+ Hits         3368     6641     +3273     
+ Misses       3576      304     -3272     
Impacted Files Coverage Δ
pennylane/qaoa/cost.py 100.00% <100.00%> (+73.33%) ⬆️
...templates/subroutines/double_excitation_unitary.py 100.00% <0.00%> (+1.39%) ⬆️
pennylane/qnodes/passthru.py 83.78% <0.00%> (+2.70%) ⬆️
...templates/subroutines/single_excitation_unitary.py 100.00% <0.00%> (+2.94%) ⬆️
pennylane/numpy/wrapper.py 100.00% <0.00%> (+3.44%) ⬆️
pennylane/devices/default_qubit.py 98.31% <0.00%> (+5.88%) ⬆️
pennylane/templates/subroutines/uccsd.py 100.00% <0.00%> (+6.89%) ⬆️
pennylane/collections/map.py 100.00% <0.00%> (+8.00%) ⬆️
pennylane/vqe/vqe.py 78.26% <0.00%> (+8.69%) ⬆️
pennylane/ops/__init__.py 100.00% <0.00%> (+9.37%) ⬆️
... and 75 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 61bc47b...d067925. Read the comment docs.

Copy link
Member

@josh146 josh146 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great improvement!

@ixfoduap ixfoduap self-requested a review August 6, 2020 13:14
@josh146 josh146 merged commit 9d584f9 into PennyLaneAI:master Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants