if ans_out is not None: fmt = '%.' + str(tolerance) + 'f' str_ans_corr = fmt % ans_corr str_ans_out = fmt % ans_out if str_ans_corr == str_ans_out: outcome = CORRECT else: print >> sys.stderr, "correctness FAILED: %s (correct is %s, output had %s)" % (ppinput(input_graph), str_ans_corr, str_ans_out) outcome = INCORRECT # log the result of the correctness check if rev is not None and run is not None: if ti is None: ti = __get_ti(input_graph) data = CorrResult(ti.dims, ti.min, ti.max, ti.num_verts, ti.num_edges, ti.seed, rev, run, outcome) try: DataSet.add_data_to_log_file(data) print 'logged correctness result to ' + data.get_path() except DataError, e: fmt = "Unable to log result to file %s (correct is %s, output had %s): %s" print >> sys.stderr, fmt % (ppinput(input_graph), str_ans_corr, str_ans_out, e) return outcome def main(argv=sys.argv[1:]): usage = """usage: %prog [options] INPUT_GRAPH OUTPUT_TO_CHECK Checks the validity of an MST. Exits with code 0 on success. Otherwise, it prints an error message and exits with a non-zero code. Does not log the result.""" parser = OptionParser(usage) parser.add_option("-f", "--force-recompute",
# handle -i, -l: collect data for a particular graph(s) if options.input_graph and options.inputs_list_file: parser.error('-i and -l are mutually exclusive') if options.input_graph is not None: try: i = extract_input_footer(options.input_graph) except ExtractInputFooterError, e: parser.error(e) input_solns = DataSet({0:InputSolution(i.prec,i.dims,i.min,i.max,i.num_verts,i.num_edges,i.seed)}) elif options.inputs_list_file is not None: input_solns = DataSet.read_from_file(InputSolution, options.inputs_list_file) # prepare for a correctness data collection if options.correctness: num_on += 1 get_results_for_rev = lambda rev : DataSet.read_from_file(CorrResult, CorrResult.get_path_to(rev)) options.inputs_list_file_arg = '' if options.inputs_list_file is None else ' -l ' + options.inputs_list_file collect_missing_data = lambda w,x,y,z: collect_missing_correctness_data(w,x,y,z,options.inputs_list_file_arg) # make sure no more than 1 type of data collection was specified if num_on > 1: parser.error('at most one of -c, -d, and -e may be specified') elif num_on == 0: # prepare for a performance data collection (default if nothing else is specified) get_results_for_rev = lambda rev : DataSet.read_from_file(PerfResult, PerfResult.get_path_to(rev)) collect_missing_data = collect_missing_performance_data # prepare the inputs and revisions for non-weight data collection schemes if options.num_vertices == 0: # get all performance inputs if we are not collecting for a single graph if input_solns is None: