Code Monkey home page Code Monkey logo

dwave-tabu's People

Contributors

arcondello avatar joelpasvolsky avatar randomir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dwave-tabu's Issues

Need to make RTD public

Clicking on the RTD link:
image

Asks clicker to log in to RTDs. This is because it has not been set to public:

image

Default value of 1 for `scale_factor` means bad results bqms with non-integer biases

Though the parameter scale_factor is documented, the default behavior means casting all biases to int (not just rounding, but truncating the fractional part) which can be pathological for anything but very low precision problems.

A quick example (note I don't fully understand this as I would think it should produce random samples):

In [21]: tabu_sampler.sample_ising({0: 0.4}, {}, num_reads=100).record.energy.mean()                                                                                                     
Out[21]: 0.3999999999999999

scale_factor should probably be set internally in the sample method, determined by the bqm range of biases. I can't think of any use-case that requires exposing it (though please mention it if there is one!)

Initial states (raw data) converted in place to binary vartype

>>> import dimod, tabu
>>> 
>>> bqm = dimod.BQM.from_ising({}, {'ab': 1})
>>> 
>>> initial = dimod.SampleSet.from_samples_bqm([{'a': 1, 'b': -1}, {'a': -1, 'b': 1}], bqm)
>>> initial
SampleSet(rec.array([([ 1, -1], -1., 1), ([-1,  1], -1., 1)],
          dtype=[('sample', 'i1', (2,)), ('energy', '<f8'), ('num_occurrences', '<i8')]), ['a', 'b'], {}, 'SPIN')
>>> 
>>> ss = tabu.TabuSampler().sample(bqm, initial_states=initial)
>>> 
>>> initial
SampleSet(rec.array([([1, 0], -1., 1), ([0, 1], -1., 1)],
          dtype=[('sample', 'i1', (2,)), ('energy', '<f8'), ('num_occurrences', '<i8')]), ['a', 'b'], {}, 'SPIN')

Expected behavior: input initial states are not modified. Tabu solver works on a copy of input data.

Error Importing Tabu

Hello, I have been trying to import dwave tabu, but I have been experiencing some issues. When importing the package in python3, I get this result:

>>>import tabu
Traceback (most recent call last):
  File "/home/chip/.local/lib/python3.5/site-packages/tabu/tabu_search.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 914, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: /home/chip/.local/lib/python3.5/site-packages/tabu/_tabu_search.so: wrong ELF class: ELFCLASS64

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chip/.local/lib/python3.5/site-packages/tabu/__init__.py", line 17, in <module>
    from tabu.tabu_search import TabuSearch
  File "/home/chip/.local/lib/python3.5/site-packages/tabu/tabu_search.py", line 17, in <module>
    _tabu_search = swig_import_helper()
  File "/home/chip/.local/lib/python3.5/site-packages/tabu/tabu_search.py", line 16, in swig_import_helper
    return importlib.import_module('_tabu_search')
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_tabu_search' 

I suspect that the error has something to do with swig, but I am unsure what to do to resolve it. Any help would be greatly appreciated.
Thanks

fails to give global minima

I am trying to solve a qubo problem using dwave tabu. I am using the python interface with the following commands.
from tabu import TabuSampler response = TabuSampler().sample_qubo(Q) print(response.first.energy)
every time I run, I am getting different values of energy and solution. I am getting energy close to the global minimum, but not global minima.
whereas qbsolv command gives global minima every time. what is the problem or am I missing something?

TabuSampler fails for single variable BQMs

To reproduce:

>>> import tabu, dimod
>>> tabu.TabuSampler().sample(dimod.BinaryQuadraticModel({'a': 1}, {}, 0, dimod.SPIN))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/radomir/work/dwave-tabu/tabu/sampler.py", line 113, in sample
    raise ValueError("'tenure' should be an integer in range [1, num_vars - 1]")
ValueError: 'tenure' should be an integer in range [1, num_vars - 1]

Install via pip fails on Debian / Ubuntu

Hello team,


When I tried to install dwave-tabu via pip, following error occurred while building wheels. (I was instead able to install dwave-tabu by downloading this package and executing setup.py.)


Environment:
Debian 10, python3.9.4
Ubuntu 20.04LTS, python3.8.?


Error message:

aaa@bf6f91819798:~$ pip install --user dwave-tabu
Collecting dwave-tabu
 Using cached dwave-tabu-0.3.1.tar.gz (13 kB)
Requirement already satisfied: numpy>=1.16 in ./.local/lib/python3.8/site-packages (from dwave-tabu) (1.20.2)
Requirement already satisfied: dimod>=0.9.0 in ./.local/lib/python3.8/site-packages (from dwave-tabu) (0.9.14)
Building wheels for collected packages: dwave-tabu
 Building wheel for dwave-tabu (setup.py) ... error
 ERROR: Command errored out with exit status 1:
  command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-jd5wrh_u
    cwd: /tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/
 Complete output (10 lines):
 running bdist_wheel
 running build
 running build_py
 running build_ext
 building 'tabu._tabu_search' extension
 swigging tabu/tabu_search.i to tabu/tabu_search_wrap.cpp
 swig -python -c++ -threads -o tabu/tabu_search_wrap.cpp tabu/tabu_search.i
 tabu/tabu_search.i:64: Error: Unable to find 'src/tabu_search.h'
 tabu/tabu_search.i:65: Error: Unable to find 'src/common.h'
 error: command 'swig' failed with exit status 1
 ----------------------------------------
 ERROR: Failed building wheel for dwave-tabu
 Running setup.py clean for dwave-tabu
Failed to build dwave-tabu
Installing collected packages: dwave-tabu
  Running setup.py install for dwave-tabu ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-yv3utw4q/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/aaa/.local/include/python3.8/dwa
ve-tabu
     cwd: /tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/
  Complete output (10 lines):
  running install
  running build
  running build_py
  running build_ext
  building 'tabu._tabu_search' extension
  swigging tabu/tabu_search.i to tabu/tabu_search_wrap.cpp
  swig -python -c++ -threads -o tabu/tabu_search_wrap.cpp tabu/tabu_search.i
  tabu/tabu_search.i:64: Error: Unable to find 'src/tabu_search.h'
  tabu/tabu_search.i:65: Error: Unable to find 'src/common.h'
  error: command 'swig' failed with exit status 1
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import io, os, sys, setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b4uflvbe/dwave-tabu_c0236da9290741ef96501a7aa8984ebc/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-yv3utw4q/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/aaa/.local/include/python3.8/dwave-tabu Check the logs for full command output.

Install from source with `pip install .` (via `bdist_wheel`) fails

pip install . will run setup.py bdist_wheel in a temporary directory to build a wheel, which it then installs in the active environment.

The problem is that during wheel building, python extensions are packaged before the compiled extension:

$ pip install . -v
...
Building wheels for collected packages: dwave-tabu
  Created temporary directory: /tmp/pip-wheel-ix5vtkcy
  Running setup.py bdist_wheel for dwave-tabu ...   Destination directory: /tmp/pip-wheel-ix5vtkcy
  Running command /tmp/dwave-tabu/env/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-8pwxbv_n/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-ix5vtkcy --python-tag cp35
  running bdist_wheel
  running build
  running build_py
  file tabu/tabu_search.py (for module tabu.tabu_search) not found      <=== PROBLEM
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/tabu
  copying tabu/__init__.py -> build/lib.linux-x86_64-3.5/tabu
  copying tabu/package_info.py -> build/lib.linux-x86_64-3.5/tabu
  copying tabu/sampler.py -> build/lib.linux-x86_64-3.5/tabu
  file tabu/tabu_search.py (for module tabu.tabu_search) not found
  running build_ext
  building 'tabu._tabu_search' extension
  swigging tabu/tabu_search.i to tabu/tabu_search_wrap.cpp
  swig -python -c++ -threads -o tabu/tabu_search_wrap.cpp tabu/tabu_search.i
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/tabu
  creating build/temp.linux-x86_64-3.5/tabu/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Itabu/src -I/usr/include/python3.5m -I/tmp/dwave-tabu/env/include/python3.5m -c tabu/tabu_search_wrap.cpp -o build/temp.linux-x86_64-3.5/tabu/tabu_search_wrap.o
  ...

and tabu/tabu_search.py module is created by SWIG during extension compilation.

Overriding the build command seems to be a known workaround.

This bug causes failing doctests, on #44.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.