예제 #1
0
def run_test(op=int.__add__, amt=0.2, itime=2.5):
    # import operator
    from cli_data.cli import supermath3
    import sys

    g = sys.modules['__main__'].__dict__
    lastdiff = g['lastdiff']
    i = lasti = g['i']
    ref = g['ref']

    diff = supermath3(95, 0, ref, itime, i, False)

    while True:
        print("Starting again", diff, lastdiff)
        lasti = i
        i = op(i, amt)
        lastdiff = diff
        diff = supermath3(95, 0, ref, itime, i, False)
        if diff >= lastdiff:
            diff = supermath3(95, 0, ref, itime, lasti, True)
            break

    _l = locals().copy()
    _l.pop('lasti')
    _l.pop('amt')
    _l.pop('op')
    _l.pop('itime')
    g._update_data(_l)
    # print(diff, lastdiff)
    return lasti
예제 #2
0
def test_leak():
    data = []
    from cli_data.cli import supermath3
    times, pvs = supermath3(leak_constant=0)
    data.append(times)
    data.append(pvs)
    for r in range(1, 11):
        rate = D(r) / 10
        _, pvs = supermath3(leak_constant=rate)
        data.append(pvs)

    plot(*data)
예제 #3
0
def manysuper3():
    d = 0
    last = 99999999999
    totaldiff = 0
    from officelib.xllib.xlcom import xlBook2
    from cli_data.cli import supermath3

    xl, wb = xlBook2("PID.xlsx")
    cell = wb.Worksheets(1).Cells.Range("C8")
    try:
        while True:
            totaldiff = supermath3(d)
            cell.Value = d
            d += 10
    except KeyboardInterrupt:
        pass

    return d, totaldiff
예제 #4
0
def optimal_i(i=D('2.5')):
    from cli_data.cli import supermath3
    #
    # try:
    #     del sys.modules['scripts.run.temp_sim']
    # except KeyError:
    #     pass

    i = D(i)
    ifactor = D('12')
    i_step = D(2)
    i_step_factor = D('0.5')
    i_step_min = D('1')
    ref_map = get_ref_map()
    ref_data = ref_map[str(i)]
    print(ref_data)
    ref_data = ref_data.y_data

    last_diff = supermath3(0, 0, ref_data, i, ifactor, False)
    diff = last_diff - 1
    ifactor += i_step

    _print = print
    _len = len
    false = False

    try:
        while diff:

            print("going up!", end='\n\n')
            while True:
                diff = supermath3(0, 0, ref_data, i, plot=false)
                _print("Ifactor:", ifactor, end=' ')
                _print("Totaldiff:", diff, end=' ')
                _print("Ave_diff:", diff / _len(ref_data))

                if diff > last_diff:
                    break
                lastdiff = diff
                ifactor += i_step

            i_step *= i_step_factor
            if i_step < i_step_min:
                i_step = i_step_min
            ifactor -= i_step
            print("going down!", end='\n\n')

            while True:
                diff = supermath3(0, 0, ref_data, i, plot=false)
                _print("Ifactor:", ifactor, end=' ')
                _print("Totaldiff:", diff, end=' ')
                _print("Ave_diff:", diff / _len(ref_data))
                if diff > last_diff:
                    break
                last_diff = diff
                ifactor -= i_step

            i_step *= i_step_factor
            if i_step < i_step_min:
                i_step = i_step_min
            ifactor += i_step

    except KeyboardInterrupt:
        pass

    if diff == 0:
        _print("wow!")

    supermath3(0, 0, ref_data, i, plot=True)

    return ifactor