Comments (2)
@Ooshita ご質問ありがとうございます。QUBOのインデックスを整数値のタプルで出力するには、to_quboメソッドでindex_labelという引数をTrueに指定することで実現できます。
もとのラベルと整数値の対応関係は、modelオブジェクトのvariablesというメンバ変数に格納されております。
>>> from pyqubo import Binary
>>> x, y, z = Binary("x"), Binary("y"), Binary("z")
>>> model = (x*y + y*z + 3*z).compile()
>>>model.to_qubo()
({('x', 'x'): 0.0,
('x', 'y'): 1.0,
('y', 'y'): 0.0,
('z', 'y'): 1.0,
('z', 'z'): 3.0},
0.0)
>>> model.to_qubo(index_label=True) # 整数値を出力する場合は、index_labelをTrueに設定してください。
({(0, 0): 3.0, (0, 2): 1.0, (1, 1): 0.0, (1, 2): 1.0, (2, 2): 0.0}, 0.0)
>>> model.variables # もとの文字列ラベルと整数値の対応は、variablesを見るとわかります。ラベルの順番=整数の値です。
['z', 'x', 'y']
詳しくはhttps://pyqubo.readthedocs.io/en/latest/reference/model.html#pyqubo.to_qubo をご覧ください。
from pyqubo.
@kotarotanahashi ご回答ありがとうございます!詳しく教えていただき感謝いたします!
from pyqubo.
Related Issues (20)
- Incorrect compilation of expression into qubo HOT 2
- How is OR supposed to work?
- Support dimod~=0.11.0 HOT 1
- Support to the number of spins HOT 3
- segmentation fault HOT 1
- Method to_bqm does not maintain variables order
- robin_hoodライブラリのバージョンアップ HOT 3
- Automatically handle strength for dimension reduction HOT 2
- Support for symbolized division HOT 1
- Support for advanced matrix operation, pseudo-inverse HOT 1
- cannot execute graph_coloring.ipynb HOT 1
- Support Python 3.11 HOT 2
- Incorrect QUBOs from large combinations of And, Or, and Not
- Issue when dealing with expressions that contain a cubic term in an intermediate step
- Memory leak when repeatedly creating QUBOs with version 1.3.0 or higher HOT 2
- Add logging functionality to track progress during pyqubo.compile()
- Error in parsing specific type of Hamiltonian expression
- Add support for Python 3.12
- The wrong for auxiliary variables
- Memory error in class model on big sizes QUBO HOT 1
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 pyqubo.