from pyqubo import Spin, solve_ising

x1, x2, x3  = Spin("x1"), Spin("x2"), Spin("x3")
Quad_form = 2*(x1) + x2 - 3*(x3)

model = Quad_form.compile()
deg1, deg2, off = model.to_ising()

print('Degree1:',deg1,' Degree2:',deg2,' Offset:',off)

res = solve_ising(deg1,deg2)
print(res) 

shots = 10 #variable used to specify number of times you want to solve the model
ans = []
for i in range(shots):
    res = solve_ising(deg1, deg2)
    ans.append(res)
    
result = ans[0]
maxim = 0
for i in ans:
    freq = ans.count(i)
    if freq>maxim:
        maxim = freq
        result = i

print(str(result))