Professional Documents
Culture Documents
Docs MTX Creation
Docs MTX Creation
3 3
∑ xii − ∑ xij
i =1 i,j=1
i< j
The SBM solver then returns the vector of binary decision variables xi ∈ [0, 1] that minimizes the
QUBO.
The steps for submitting this problem to SBM are the following:
1. Create a matrix Q such that the above diagonal elements are -1 and the elements on the
diagonal are 1.
2. Convert Q to a symmetric matrix.
3. Convert this symmetric matrix to a matrix in coordinate format. This can be done using the
coo_matrix function from scipy.sparse.
4. Save the matrix in coordinate format to a Matrix Market file. This can be done using the
mmwrite function from scipy.io.
5. Rename the file name so it is saved as a .txt file instead of .mtx
1.1 Create Q
[1]: import numpy as np
[[ 1 -1 -1]
[ 0 1 -1]
[ 0 0 1]]
[[ 1 -1 -1]
[-1 1 -1]
[-1 -1 1]]
coordinate_matrix = coo_matrix(symmetric_Q)
print(coordinate_matrix)
file_name = 'example_Q'
mmwrite(file_name, a = coordinate_matrix, field = 'real', symmetry = 'symmetric')