dwavesystems / dimod Goto Github PK
View Code? Open in Web Editor NEWA shared API for QUBO/Ising samplers.
Home Page: https://docs.ocean.dwavesys.com/en/stable/docs_dimod/
License: Apache License 2.0
A shared API for QUBO/Ising samplers.
Home Page: https://docs.ocean.dwavesys.com/en/stable/docs_dimod/
License: Apache License 2.0
Except for getargspec
Should be collections.abc.Sized
as currently implemented.
Also could be collections.abc.Container
or even collections.abc.Collection
.
The documentation structure needs a major refactor.
Documentation is incomplete and a few NotImplementedErrors floating around
We would like to make the response object use numpy rather than pandas.
dimod.response.infer_vartype
expects sample values to be binary {0,1}
or {-1,1}
, but the real QPU/SAPI response also includes the "third state" for missing qubits.
We can filter those out (in dimod.Response.from_futures
) or support them (in infer_vartype
).
See also #135
The docstrings for the Sampler/Composite/Structured mixins should make clear that they have been inherited.
https://travis-ci.org/dwavesystems/dimod/jobs/348408848
Error: python 2.7.14 is already installed
To upgrade to 3.6.4_3, run `brew upgrade python`
Add tests for the examples and import the files directly (http://www.sphinx-doc.org/en/stable/markup/code.html#includes)
When testing dimod solvers in qbsolv I ran into an issue where the returned solution was missing variables that should have been present (although may have been zero on all biases/couplings).
It was with either the random or SA ones.
Line 11 in 6e1912d
It should at least be ruled out that it cannot be
Even if the documentation is incomplete - create the .rst
files for everything so that we can get an idea of the form.
Line 40 in 7b75e47
Making it be more than one thing requires the parser of the response to inspect the object before using it. If we want to have the benefits of a numpy array for some of the data_vectors, I think it's worth it to make everything a numpy array
If we don't need it to be a numpy array, might as well make them all lists?
docs/_build/
docs/reference/generated/
A clear documentation of the dimod API is needed.
Also, it would be good for dimod to expose a set of unittests that can be run for any response, sampler or composite that would verify that the API has been set up correctly. Right now there are GenericSamplerTests and GenericResponseTest classes, but they are not imported into dimod nor are they designed with only verifying the API in mind.
dwave_networkx currently implements min_vertex_cover, it would be relatively straightforward to generalize it to min_weighted_vertex_cover as in networkx.
Line 795 in e03cc88
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-980440423cf0> in <module>()
1 dwave_sampler = DWaveSampler(solver_name, url=url, token=token, permissive_ssl=True)
----> 2 nodelist, edgelist, _ = dwave_sampler.structure
/usr/local/lib/python2.7/site-packages/dimod/core/structured.pyc in structure(self)
114 def structure(self):
115 """A :class:`~collections.namedtuple` :samp:`Structure(nodelist, edgelist, adjacency)`"""
--> 116 return _Structure(self.nodelist, self.edgelist, self.adjacency)
/usr/local/lib/python2.7/site-packages/dimod/core/structured.pyc in adjacency(self)
104 for u, v in self.edgelist:
105 if v in adjacency[u]:
--> 106 raise ValueError("Each edge in edgelist must be unique")
107 adjacency[u].add(v)
108 adjacency[v].add(u)
ValueError: Each edge in edgelist must be unique
dimod/tests/test_binary_quadratic_model.py
Line 1501 in b0e1c9c
In tests raises a warning:
RuntimeWarning: '<' not supported between instances of 'int' and 'str', sort order is undefined for incomparable objects
self.assertAlmostEqual(bqm.energy(sample), sample_series.dot(bqm_df.dot(sample_series)))
A composite layer that rescales the Hamiltonian would add a lot of convenience. It would rescale the input Hamiltonian to fit within specified ranges, then reverse the rescaling so the energies match the original Hamiltonian.
I currently use the following function to rescale Hamiltonians, with an additional feature that allows clipping large values so that the Hamiltonian doesn't have to be scaled down as much (the tradeoff being that the Hamiltonian is not a faithful rescaling if clipping < 1).
def rescale(hh, jj, h_range, j_range, clipping=1.):
"""Rescale the Hamiltonian.
Clipping truncates values at a certain fraction of the provided range to lessen the
required compression.
"""
# Unpack the bounds.
min_h, max_h = map(float, h_range)
min_j, max_j = map(float, j_range)
# Find the natural rescaling factor
scalars = [
1.,
max([h / min_h for h in hh]),
max([h / max_h for h in hh]),
max([j / min_j for j in jj.values()]),
max([j / max_j for j in jj.values()]),
]
scalar = max(scalars)
# Adjust for clipping
scalar *= clipping
hh_scaled = [min_h if h/scalar <= min_h else max_h if h/scalar >= max_h else h/scalar for h in hh]
jj_scaled = {k: min_j if v/scalar <= min_j else max_j if v/scalar >= max_j else v/scalar for k, v in jj.iteritems()}
return hh_scaled, jj_scaled, scalar
In python 3.6
dimod/dimod/decorators.py:116: DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
Relevant documentation:
https://docs.python.org/3/library/inspect.html#inspect.getfullargspec
https://docs.python.org/3/library/inspect.html#inspect.getargspec
response.to_dataframe
etc
dimod/dimod/embedding/chain_breaks.py
Line 231 in 0f43963
This should be fixed or at least the docstring should state the limitation.
As a followup to #159
download_url is static, should use __version__
instead.
Line 20 in cfdb14e
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.