openjij / openjij Goto Github PK
View Code? Open in Web Editor NEWOpenJij : Framework for the Ising model and QUBO.
Home Page: https://www.openjij.org/
License: Apache License 2.0
OpenJij : Framework for the Ising model and QUBO.
Home Page: https://www.openjij.org/
License: Apache License 2.0
SASamplerにおけるstep_num, iterationによる異常な振る舞い
SASamplerに古い引数であるstep_numをiterationの値を代入することができました。
その場合に、計算結果のベンチマークをとると正しい値になりません。
macOS 10.14
openjij/sampler/sa_sampler.pyの__init__の修正
iteration で複数回 annealing したときにスピンの状態を初期化していないので、前のアニーリングの結果に引きずられているっぽい。ちゃんと初期化しないといけない。
c++側で初期化メソッドを作るか、python側でiterationのたびにcxxjij.graph.Graphインスタンスを再生性しないいけない。
変数を固定する機能 0 or 1 に変数を固定して投げるための機能の追加
fix gen_spin for controling seeds
#include "graph.h"
#include <cassert>
#include <random>
namespace openjij {
namespace graph {
const Spins Graph::gen_spin(bool random_initialize) const{
// TODO: gen_spin(bool random_initialize, int seed) const{
//generate spin array
Spins ret_spin(num_spins);
if(random_initialize){
std::random_device rd;
auto mt = std::mt19937(rd());
std::uniform_int_distribution<> unif(0, 1);
for(auto& elem : ret_spin){
elem = 2*unif(mt)-1;
}
}
else{
...
in SQASampler, I could not change value of gamma, that is always one.
Describe the bug
CSQASampler()
causes the NoneType-related error.
To Reproduce
>>> import openjij as oj
>>> h = {0: -1, 1: -1, 2: 1, 3: 1}
>>> J = {(0, 1): -1, (3, 4): -1}
>>> sampler = oj.CSQASampler()
>>> res = sampler.sample_ising(h, J)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/openjij/sampler/csqa_sampler.py", line 103, in sample_ising
self._annealing_schedule_setting(
File "/usr/local/lib/python3.9/site-packages/openjij/sampler/sqa_sampler.py", line 228, in _annealing_schedule_setting
self._schedule, beta_gamma = quartic_ising_schedule(
File "/usr/local/lib/python3.9/site-packages/openjij/sampler/sqa_sampler.py", line 270, in quartic_ising_schedule
s = np.linspace(0, 1, num_sweeps)
File "<__array_function__ internals>", line 5, in linspace
File "/usr/local/lib/python3.9/site-packages/numpy/core/function_base.py", line 120, in linspace
num = operator.index(num)
TypeError: 'NoneType' object cannot be interpreted as an integer
Expected behavior
Environment (please complete the following information):
Additional context
I can't install openjij by pip.
$pip install openjij
Could not find a version that satisfies the requirement openjij (from versions: )
No matching distribution found for openjij
Odd number of trotter slices results in undefined behavior (all spin values are set to 0).
chimera = cj.graph.Chimera(2,2, init_val=-0.5)
method = cj.method.ChimeraGPUQuantum(chimera, num_trotter_slices=3)
method.simulated_quantum_annealing(10.0, 0.1, 10.0, 5, 10)
res = method.get_spins()
for r in res:
print(r)
# [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
# [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
add Chimera nodelist as function or member
python setup.py test
command fails under the latest version of gcc.
gcc-libs ((before)9.3.0-1 -> (after)10.1.0-2)
gcc ((before)9.3.0-1 -> (after)10.1.0-2)
gcc-fortran ((before)9.3.0-1 -> (after)10.1.0-2)
test_benchmark (tests.test_utils.TestUtils) ... ok
test_str_key_success_prob (tests.test_utils.TestUtils) ... ok
test_var_type (tests.test_utils.TestUtils) ... ok
test_csqa (tests.test_sampler.TestSamplers) ... FAIL
test_sa (tests.test_sampler.TestSamplers) ... ok
test_sqa (tests.test_sampler.TestSamplers) ... ok
test_bqm (tests.test_model.ModelTest) ... ok
test_bqm_calc_energy (tests.test_model.ModelTest) ... ok
test_bqm_constructor (tests.test_model.ModelTest) ... ok
test_chimera (tests.test_model.ModelTest) ... ok
test_chimera_converter (tests.test_model.ModelTest) ... ok
test_energy_consistency (tests.test_model.ModelTest) ... ok
test_get_chimera_graph (tests.test_model.ModelTest) ... ok
test_interaction_matrix (tests.test_model.ModelTest) ... ok
test_ising_dict (tests.test_model.ModelTest) ... ok
test_king_graph (tests.test_model.ModelTest) ... ok
test_transfer_to_cxxjij (tests.test_model.ModelTest) ... ok
test_variable_type (tests.test_model.VariableTypeTest) ... ok
test_ContinuousTimeSwendsenWang_ContinuousTimeIsing_Sparse (tests.test.CXXTest) ... FAIL
test_SingleSpinFlip_ClassicalIsing_Dense (tests.test.CXXTest) ... ok
test_SingleSpinFlip_ClassicalIsing_Sparse (tests.test.CXXTest) ... ok
test_SingleSpinFlip_TransverseIsing_Dense (tests.test.CXXTest) ... ok
test_SingleSpinFlip_TransverseIsing_Sparse (tests.test.CXXTest) ... ok
test_SwendsenWang_ClassicalIsing_Sparse (tests.test.CXXTest) ... ok
test_hubo_sampling (tests.test_hubo.HUBOTest) ... ok
======================================================================
FAIL: test_csqa (tests.test_sampler.TestSamplers)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jiko/workspace/Jij/openjij/OpenJij/tests/test_sampler.py", line 120, in test_csqa
self.samplers(sampler,
File "/home/jiko/workspace/Jij/openjij/OpenJij/tests/test_sampler.py", line 48, in samplers
self._test_response(res, self.e_q, self.ground_q)
File "/home/jiko/workspace/Jij/openjij/OpenJij/tests/test_sampler.py", line 53, in _test_response
self.assertListEqual(s_g, list(res.states[0]))
AssertionError: Lists differ: [1, 1, 0, 0, 0] != [1, 1, 0, 0, 1]
First differing element 4:
0
1
- [1, 1, 0, 0, 0]
? ^
+ [1, 1, 0, 0, 1]
? ^
======================================================================
FAIL: test_ContinuousTimeSwendsenWang_ContinuousTimeIsing_Sparse (tests.test.CXXTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jiko/workspace/Jij/openjij/OpenJij/tests/test.py", line 291, in test_ContinuousTimeSwendsenWang_ContinuousTimeIsing_Sparse
self.assertTrue(self.true_groundstate == result_spin)
AssertionError: False is not true
----------------------------------------------------------------------
Ran 25 tests in 4.749s
In the current version, the GPU system must be initialized with the Graph type with the suffix "GPU".
GPU system should be initialized with the Graph type the same as CPU.
before
system = S.make_xxx_ising_gpu(self.dense.gen_spin(self.seed_for_spin), self.denseGPU)
after
system = S.make_xxx_ising_gpu(self.dense.gen_spin(self.seed_for_spin), self.dense)
import cxxjij as cj
L = 3
chimera = cj.graph.Chimera(1, L)
print(chimera[2, 2, 0], chimera[1, 4, 0])
0, 0
設定したcolumn と row よりも大きい column と row にアクセスしてもエラーが出ない。
エラー出した方がよい。
The following conditional expression should be true but is false.
import openjij as oj
model = oj.BinaryQuadraticModel({}, {(0,1):1}, "SPIN")
model.vartype == model.get_vartype()
False
It seems that model.vartype
is openjij.Vartype.SPIN
but model.get_vartype()
returns cxxcimod.SPIN
.
Both must be openjij.Vartype.SPIN
Environment
ProductName: macOS
ProductVersion: 12.0.1
BuildVersion: 21A559
Python 3.9.8 (main, Nov 10 2021, 03:55:42)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
If USE_TEST is not set, C++ test will not be executed, but the following command
python setup.py test
seems to raise Error like
Python tests complete, now running C++ tests...
build/lib.macosx-11-x86_64-3.9
make: *** No rule to make target `cxxjij_test'. Stop.
/bin/sh: ./tests/cxxjij_test: No such file or directory
This appears to be an error message, so it would be better to replace the proper message.
Describe the bug
SASampler().sample_qubo
does not work
To Reproduce
Steps to reproduce the behavior:
import openjij as oj
res = oj.SASampler().sample_qubo({(0, 1): -1})
Error
TypeError: make_BinaryQuadraticModel() missing 1 required positional argument: 'sparse'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
----> 1 oj.SASampler().sample_qubo({(0, 1): -2}, sparse=True)
in sample_qubo(self, Q, **parameters)
230 :class:`openjij.sampler.response.Response`: results
231 """
--> 232 bqm = openjij.BinaryQuadraticModel.from_qubo(Q)
233 return self.sample(bqm, **parameters)
234
in <lambda>(Q, offset, **kwargs)
174 #classmethods
175 BinaryQuadraticModel.from_qubo = \
--> 176 lambda Q, offset=0.0, **kwargs: make_BinaryQuadraticModel({}, Q).from_qubo(Q, offset, **kwargs)
177
178 BinaryQuadraticModel.from_ising = \
/openjij/model/model.py in make_BinaryQuadraticModel(linear, quadratic)
46 """
47
---> 48 class BinaryQuadraticModel(cimod.make_BinaryQuadraticModel(linear, quadratic)):
49 """Represents Binary quadratic model.
50 Indices are listed in self.indices.
TypeError: make_BinaryQuadraticModel() missing 1 required positional argument: 'sparse'
Expected behavior
sample_qubo should be working.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
OpenJij is now replacing Graph class with BQM class with c++ implementation.
All constructors in the system should be initialized with the BQM class.
python setup.py test
outputs the following warning:
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
We should replace the test with an alternative one (e.g., tox?) shortly.
Now p_d is constant at to evaluate TTS
Building projects with CMake and make results in long compilation time and troublesome errors.
It is highly recommended to replace the build systems with meson and ninja.
meson: https://mesonbuild.com/
ninja: https://ninja-build.org/
On Mac OS
import openjij
openjij.SASampler().sample_hubo({}, "SPIN")
zsh: segmentation fault python
Now the total Hamiltonian in SQA is
However, I think the following Hamiltonian is good.
where s=t/\tau
The reason is that if the first term is not dependent on time, in reverse annealing, the spatial direction of the classical system is fixed.
Similarly, if Gamma_max is not sufficiently large with respect to the classical term, it is likely to be addicted to the local solution in the first Hamiltonian.
The connection should have symmetry. However, Chimera graph not has symmetry.
import cxxjij as cj
chimera = cj.graph.Chimera(2,2)
chimera[0,0,4, cj.graph.ChimeraDir.PLUS_C] = 2
print(chimera[0,0,4, cj.graph.ChimeraDir.PLUS_C], chimera[1,0,4, cj.graph.ChimeraDir.MINUS_C])
2, 0 # these two value should be same from symmetry.
I can't compile "benchmark.py".
When I try following command, I got some error.
$python benchmark.py
File "benchmark.py", line 2, in <module> import matplotlib.pyplot as plt File "~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/matplotlib/pyplot.py", line 2374, in <module> switch_backend(rcParams["backend"]) File "~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/matplotlib/pyplot.py", line 207, in switch_backend backend_mod = importlib.import_module(backend_name) File "~/.pyenv/versions/3.7.0/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "~/.pyenv/versions/3.7.0/lib/python3.7/site-packages/matplotlib/backends/backend_macosx.py", line 14, in <module> from matplotlib.backends import _macosx ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
[jw@cn06 openjij]$ sudo python3 setup.py install --verbose
running install
running bdist_egg
running egg_info
writing openjij.egg-info/PKG-INFO
writing dependency_links to openjij.egg-info/dependency_links.txt
writing requirements to openjij.egg-info/requires.txt
writing top-level names to openjij.egg-info/top_level.txt
reading manifest file 'openjij.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '.cmake'
warning: no files found matching 'FetchContent/.cmake.in'
writing manifest file 'openjij.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-aarch64/egg
running install_lib
running build_py
running build_ext
-- GCC detected, adding compile flags
-- No CUDA support
-- USE_OMP = Yes
-- USE_CUDA = No
-- USE_TEST = Yes
-- Fetch googletest for C++ testing
[ 11%] Performing download step (git clone) for 'googletest-populate'
Cloning into 'googletest-src'...
fatal: unable to access 'https://github.com/google/googletest.git/': Could not resolve host: github.com
Cloning into 'googletest-src'...
fatal: unable to access 'https://github.com/google/googletest.git/': Could not resolve host: github.com
Cloning into 'googletest-src'...
fatal: unable to access 'https://github.com/google/googletest.git/': Could not resolve host: github.com
-- Had to git clone more than once:
3 times.
CMake Error at googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitclone.cmake:31 (message):
Failed to clone repository: 'https://github.com/google/googletest.git'
gmake[2]: *** [CMakeFiles/googletest-populate.dir/build.make:111: googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-download] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/googletest-populate.dir/all] Error 2
gmake: *** [Makefile:103: all] Error 2
CMake Error at /usr/share/cmake/Modules/FetchContent.cmake:987 (message):
Build step for googletest failed: 2
Call Stack (most recent call first):
/usr/share/cmake/Modules/FetchContent.cmake:1082:EVAL:2 (__FetchContent_directPopulate)
/usr/share/cmake/Modules/FetchContent.cmake:1082 (cmake_language)
external/googletest.cmake:13 (FetchContent_Populate)
CMakeLists.txt:73 (include)
-- Configuring incomplete, errors occurred!
See also "/data/jw/openjij/build/temp.linux-aarch64-3.9/CMakeFiles/CMakeOutput.log".
See also "/data/jw/openjij/build/temp.linux-aarch64-3.9/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
File "/data/jw/openjij/setup.py", line 122, in
setup(
File "/usr/lib/python3.9/site-packages/setuptools/init.py", line 165, in setup
return distutils.core.setup(**attrs)
File "/usr/lib64/python3.9/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.9/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.9/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/usr/lib/python3.9/site-packages/setuptools/command/install.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "/usr/lib64/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.9/site-packages/setuptools/command/bdist_egg.py", line 174, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "/usr/lib/python3.9/site-packages/setuptools/command/bdist_egg.py", line 160, in call_command
self.run_command(cmdname)
File "/usr/lib64/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/lib/python3.9/site-packages/setuptools/command/install_lib.py", line 11, in run
self.build()
File "/usr/lib64/python3.9/distutils/command/install_lib.py", line 107, in build
self.run_command('build_ext')
File "/usr/lib64/python3.9/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/data/jw/openjij/setup.py", line 43, in run
self.build_extension(ext)
File "/data/jw/openjij/setup.py", line 73, in build_extension
subprocess.check_call(['cmake', ext.sourcedir] +
File "/usr/lib64/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '/data/jw/openjij', '-DUSE_TEST=Yes', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/data/jw/openjij/build/lib.linux-aarch64-3.9', '-DPYTHON_EXECUTABLE=/usr/bin/python3', '-DCMAKE_BUILD_TYPE=Release']' returned non-zero exit status 1.
[jw@cn06 openjij]$
The current interface of model initialization supports only the dictionary object.
It is recommended to support the NumPy matrix interface.
Following the tutorial on classical ising model (https://openjij.github.io/OpenJijTutorial/build/html/ja/A003-LargeScaleMC.html),
I executed this program (using openjij==0.1.1 and numpy==1.19.1):
import numpy as np
import cxxjij.graph as G
import cxxjij.system as S
N = 100
graph = G.Dense(N)
mu, sigma = 0, 1
for i in range(N):
for j in range(N):
# to avoid a large Jij value, normalize in 1/N
graph[i,j] = 0 if i == j else np.random.normal()/N
for i in range(N):
graph[i] = np.random.normal()/N
spin = graph.gen_spin()
mysystem = S.make_classical_ising(spin, graph)
Then, I noticed that the number of spins generated at random does not match the number of spins the system has.
print(len(spin), mysystem.num_spins, graph.size())
>>> 100 100 100
print(mysystem.spin.shape)
>>> (101,)
Following python code raises the error (shape mismatching in NumPy)
a = oj.GPUChimeraSASampler(unit_num_L = 2)
a.sample_ising(h={0: 0.1, 1: 0.4}, J={(2,5): 0.3})
error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/mnt/ssd/workspace/linux/workspace/Jij/openjij/OpenJij/openjij/sampler/chimera_gpu/gpu_sa_sampler.py", line 113, in sample_ising
return self._sampling(model, beta_min, beta_max,
File "/mnt/ssd/workspace/linux/workspace/Jij/openjij/OpenJij/openjij/sampler/sa_sampler.py", line 204, in _sampling
response = self._cxxjij_sampling(
File "/mnt/ssd/workspace/linux/workspace/Jij/openjij/OpenJij/openjij/sampler/sampler.py", line 120, in _cxxjij_sampling
sampling_time = exec_sampling()
File "/mnt/ssd/workspace/linux/workspace/Jij/openjij/OpenJij/openjij/sampler/sampler.py", line 27, in wrapper
func(*args, **kargs)
File "/mnt/ssd/workspace/linux/workspace/Jij/openjij/OpenJij/openjij/sampler/sampler.py", line 113, in exec_sampling
energies.append(model.calc_energy(result_state))
File "/mnt/ssd/workspace/linux/workspace/Jij/openjij/OpenJij/openjij/model/model.py", line 150, in calc_energy
energy = (np.dot(_state, np.dot(int_mat, _state)) -
File "<__array_function__ internals>", line 5, in dot
ValueError: shapes (4,4) and (32,) not aligned: 4 (dim 1) != 32 (dim 0)
This error may occur since the Chimera graph with 2 * 2 * 8 spins is interpreted to Binary Quadratic Model with four spins when evaluating calc_energy
inside Python implementation of OpenJij.
In a current version of the library, GPU-based algorithms can be used only with a single-precision floating-point type. To use GPU-based algorithms with double precision, one should add compile and linker options (e.g. nvcc -arch sm_60
) in the CMake file.
(Note that this compile option does not work on previous versions of GPU devices.)
Error message
Collecting openjij
Downloading https://files.pythonhosted.org/packages/64/f2/ac9fd9380e7464c78b5e66f278b70e083fa3395e57c6c521b90f8b7c313e/openjij-0.0.1.0.tar.gz
Requirement already satisfied: numpy in /usr/local/lib/python3.6/site-packages (from openjij) (1.15.4)
Building wheels for collected packages: openjij
Building wheel for openjij (setup.py) ... error
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-m3y_dlos/openjij/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-_n2vxo_n --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/openjij
copying openjij/sampler.py -> build/lib.linux-x86_64-3.6/openjij
copying openjij/model.py -> build/lib.linux-x86_64-3.6/openjij
copying openjij/utils.py -> build/lib.linux-x86_64-3.6/openjij
copying openjij/__init__.py -> build/lib.linux-x86_64-3.6/openjij
running build_ext
<__main__.CMakeExtension('cxxjij') at 0x7ff642d3a358> cxxjij
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Fetch googletest for C++ testing
-- Found PythonInterp: /usr/local/bin/python (found version "3.6.8")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Fetch pybind11 for python-binding
-- Found PythonLibs: /usr/local/lib/libpython3.6m.so
-- pybind11 v2.2.4
-- Looking for a CUDA compiler
-- Looking for a CUDA compiler - NOTFOUND
-- No CUDA support
-- USE_OMP = No
-- USE_CUDA = No
-- USE_TEST = No
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/pip-install-m3y_dlos/openjij/build/temp.linux-x86_64-3.6
Scanning dependencies of target algorithm_static
Scanning dependencies of target graph_static
[ 7%] Building CXX object src/algorithm/CMakeFiles/algorithm_static.dir/sa.cpp.o
[ 14%] Building CXX object src/graph/CMakeFiles/graph_static.dir/graph.cpp.o
[ 21%] Building CXX object src/algorithm/CMakeFiles/algorithm_static.dir/sqa.cpp.o
[ 28%] Linking CXX static library libalgorithm_static.a
[ 35%] Building CXX object src/graph/CMakeFiles/graph_static.dir/dense.cpp.o
[ 35%] Built target algorithm_static
[ 42%] Building CXX object src/graph/CMakeFiles/graph_static.dir/sparse.cpp.o
[ 50%] Building CXX object src/graph/CMakeFiles/graph_static.dir/square.cpp.o
[ 57%] Building CXX object src/graph/CMakeFiles/graph_static.dir/chimera.cpp.o
[ 64%] Linking CXX static library libgraph_static.a
[ 64%] Built target graph_static
Scanning dependencies of target method_static
[ 71%] Building CXX object src/method/CMakeFiles/method_static.dir/classical_ising.cpp.o
[ 78%] Building CXX object src/method/CMakeFiles/method_static.dir/quantum_ising.cpp.o
[ 85%] Linking CXX static library libmethod_static.a
[ 85%] Built target method_static
Scanning dependencies of target cxxjij
[ 92%] Building CXX object openjij/CMakeFiles/cxxjij.dir/main.cpp.o
[100%] Linking CXX shared module ../../lib.linux-x86_64-3.6/cxxjij.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: ../src/graph/libgraph_static.a(graph.cpp.o): relocation R_X86_64_PC32 against symbol `_ZNSt23mersenne_twister_engineImLm32ELm624ELm397ELm31ELm2567483615ELm11ELm4294967295ELm7ELm2636928640ELm15ELm4022730752ELm18ELm1812433253EEclEv' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
openjij/CMakeFiles/cxxjij.dir/build.make:88: recipe for target '../lib.linux-x86_64-3.6/cxxjij.cpython-36m-x86_64-linux-gnu.so' failed
make[3]: *** [../lib.linux-x86_64-3.6/cxxjij.cpython-36m-x86_64-linux-gnu.so] Error 1
CMakeFiles/Makefile2:662: recipe for target 'openjij/CMakeFiles/cxxjij.dir/all' failed
make[2]: *** [openjij/CMakeFiles/cxxjij.dir/all] Error 2
CMakeFiles/Makefile2:706: recipe for target 'openjij/CMakeFiles/python.dir/rule' failed
make[1]: *** [openjij/CMakeFiles/python.dir/rule] Error 2
Makefile:320: recipe for target 'python' failed
make: *** [python] Error 2
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-m3y_dlos/openjij/setup.py", line 109, in <module>
zip_safe=False
File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 143, in setup
return distutils.core.setup(**attrs)
File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 188, in run
self.run_command('build')
File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-install-m3y_dlos/openjij/setup.py", line 34, in run
self.build_extension(ext)
File "/tmp/pip-install-m3y_dlos/openjij/setup.py", line 62, in build_extension
subprocess.check_call(['cmake', '--build', '.', '--target', 'python'] + build_args, cwd=self.build_temp)
File "/usr/local/lib/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'python', '--config', 'Release', '--', '-j2']' returned non-zero exit status 2.
----------------------------------------
Failed building wheel for openjij
Running setup.py clean for openjij
Failed to build openjij
Describe the bug
When the same problem is annealed by different num_sweeps, even though num_sweep is set smaller, the annealing time may be long.
import openjij as oj
N = 30
h = {0: -10}
J = {(i, i+1): 1 for i in range(N-1)}
num_reads = 10
for num_sweeps in [25, 50]:
sampler = oj.SASampler(num_sweeps=num_sweeps, num_reads=num_reads)
response = sampler.sample_ising(h, J)
t = response.info["execution_time"]
print(f"t(num_sweeps={num_sweeps}) = {t}")
t(num_sweeps=25) = 88.32270978018641
t(num_sweeps=50) = 58.8218797929585
Expected behavior
Environment (please complete the following information):
It is recommended to enable build automation by using Travis CI for the convenience.
FYI Attached is the example of the pull request in qulacs library. Please see the rewritten .travis.yml
in the request.
Describe the bug
setting initial_state
keyword of sample_qubo
with binary variables (0, 1) results in weird answer.
To Reproduce
>>> import openjij as oj
>>> a = oj.SASampler()
>>> a.sample_qubo(Q={(2, 2): -68.55, (0, 2): 0.1, (1, 3): 0.1, (3, 4): 0.1, (1, 4): 0.1, (4, 4): -66.55, (2, 3): 0.1, (1, 1): -69.55, (0, 0): -70.55, (0, 4): 0.1, (0, 3): 0.1, (2, 4): 0.1, (0, 1): 0.1, (3, 3): -67.55, (1, 2): 0.1}, num_sweeps=1000, initial_state=[1,1,0,1,1])
Response(rec.array([([1, 1, 0, 1, 1], -273.6, 1)],
dtype=[('sample', 'i1', (5,)), ('energy', '<f8'), ('num_occurrences', '<i8')]), Variables([0, 1, 2, 3, 4]), {'system': [], 'sampling_time': 1059.5160019875038, 'execution_time': 900.4790008475538, 'list_exec_times': array([900.47900085]), 'schedule': {'beta_max': 184.20680743952366, 'beta_min': 0.01964981376498782, 'num_sweeps': 1000}}, 'BINARY')
Expected behavior
Result binary array should be [1,1,1,1,1]
Additional context
This error comes from the missing conversion of the binary initial_state
array to spin array.
SingleBinayFlip
may accelerate the calc speed.openjij::
).The performance of "fmath" (https://github.com/esheldon/fmath) is in general much better than std::exp.
I strongly recommend using "fmath" in OpenJij.
The cooling schedule does not seem to be consistent with changing vartype
import openjij as oj
model = oj.BinaryPolynomialModel({(0,1):-1}, "SPIN")
res = oj.SASampler().sample_hubo(model.to_hising(), "SPIN")
res.info['schedule']
{'beta_max': 2.302585092994046, 'beta_min': 0.34657359027997264, 'num_sweeps': 1000}
res = oj.SASampler().sample_hubo(model.to_hubo(), "BINARY")
res.info['schedule']
{'beta_max': 1.5350567286626973, 'beta_min': 0.11552453009332421, 'num_sweeps': 1000}
Above two cases should have the same cooling schedule.
This inconsistency also occurs in sample_ising
and sample_qubo
.
res = oj.SASampler().sample_ising({}, {(0,1):-1, (0,2):+1})
res.info['schedule']
{'beta_max': 4.605170185988092, 'beta_min': 0.34657359027997264, 'num_sweeps': 1000}
Then we multiply the interaction by two.
res = oj.SASampler().sample_ising({}, {(0,1):-2, (0,2):+2})
res.info['schedule']
{'beta_max': 4.605170185988092, 'beta_min': 0.17328679513998632, 'num_sweeps': 1000}
beta_max must be 2.30258509299 (half of the first beta_max) ?
The following code
import cxxjij
model = cxxjij.graph.Polynomial(3)
model[0,1,2] = 1
sys = cxxjij.system.make_classical_ising_polynomial([1,1,1], model, "SPIN")
sys.vartype
raises
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Unable to convert function return value to a Python type! The signature was
(self: cxxjij.system.ClassicalIsing_Polynomial) -> cimod::Vartype
Environment:
pyquboの出力だとラベルが文字列なのでopenjijに投げた時にstateに入るスピンの順番が意図せずバラバラになる。benchmark 関数では state in correct_states
(stateが配列)で評価しているので、順番が異なるとダメ。辞書型でラベル対応させて比べないと状態があっているのがどうかを評価できない。
change GPU Sampler constructor. Now GPU algorithm overwrites by CPU SA.
related to #144.
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
Error output
parse<openjij::FloatTy
pe>,true>(pybind11::module &,const std::string &,const std::string &)' のリファレンスを確認してください [C:\Users\winya\source\repos\OpenJij\OpenJij\build\openjij\cxxjij.vcxproj]
ライブラリ C:/Users/winya/source/repos/OpenJij/OpenJij/build/openjij/Debug/cxxjij.lib とオブジェクト C:/Users/winya/source/repos/OpenJij/OpenJij/build/openjij/Debug/cxxjij.exp を作成
中
cxxjij_chimera_gpu_kernel_static.lib(kernel.obj) : error LNK2001: 外部シンボル "__cudaRegisterLinkedBinary_41_tmpxft_00004298_00000000_7_kernel_cpp1_ii_fd013a99" は未解決で
す。 [C:\User
s\winya\source\repos\OpenJij\OpenJij\build\openjij\cxxjij.vcxproj]
C:\Users\winya\source\repos\OpenJij\OpenJij\build\openjij\Debug\cxxjij.cp37-win_amd64.pyd : fatal error LNK1120: 1 件の未解決の外部参照 [C:\Users\winya\source\repos\OpenJij\OpenJij\b
uild\openjij\cxxjij.vcxproj]
Building Custom Rule C:/Users/winya/source/repos/OpenJij/OpenJij/src/system/CMakeLists.txt
Compiling CUDA source file ..\..\..\src\system\gpu\chimera_cuda\kernel.cu...
Current specifications are
import openjij as oj
sampler = oj.SASampler()
res = sampler.sample_ising({}, {(0,1):-1}, num_sweeps=10)
res.info['schedule']
-->'num_sweeps': 10
res = sampler.sample_ising({}, {(0,1):-1})
res.info['schedule']
-->'num_sweeps': 10
But that should be like
import openjij as oj
sampler = oj.SASampler()
res = sampler.sample_ising({}, {(0,1):-1}, num_sweeps=10)
res.info['schedule']
-->'num_sweeps': 10
res = sampler.sample_ising({}, {(0,1):-1})
res.info['schedule']
-->'num_sweeps': 1000
Note that the default value of num_sweeps
is 1000.
It is better to calculate the dE first and only update the dE when flipping spins so that the energy difference is calculated less often.
the build from scratch does not work anymore
Currently, OpenJij does not support the windows environment.
We need to remake cmake for the Windows environment.
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.