示例#1
0
# examples-01
# k to 2 body

import symque as sq

# create an object qsymaqc 
mypb=sq.symq
# fill EQ with expression in STRING format
mypb.EQ='x0 - x0*x1*x2'

# extract qubo/ising coefficients
hi, Jij = mypb.extract_qs_coeffs_from_string() 
J=Jij.tolist()
for m in range(0,len(hi)):
    J[m][m]=hi[m]
## to be processed by neal, wildqat, qbsolve, dwave, or other quantum machines
#print('\nhi=',mypb.ising_hi)
#print('\nJij=',mypb.ising_Jij)

###
'''
Solve the problem using wildqat
'''
print('\nSolve using wildqat ... !')
import wildqat as wq
b = wq.opt()
# fill in qubo coeffs
b.qubo = J#Jij.tolist() 
print(b.sa())
示例#2
0
# -*- coding: utf-8 -*-
"""
Created on Fri May  3 12:56:26 2019
@author: Suksmono
Simplest example of symque
"""
'''
# setup symque
'''
import symqui as sq

qb = sq.symqx()
qb.eq_str = '2*(1+q0*q1*q2*q3)'
'''
# solve using wildqat
'''
import wildqat as wq

a = wq.opt()
#enter qubo coeffs into solver
a.qubo = qb.get_qubo_coeffs()
#solve the problem
print('\nSolution:', a.sa())
示例#3
0
import wildqat as wq   # wildqat をインポート

a = wq.opt()        # 計算をするためのオブジェクトを作成
a.qubo = [[3,0],[0,-2]] # QUBO 行列を定義
a.sa()             # 計算実行