def render(self, output_port): self.render_title(output_port, "Simple Random Sampling: %s" % self.project_name) self.render_summary(output_port) self.render_overall(output_port ,("untyped", config.is_untyped) ,("typed", config.is_typed)) self.render_absolute(output_port ,*[(str(n), self.in_random_sample(num_typed=n)) for n in range(self.get_num_modules())]) self.render_sample_results(output_port) self.strategy = constants.CACHE # self.render_all_paths(output_port, [1,2,3,4]) print(latex.end(), file=output_port)
def render(self, output_port): title = "Ground Truth Results: %s" % self.project_name self.render_title(output_port, title) self.render_summary(output_port) best_cfgs = self.best_rows( config.is_gradual, lambda x, y: self.stats_by_config[x]["mean"] > self.stats_by_config[y]["mean"] ) worst_cfgs = self.best_rows( config.is_gradual, lambda x, y: self.stats_by_config[x]["mean"] < self.stats_by_config[y]["mean"] ) self.render_overall( output_port, ("untyped", config.is_untyped), ("gradual", config.is_gradual), ("fastest(%s)" % best_cfgs[0], lambda x: x == best_cfgs[0]), ("slowest(%s)" % worst_cfgs[0], lambda x: x == worst_cfgs[0]), ("typed", config.is_typed), ) print( "Num. within 2x: %s" % len( self.stats_of_predicate( lambda x: self.stats_by_config[x]["mean"] < 2 * self.stats_by_config["0" * self.get_num_modules()]["mean"] ) ), file=output_port, ) print(latex.subsection("Aggregate Figures"), file=output_port) self.render_normalized( output_port, ("untyped", config.is_untyped), ("gradual", config.is_gradual), ("top %s" % len(best_cfgs), lambda x: x in best_cfgs), ("bottom %s" % len(worst_cfgs), lambda x: x in worst_cfgs), ("typed", config.is_typed), ) self.render_absolute( output_port, *[(str(n), config.has_typed_modules(n)) for n in range(self.get_num_modules())] ) baseline = self.stats_of_config("0" * self.get_num_modules())["mean"] self.render_graphs( output_port, worst_cfgs, baseline, title="Top %s slowest gradually-typed configurations" % len(worst_cfgs) ) self.render_graphs( output_port, best_cfgs, baseline, title="Top %s fastest gradually-typed configurations" % len(best_cfgs) ) # self.render_all_paths(output_port, [1,2,3,4]) # self.render_cutoff_paths(output_port) print(latex.end(), file=output_port)
# Adding identity size = len(mat) for i in range(len(mat)): add = [0] * len(mat) add[i] = 1 mat[i] += add latex_line(mat) # Eliminating for i in range(len(mat)): if is_zero(mat[i][i]): print("Can't invert the matrix.") latex.output("\\end{array}") latex.enq() latex.output("\\\\Can't invert the matrix.\n") latex.end("Inverting the matrix") exit() matrix.mult(mat, i, 1/mat[i][i]) for j in range(len(mat)): if j == i: continue matrix.add(mat, j, -mat[j][i], i) latex_line(mat) # Output invert = [] for i in range(len(mat)): invert += [[0] * size] for j in range(size): invert[i][j] = mat[i][j + size] matrix.output(invert)
print("Usage: ./summary FILE.rktd") ### Entry point, accepts a list of files. if __name__ == "__main__": if len(sys.argv) < 2: print_help() elif sys.argv[1] in ["-a", "--all", "--aggregate"]: main_aggregate(sys.argv[2::]) else: init(constants.OUTPUT_DIR) results = "%s/results.tex" % constants.OUTPUT_DIR output_port = open(results, "w") print(latex.PREAMBLE, file=output_port) print("\\begin{figure}", file=output_port) print(latex.L_HEADER, file=output_port) summs = [] for fname in sys.argv[1::]: print("\\hbox{", file=output_port) summs.append(main(fname, default_out=constants.OUTPUT_DIR, default_port=output_port)) print("}", file=output_port) print("\\caption{\\emph{L-step, M/N-usable} results for selected benchmarks.}", file=output_port) print("\\end{figure}", file=output_port) print(latex.end(), file=output_port) output_port.close() ## BEGIN HACKS os.system("cd output-summary; xelatex results.tex; cd ..;") os.system("cp output-summary/results.pdf /home/ben/Downloads/results.pdf") ## END HACKS
######### Main loop ########## if __name__ == "__main__": coeffs, b = matrix.read(sys.argv[1]) if not b: print("Invalid file :", sys.argv[1]) exit() p = len(coeffs[0]) - 1 print("Solving :") matrix.output(coeffs) latex.begin("latex.matrix") latex.beq() latex.matrix(coeffs) latex.output("\\\\") print("Triangularized :") comp = triangularize(coeffs, p) bs = base(p, comp) matrix.output(coeffs) latex.enq() if not solve(coeffs, bs, p): print("No solution.") latex.string("No solution.\n") else: print("Solution : ") output_results(bs) latex.base(bs) latex.end("Solving a linear system")