Пример #1
0
def analyse(in_files: str, out_file: str):
    """
    Creates a summary file for the passed-in in-files, at the out-file
    location. This file summarises all passed-in instances.
    """
    file = Path(out_file)

    if file.exists():
        last_modified = file.lstat().st_mtime
        timestamp = datetime.fromtimestamp(last_modified)

        print(f"Printing {out_file} (last modified {timestamp})")
        instances = pd.read_csv(out_file, skipfooter=1, engine="python")
    else:
        instances = pd.DataFrame()

        for location in glob.iglob(in_files):
            problem = Problem.from_file(location, delimiter=',')
            sol = Solution.from_file(f"solutions/oracs_{problem.instance}.csv")

            instance = dict([(func.__name__, func(sol))
                             for func in PARAMETERS + STATISTICS])

            instances = instances.append(instance, ignore_index=True)

    report = make_pivot_table(instances)

    if not file.exists():
        report.to_csv(out_file)

    print(report)
Пример #2
0
def main():
    if len(sys.argv) < 2:
        raise ValueError(f"{sys.argv[0]}: expected file location.")

    problem = Problem.from_file(sys.argv[1], delimiter=',')
    solution = Solution.from_file(f"solutions/oracs_{problem.instance}.csv")

    is_feasible = True

    for idx, rule in enumerate(RULES):
        result, message = rule(solution)

        print(f"{idx}: {message}")

        if not result:
            is_feasible = False

    exit(0 if is_feasible else 1)