Open deepakpathania-py opened 1 year ago
Pyqubo gives the error for the following Hamiltonian:
n=3 from pyqubo import solve_qubo,Array,Placeholder x = Array.create('x', shape=(5), vartype='BINARY') dic={"0":12,"1":6,"2":21,"3":32,"4":7}
H_1 = (sum(x)-n)*2 H_2 = sum(x[i]dic["{}".format(i)] for i in range(5)) H = sum(dic.values())3/5H_1 + H_2
TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_12292/2264980511.py in 1 H_1 = (sum(x)-n)*2 2 H_2 = sum(x[i]dic["{}".format(i)] for i in range(5)) ----> 3 H = sum(dic.values())3/5H_1 + H_2
TypeError: radd(): incompatible function arguments. The following argument types are supported:
However, this error can be worked around if we re-write the above expression as follows:
H_1 = (sum(x)-n)*2 H_2 = sum(x[i]dic["{}".format(i)] for i in range(5)) H = sum(dic.values())3/5H_1 - (- H_2) # Negative sign is a work-around
Pyqubo gives the error for the following Hamiltonian:
n=3 from pyqubo import solve_qubo,Array,Placeholder x = Array.create('x', shape=(5), vartype='BINARY') dic={"0":12,"1":6,"2":21,"3":32,"4":7}
H_1 = (sum(x)-n)*2 H_2 = sum(x[i]dic["{}".format(i)] for i in range(5)) H = sum(dic.values())3/5H_1 + H_2
Error Reported:
TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_12292/2264980511.py in
1 H_1 = (sum(x)-n)*2
2 H_2 = sum(x[i]dic["{}".format(i)] for i in range(5))
----> 3 H = sum(dic.values())3/5H_1 + H_2
TypeError: radd(): incompatible function arguments. The following argument types are supported:
However, this error can be worked around if we re-write the above expression as follows:
H_1 = (sum(x)-n)*2 H_2 = sum(x[i]dic["{}".format(i)] for i in range(5)) H = sum(dic.values())3/5H_1 - (- H_2) # Negative sign is a work-around