Skip to content

Commit

Permalink
removed indeterministic part of maxclique test
Browse files Browse the repository at this point in the history
  • Loading branch information
positr0nium committed Nov 15, 2024
1 parent a84dc6a commit 7d72d55
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions tests/test_QAOAmaxClique.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,31 +89,3 @@ def aClcostFct(state, G):
#assert set(intlist) in the_itt
#assert aClcostFct(name, giraf) <= -1

# test for full solution...
truth_list = []
for index in range(10):

integ = np.random.randint(1,7)
#create random graph with either all nodes connected, or no nodes connected
integ2 = np.random.randint(0,1)

secondGraph = nx.erdos_renyi_graph(integ,integ2)
secondQarg = QuantumVariable(secondGraph.number_of_nodes())
secondInstance = QAOAProblem(cost_operator= maxCliqueCostOp(secondGraph), mixer= RX_mixer, cl_cost_function=maxCliqueCostfct(secondGraph))
secondInstance.set_init_function(init_function=init_state)
theNiceQAOA2 = secondInstance.run(qarg=secondQarg, depth= 3, max_iter = 50, mes_kwargs = {"shots" : 100000})
maxOne = sorted(theNiceQAOA2, key=theNiceQAOA2.get, reverse=True)[:1]
#if no nodes connected, maxClique sol should just be the first node, i.e. "1000" (more or less zeros)
if integ2 == 0:
string = "1"
string += str(integ2) * (secondGraph.number_of_nodes()-1)
testStr = [string]
#if all nodes connected, maxClique sol should be all nodes, i.e. "1111" (more or less ones)
if integ2 == 1:
testStr = [str(integ2) * secondGraph.number_of_nodes()]


if testStr == maxOne:
truth_list.append(1)

assert sum(truth_list)/10 > 0.5

0 comments on commit 7d72d55

Please sign in to comment.