Comments (11)
Thanks for reporting this @riyasett . Would it be possible for you to share the code-snippet that produced this error so I can try to reproduce this on my end?
from grove.
from grove.
@riyasett I can't seem to find the notebook. Maybe github email filtered it out?
from grove.
Oh, I am extremely sorry. I sent you the notebook through email. I am attaching it here again.
I cannot attach the notebook (.ipynb) here...
from grove.
hmm .. I unfortunately still can't see the full code to reproduce the error. Can you turn the notebook into a small script that I can run? You can also copy-and-paste the code you are running into a comment here.
from grove.
import numpy as np
import pyquil.api as api
from pyquil.paulis import PauliTerm, PauliSum
import networkx as nx
from scipy.optimize import minimize
from grove.pyqaoa.qaoa import QAOA
CXN = api.SyncConnection()
def print_fun(x):
print(x)
def maxcut_qaoa(graph, steps=1, rand_seed=None, connection=None, samples=None,
initial_beta=None, initial_gamma=None, minimizer_kwargs=None,
vqe_option=None):
if not isinstance(graph, nx.Graph) and isinstance(graph, list):
maxcut_graph = nx.Graph()
for edge in graph:
maxcut_graph.add_edge(*edge)
graph = maxcut_graph.copy()
cost_operators = []
driver_operators = []
for i, j in graph.edges():
cost_operators.append(PauliTerm("Z", i, 0.5)*PauliTerm("Z", j) + PauliTerm("I", 0, -0.5))
for i in graph.nodes():
driver_operators.append(PauliSum([PauliTerm("X", i, -1.0)]))
if connection is None:
connection = CXN
if minimizer_kwargs is None:
minimizer_kwargs = {'method': 'Nelder-Mead',
'options': {'ftol': 1.0e-2, 'xtol': 1.0e-2,
'disp': False}}
if vqe_option is None:
vqe_option = {'disp': print_fun, 'return_all': True,
'samples': samples}
qaoa_inst = QAOA(connection, len(graph.nodes()), steps=steps, cost_ham=cost_operators,
ref_hamiltonian=driver_operators, store_basis=True,
rand_seed=rand_seed,
init_betas=initial_beta,
init_gammas=initial_gamma,
minimizer=minimize,
minimizer_kwargs=minimizer_kwargs,
vqe_options=vqe_option)
return qaoa_inst
Sample Run:
Cutting 0 - 1 - 2 graph!
inst = maxcut_qaoa([(0, 1), (1, 2)], steps=2, rand_seed=42, samples=None)
betas, gammas = inst.get_angles()
probs = inst.probabilities(np.hstack((betas, gammas)))
for state, prob in zip(inst.states, probs):
print(state, prob)
print("Most frequent bitstring from sampling")
most_freq_string, sampling_results = inst.get_string(
betas, gammas)
print(most_freq_string)
from grove.
Thanks @riyasett, this will help me in reproducing your error!
from grove.
from grove.
@riyasett we just pushed a fix to master for your problem #109. Thanks @jonathanward for this. We will have a release of Grove coming up soon that will contain this fix.
from grove.
from grove.
@riyasett You're welcome! We just pushed a new release of grove. v1.4.0 I hope your problem is fixed there. I'll close this ticket, but feel free to reopen if you encounter the issue again!
from grove.
Related Issues (20)
- Add type annotations to grove modules
- Make grove documentation pyQuil 2.0 compatible
- Make VQE/QAOA/ising modules pyQuil 2.0 compatible
- Make example notebooks pyQuil 2.0 compatible
- DeutschJosza has no business being a class
- IsingSolver probably doesn't work with noise models
- Inconsistent energy in maxcut_qaoa depending on samples argument
- Implementation of weighted Max-cut
- Bug when minimizer_kwargs is empty but the minimizer is not optimize.minimize
- Bug in vqe_run when disp = True
- 'QVMConnection' object has no attribute 'run_and_measure_async'
- master/docs/qaoa.rst is almost unintelligible because markup is not rendered HOT 4
- VQE documentation is out of date with code HOT 1
- Release 1.8.0 (or 2.0.0).
- Phase Estimation wont return eigenvectors that correspond to the eigenvalue
- maxcut notebook is broke HOT 1
- Problem with the 'return_all' parameter in the 'vqe_run'
- import error 'get_devices' HOT 1
- VQE on QVM with noise model not compatible
- Numpy required for setup?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grove.