Exemplo n.º 1
0
def optimize_given(seq, context, bound):
    assert_normal(seq)
    antecedents = sortedset(seq.antecedents - context)
    (succedent,) = list(seq.succedents)
    POMAGMA_DEBUG('{} | {} |- {}', list(bound), list(antecedents), succedent)
    plan = optimize_plan(antecedents, succedent, bound)
    plan.validate(bound)
    return plan.cost, seq, plan
Exemplo n.º 2
0
def _test_normalize(name):
    print '# normalized'
    print
    for rule in RULE_SETS[name]:
        print rule.ascii()
        print
        if len(rule.succedents) != 1:
            print '    TODO'
            print
            continue
        for seq in sequents.normalize(rule):
            print seq.ascii(indent=4)
            print
            sequents.assert_normal(seq)
Exemplo n.º 3
0
def rank_compiled(seq, context, bound):
    assert_normal(seq)
    antecedents = seq.antecedents - context
    (succedent,) = list(seq.succedents)
    compiled = get_compiled(antecedents, succedent, bound)
    assert compiled, 'failed to compile {0}'.format(seq)
    # logger('optimizing {0} versions'.format(len(compiled)))
    ranked = []
    for s in compiled:
        s.validate(bound)
        # print 'DEBUG', '-' * 8
        # print 'DEBUG', s
        s.optimize()
        # print 'DEBUG', s
        s.validate(bound)
        ranked.append((s.cost(), s))
    return ranked