Exemple #1
0
def solve_ins_csr(instance):
    print(f"Solving using insertion and clause-set refinement: {instance}",
          flush=True)
    f = CNF(from_file=instance).clauses

    global calls
    calls = 0

    mus = list()

    while len(f) > 0:
        solve_with = mus.copy()
        solve_with.extend(f)

        if len(solve_with) == 0:
            break

        c = solve_with.pop(-1)
        res = solve_CNF_core(solve_with)
        print(res)
        if res[0]:
            mus.append(c)
            f.pop(-1)
        else:
            f = res[1]
            for m in mus:
                f.remove(m)

    return (calls, mus)
Exemple #2
0
def solve_del(instance):
    print(f"Solving using deletion: {instance}", flush=True)
    mus = CNF(from_file=instance).clauses

    i = 0
    global calls
    calls = 0
    while i < len(mus):
        clause = mus.pop(i)

        if solve_CNF(mus):
            mus.insert(i, clause)
            i += 1

    return (calls, mus)