From cc4a04e77b72a978238374e05cbdde4de3d8b74d Mon Sep 17 00:00:00 2001 From: Steven Holtzen Date: Thu, 22 Aug 2019 15:19:42 -0700 Subject: [PATCH] fix silliness --- .#markov.py | 1 - factor.py | 39 +++++++-------------------------------- markov.py | 12 ++---------- 3 files changed, 9 insertions(+), 43 deletions(-) delete mode 120000 .#markov.py diff --git a/.#markov.py b/.#markov.py deleted file mode 120000 index 81d4561..0000000 --- a/.#markov.py +++ /dev/null @@ -1 +0,0 @@ -sholtzen@Stevens-MacBook-Pro.local.879 \ No newline at end of file diff --git a/factor.py b/factor.py index b2b3348..0edd343 100644 --- a/factor.py +++ b/factor.py @@ -28,29 +28,6 @@ def fast_random_element(g): class FactorGraph: - ### Given a group g, strips the factor generators from that group - ### necessary for the correctness of automorphism group order - def strip_factors(self, g): - stripped_gens = [] - for gen in g.gens(): - sgen = [] - for cycle in gen.cycle_tuples(singletons=False): - # print "checking cycle " + str(cycle) - # check this cycle contains a factor - contains_factor = False - for factor in self.factors: - for e in factor: - # print "checking if " + str(e) + " in " + str(cycle) - if e in cycle: - contains_factor = True - if not contains_factor: - # print "no factor in " + str(cycle) - sgen.append(cycle) - stripped_gens.append(tuple(sgen)) - print stripped_gens - return PermutationGroup(stripped_gens) - - ### graph: a sage graph ### variables: a list of graph vertices which correspond to variables in the factor graph ### factors: a list of list of factors; each list is a single color @@ -59,14 +36,11 @@ def strip_factors(self, g): def __init__(self, graph, variables, factors, potential): self.graph = graph self.variables = variables - print "variables: " + str(variables) - print "factors: " + str(factors) self.factors = factors self.potential = potential g = graph.automorphism_group(partition=[variables] + factors) - print g - self.graph_aut = self.strip_factors(g) - print self.graph_aut + self.graph_aut = g + # print self.graph_aut self.graph_aut_order = self.graph_aut.order() ### converts a variable state into a variable partition @@ -131,7 +105,6 @@ def partition(self): c = queue.popleft() # TODO: turn this into a single GI call by having it return both the # automorphism group and the canonical form - print c + self.factors gcanon, cert = my_bliss.canonical_form(self.graph, partition=c + self.factors, certificate=True, @@ -153,7 +126,7 @@ def partition(self): A, orbits = self.graph.automorphism_group(partition=c+self.factors, orbits=True, algorithm="bliss") - orbitsz = g_order / (self.strip_factors(A)).order() + orbitsz = g_order / A.order() A = None states = self.partition_to_state(c) @@ -195,10 +168,12 @@ def potential(state): if v: p += 1 return p - return FactorGraph(g, v, [factors[:len(factors)/2],factors[len(factors)/2:]], potential) + # make half the factors different colors + # return FactorGraph(g, v, [factors[:len(factors)/2],factors[len(factors)/2:]], potential) + return FactorGraph(g, v, [factors], potential) if __name__ == "__main__": - fg = gen_complete_pairwise_factorgraph(8) + fg = gen_complete_pairwise_factorgraph(10) print fg.partition() print fg.brute_force_partition() diff --git a/markov.py b/markov.py index 5200e4a..4c12242 100644 --- a/markov.py +++ b/markov.py @@ -29,7 +29,7 @@ def fast_random_element(g): class MarkovModel: ### graph: a sage graph - ### variables: a list of graph vertices which correspond to variables in the factor graph + ### variables: a list of graph vertices which correspond to variables ### potential: state -> real: a function which evaluates the potential on a particular state ### a state is a dictionary assigning variables to Boolean values def __init__(self, graph, variables, potential, order=True): @@ -543,15 +543,7 @@ def trivial_query(state): return supp_explored -def gen_complete_pairwise_factorgraph(n): - (g, (v, factors)) = gen_complete_pairwise_factor(n) - def potential(state): - p = 0.0 - for v in state.itervalues(): - if v: - p += 1 - return p - return FactorGraph(g, v, [factors], potential) + def run_burnside(): cur_state = dict()