QAOA eThrTwoLin problem implementation#

This is a QAOA implementation of the eThrLinTwo problem.

Problem description#

Given a set of \(m\) three-variable equations \(A = {A_j}\) , over n binary variables \(x \in \{ 0, 1 \}^n\) , where each equation \(A_j\) is of the form \(x_{a_{1,j}} + x_{a_{1,j}} + x_{a_{1,j}} = b_j \text{ mod } 2\), where \(a_{1,j} \, ; \, a_{1,j}; \, a_{1,j} \in [ n ]\) and \(b_j \in \{ 0 , 1 \}\) find an assignment \(x \in \{ 0, 1 \}^n\) that maximizes the number of satisfied equations.

Cost operator#

eThrTwocostOp(clauses)[source]#
Implementation for eThrTwoLin Cost-Operator.
Straight forward, apply \(R_{ZZZ}\) gates between all qubits meantioned in each clause.
Parameters
clausesList(List)

clauses to be considered for eTwoThrLin

Returns
QuantumCircuit: qrisp.QuantumCircuit

the Operator applied to the circuit-QuantumVariable

Examples

first three are the indices (a_1,j ; a_2,j ; a3,j), last one is b_L

>>> clauses = [(1,3,4,5), (2,6,9,11), (1,5,8,33), (3,4,5,77), (2,4,6,7), (1,3,4,55), (1,3,6,49), (1,3,4,57), (1,3,6,44), (2,4,7,8)]
>>> cost_operator = eThrTwocostOp(clauses=clauses)

Classical cost function#

eTwoThrLinclCostfct(clauses)[source]#
Parameters
clausesList

clauses to analyze in the problem instance

Returns
Costfunctionfunction

the classical function for the problem instance, which takes a dictionary of measurement results as input