`QuadratricExpression` does not support `__pow__()`?
I'm trying to use this library to maximize a function:
In which, Ψ is defined as: α|0> + β|1> and has a normalization condition α^2 + β^2 = 1 (reference)
So in picos, this is roughly what I'm doing:
ket_0 = np.array([[1.], [0.]])
ket_1 = np.array([[0.], [1.]])
prob = pic.Problem()
alpha = pic.RealVariable('alpha', shape=(1, 1))
beta = (1 - alpha**2)) ** 0.5
ket_0 = pic.Constant('ket_0', ket_0, shape=(2, 1))
ket_1 = pic.Constant('ket_1', ket_1, shape=(2, 1))
psi = (alpha*ket_0) + (beta*ket_1)
inner = p1*psi*psi.T - p2*(iMat/d) # p1 = p2 = 0.5, d=2
trace_norm = pic.expressions.exp_norm.Norm(inner, 1)
...
However, I run into this issue while calculating beta
:
Traceback (most recent call last):
File "/home/hoppingturtles/Documents/pyprojects/quantum assignment/quantum_state_discrim.py", line 68, in <module>
find_lowest_error_prob_2_part_picos()
File "/home/hoppingturtles/Documents/pyprojects/quantum assignment/quantum_state_discrim.py", line 42, in find_lowest_error_prob_2_part_picos
beta = (1 - alpha**2) ** 0.5
~~~~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for ** or pow(): 'QuadraticExpression' and 'float'
I'm confused on I would be able to solve this optimzation problem because of this error. How should I approach this problem then?
Python version: 3.11 picos version: 2.4.17 cvxopt version: 1.3.1