import warnings
warnings.filterwarnings('ignore')

import os
os.chdir('..')

from functions import maxcut_utilities

import networkx 
from classes import Problems

G = networkx.Graph()
G.add_edges_from([[0,3],[0,4],[1,3],[1,4],[2,3],[2,4]])
instance = Problems.Problems(G=G)
maxcut = maxcut_utilities.compute_max_cut_exactly(instance)
print(maxcut)

counts = {'11000': 1, '00011': 29, '01011': 24}
rearranged_counts = maxcut_utilities.invert_counts(counts)
print(rearranged_counts)

cut_value = maxcut_utilities.get_maxcut_number_of_edges(instance,"10011")
print(-cut_value)

approximate_result = maxcut_utilities.compute_maxcut_energy(instance,counts)
print(approximate_result)

from classes import Qaoa

instance = Problems.Problems()
qaoa = Qaoa.Qaoa(p=3, G=instance)

from functions import qaoa_optimizers 

init_point = qaoa.betas + qaoa.gammas
maxcut_value = qaoa_optimizers.objective_function(init_point,qaoa,shots=100)
print("energy", maxcut_value)

qaoa_optimizers.callback([])

x, f = qaoa_optimizers.simple_optimization(qaoa)

from functions import qaoa_utilities

two_random_angles = qaoa_utilities.generate_parameters(2,1)
print(two_random_angles)

#pip install --no-binary pynauty pynauty

from functions import symmetry_utilities

instance = Problems.Problems(G=G)
adjacency_dict = instance.get_adjacency_dict()
num_automorphisms = symmetry_utilities.get_number_of_automorphisms(G=instance, adjacency_dict=adjacency_dict)
print(num_automorphisms)

generators = symmetry_utilities.get_symmetry_generators(G=instance, adjacency_dict=adjacency_dict)
print(generators)

num_orbits, orbits = symmetry_utilities.get_symmetry_orbits(G=instance, adjacency_dict=adjacency_dict)
print(num_orbits, orbits)