def main(Ns, ds, num_trials, statistic, approach, filename): doPrintd = False if len(Ns) == 1: doPrintd = True filename = "output/" + filename f = open(filename,"w") for N in Ns: print "N = " + str(N) for d in ds: if doPrintd: print d trials = num_trials*[0] for i in range(num_trials): success,unmatched,matching,incident = bes.main(N,d,approach) assert success if unmatched > 0: for i in range(N): for e in incident[i]: print e print matching trials[i] = unmatched result = statistic(trials) f.write(str(result)) if d == ds[-1]: f.write("\n") else: f.write(",") f.close()
def main(N, d, approach, freq): itr = 0 max_unmatched = 0 while True: itr += 1 if itr % freq == 0: print "iteration #" + str(itr) if approach == 3: success,num_unmatched,matching,incident = besi.main(N,d) else: success,num_unmatched,matching,incident = bes.main(N,d,approach) assert success if num_unmatched > max_unmatched: for n in range(N): for e in incident[n]: print e print matching print "New max unmatched: " + str(num_unmatched) max_unmatched = num_unmatched
print "Script that outputs the maximum amount of unmatched nodes encountered during run." if len(argv) == 1: # Lauren's w/ multi --> approach = 0 # Lauren's w/o multi --> approach = 1 # Random, stupid edge selection --> approach = 2 print "Enter N, d, approach:", params = raw_input().split() N = int(params[0]) d = int(params[1]) approach = int(params[2]) else: N = int(argv[1]) d = int(argv[2]) approach = int(argv[3]) max_unmatched = 0 i = 0 for right_sides in bes.create_all_right_sides(N, d): i += 1 success, unmatched, matching, incident = bes.main(N, d, approach, right_sides=right_sides) if i % 100000: print i if unmatched > max_unmatched: print "" for i in range(N): for e in incident[i]: print e print matching print "Max Unmatched = " + str(unmatched)