pyqubo允许您从数学表达式创建qubo或ising模型。
pyqubo的Python项目详细描述
皮库博
PyQubO允许您轻松地从灵活的数学表达式创建QubOS或Ising模型。 pyqubo的一些特性是有关详细信息,请参见PyQUBO Documentation。
示例用法
此示例构造一个简单表达式并将其编译为model。 通过调用model.to_qubo(),我们得到结果qubo。 (此示例使用集合s={4,2,7,1}求解Number Partitioning Problem)
>>> from pyqubo import Spin >>> s1, s2, s3, s4 = Spin("s1"), Spin("s2"), Spin("s3"), Spin("s4") >>> H = (4*s1 + 2*s2 + 7*s3 + s4)**2 >>> model = H.compile() >>> qubo, offset = model.to_qubo() >>> pprint(qubo) {('s1', 's1'): -160.0, ('s1', 's2'): 64.0, ('s1', 's3'): 224.0, ('s1', 's4'): 32.0, ('s2', 's2'): -96.0, ('s2', 's3'): 112.0, ('s2', 's4'): 16.0, ('s3', 's3'): -196.0, ('s3', 's4'): 56.0, ('s4', 's4'): -52.0}
有关更多示例,请参见example notebooks。
安装
pip install pyqubo
或
python setup.py install
支持的python版本
支持Python2.7、3.4、3.5、3.6和3.7。
测试
运行所有测试。
python -m unittest discover test
显示覆盖率报告。
coverage run -m unittest discover coverage html
使用circleci cli运行测试。
circleci build --job $JOBNAME
运行doctest。
make doctest
引文
如果你在研究中使用pyqubo,请引用this paper。
@article{tanahashi2019application, title={Application of Ising Machines and a Software Development for Ising Machines}, author={Tanahashi, Kotaro and Takayanagi, Shinichi and Motohashi, Tomomitsu and Tanaka, Shu}, journal={Journal of the Physical Society of Japan}, volume={88}, number={6}, pages={061010}, year={2019}, publisher={The Physical Society of Japan} }
组织
新兵通信有限公司
许可证
在apache许可证2.0下发布。
贡献
我们欢迎对这个项目的贡献。见CONTRIBUTING。