Example #1
0
    return (pop.total_iters, optmethod)


if __name__ == "__main__":
    method = sys.argv[1]
    K = 30 if method.count(',') == 0 else method.count(',') + 1
    if len(sys.argv) > 2:
        K = eval(sys.argv[2])
    maxfev = '1050' if len(sys.argv) <= 3 else sys.argv[3]

    m_opts = dict(K = K, method = method)

    # b stands for "basinhopping"
    if method.find(',') >= 0:
        shortname = 'mUNIF%d' % K
        comments = 'Iterative UNIFORM-sampling mix (%s), pop. K=%d' % (method, K)
    else:
        shortname = 'pUNIF%d_%s' % (K, method)
        comments = 'Iterative UNIFORM-sampling %s, pop. K=%d' % (method, K)
    e = Experiment(eval(maxfev), shortname, comments)

    for i in e.finstances():
        (n_iters, optmethod) = minimize_f(i, **m_opts)
        e.f.finalizerun()

        comment = ' with %d iterations' % n_iters
        if optmethod is not None:
            comment += ' (* %s)' % optmethod
        e.freport(i, comment)
Example #2
0
    method = sys.argv[1]
    K = 30 if method.count(',') == 0 else method.count(',') + 1
    if len(sys.argv) > 2:
        K = eval(sys.argv[2])
    maxfev = '1050' if len(sys.argv) <= 3 else sys.argv[3]
    eps = 0.5 if len(sys.argv) <= 4 else eval(sys.argv[4])
    accrual = 'latest' if len(sys.argv) <= 5 else sys.argv[5]

    m_opts = dict(K=K, method=method, eps=eps, accrual=accrual)

    if method.find(',') >= 0:
        shortname = 'mE%dG%d%s' % (int(
            eps * 100), K, accrual if accrual != 'latest' else '')
        comments = 'Iterative epsgreedy-sampling mix (%s), eps=%s, pop. K=%d, cr. accrual = %s' % (
            method, eps, K, accrual)
    else:
        shortname = 'pE%dG%d%s_%s' % (int(
            eps * 100), K, accrual if accrual != 'latest' else '', method)
        comments = 'Iterative epsgreedy-sampling %s, eps=%s, pop. K=%d, cr. accrual = %s' % (
            method, eps, K, accrual)
    e = Experiment(eval(maxfev), shortname, comments)

    for i in e.finstances():
        (n_iters, optmethod) = minimize_f(i, **m_opts)
        e.f.finalizerun()

        comment = ' with %d iterations' % n_iters
        if optmethod is not None:
            comment += ' (* %s)' % optmethod
        e.freport(i, comment)
Example #3
0
        cb = MMCallback(fi, f, maxfevals, mm, mmdata, n_iters)

        try:
            warnings.simplefilter("ignore") # ignore warnings about unused/ignored options
            mm(f.evalfun, x0, inner_cb = cb)
        except MMCancel:
            pass # Ok.

        n_iters = cb.n_iters

    return n_restarts


if __name__ == "__main__":
    method = sys.argv[1]
    wantrestarts = 0 if len(sys.argv) <= 2 else eval(sys.argv[2])
    maxfev = '1050' if len(sys.argv) <= 3 else sys.argv[3]

    if wantrestarts > 0:
        shortname = '%sr%d' % (method, wantrestarts)
        comments = 'Method %s with %d planned restarts' % (method, wantrestarts)
    else:
        shortname = '%s' % method
        comments = 'Method %s' % method
    e = Experiment(eval(maxfev), shortname, comments)

    for i in e.finstances():
        restarts = minimize_f(i, method, wantrestarts)
        e.f.finalizerun()
        e.freport(i, ' with %d restarts' % restarts)