예제 #1
0
def solve(g, n_eqs, func):
    print('------------------------------------------------------------------')
    print('Solving problem of size', n_eqs)
    msg   = 'Size: ' + str(n_eqs)
    fname = '{0:03d}a'.format(n_eqs)
    to_pdf(g, list(irange(n_eqs)), irange(n_eqs, 2*n_eqs), msg, fname)
    #
    res = func(g, set(irange(n_eqs)))
    #
    print('Explored', res.explored, 'nodes')
    msg   = 'OPT = {}, BT: {}'.format(res.ub, res.explored)
    fname = '{0:03d}b'.format(n_eqs)
    to_pdf(g, res.rowp, res.colp, msg, fname)
    print_timestamp()
예제 #2
0
def solve(g, n_eqs):
    from plot_ordering import to_pdf
    from six.moves import xrange as range
    print('------------------------------------------------------------------')
    print('Solving problem of size', n_eqs)
    fname = '{0:03d}a'.format(n_eqs)
    to_pdf(g, list(range(n_eqs)), range(n_eqs, 2 * n_eqs), fname=fname)
    #
    rowp, colp = hellerman_rarick_p_3_5(g, set(range(n_eqs)))
    #
    fname = '{0:03d}b'.format(n_eqs)
    to_pdf(g, rowp, colp, fname=fname)
    #
    print('Plot written!')
예제 #3
0
def difficult(size):
    print('Solving patterns leading to many ties (backtracking) of size', size)
    msg = 'Size: ' + str(size)
    fname = '{0:03d}a'.format(size)
    g = create_difficult_pattern(size)
    to_pdf(g, list(irange(size)), irange(size, 2 * size), msg, fname)
    #
    solve_problem(g, set(irange(size)))
    #
    explored, g, _, rowp, colp, ub = _worst_cases[0]
    msg = 'OPT = {}, BT: {}'.format(ub, explored)
    fname = '{0:03d}b'.format(size)
    to_pdf(g, rowp, colp, msg, fname)
    _worst_cases[:] = []
    print_timestamp()
예제 #4
0
def solve_difficult_for_bb():
    filepath = 'data/worst_of_10M_runs/bb_bad_perf_n=10_c=0.5_1.pkl.gz'
    g, eqs, _ = deserialize(filepath)
    rowp, colp = solve_problem(g, eqs)[0:2]
    to_pdf(g, rowp, colp)