コード例 #1
0
ファイル: parameterfitting.py プロジェクト: dawedawe/traipor
def pp_lmfit_fitting(plan, real_perf_values, method='leastsq'):
    '''least squares or differential evolution fitting with bounds'''
    real_perf_values = np.array(real_perf_values)
    load_scale_factor = calc_pp_load_scale_factor(plan)
    perf_scale_factor = calc_pp_perf_scale_factor(real_perf_values)
    scaled_plan = list(map(lambda l: load_scale_factor * l, plan))
    scaled_perfs = list(map(lambda p: perf_scale_factor * p, real_perf_values))
    args = (scaled_plan,
            np.array(scaled_perfs),
            calc_residuals,
            unpack_pp_lmfit_parms,
            pp_performance_over_time2)
    params = lmfit.Parameters()
    params.add(name='perfpot', value=0.5, min=0, max=1)
    params.add(name='straindelay', value=4.0, min=0.001, max=30)
    params.add(name='responsedelay', value=2.0, min=0.001, max=30)
    params.add(name='overflowdelay', value=15, min=0.001, max=30)
    lmfit.minimize(objective_f, params, method=method, args=args)
    model_perfs = pp_performance_over_time(scaled_plan,
                                           0.0,
                                           0.0,
                                           params['perfpot'],
                                           params['straindelay'],
                                           params['responsedelay'],
                                           params['overflowdelay'])
    model_perfs = filter_model_perfs_2_real_perfs(model_perfs, real_perf_values)
    scaled_perfs = list(filter(lambda x: x > 0.0, scaled_perfs))
    assert(len(model_perfs) == len(scaled_perfs))
    rmse = calc_rmse(scaled_perfs, model_perfs)
    return (((params['perfpot'].value,
            params['straindelay'].value,
            params['responsedelay'].value,
            params['overflowdelay'].value), rmse),
            load_scale_factor,
            perf_scale_factor)
コード例 #2
0
ファイル: parameterfitting.py プロジェクト: bsh2/traipor
def pp_lmfit_fitting(plan, real_perf_values, method='leastsq'):
    '''least squares or differential evolution fitting with bounds'''
    real_perf_values = np.array(real_perf_values)
    load_scale_factor = calc_pp_load_scale_factor(plan)
    perf_scale_factor = calc_pp_perf_scale_factor(real_perf_values)
    scaled_plan = list(map(lambda l: load_scale_factor * l, plan))
    scaled_perfs = list(map(lambda p: perf_scale_factor * p, real_perf_values))
    args = (scaled_plan, np.array(scaled_perfs), calc_residuals,
            unpack_pp_lmfit_parms, pp_performance_over_time2)
    params = lmfit.Parameters()
    params.add(name='perfpot', value=0.5, min=0, max=1)
    params.add(name='straindelay', value=4.0, min=0.001, max=30)
    params.add(name='responsedelay', value=2.0, min=0.001, max=30)
    params.add(name='overflowdelay', value=15, min=0.001, max=30)
    lmfit.minimize(objective_f, params, method=method, args=args)
    model_perfs = pp_performance_over_time(scaled_plan, 0.0, 0.0,
                                           params['perfpot'],
                                           params['straindelay'],
                                           params['responsedelay'],
                                           params['overflowdelay'])
    model_perfs = filter_model_perfs_2_real_perfs(model_perfs,
                                                  real_perf_values)
    scaled_perfs = list(filter(lambda x: x > 0.0, scaled_perfs))
    assert (len(model_perfs) == len(scaled_perfs))
    rmse = calc_rmse(scaled_perfs, model_perfs)
    return (((params['perfpot'].value, params['straindelay'].value,
              params['responsedelay'].value, params['overflowdelay'].value),
             rmse), load_scale_factor, perf_scale_factor)
コード例 #3
0
ファイル: parameterfitting.py プロジェクト: dawedawe/traipor
def ff_lmfit_fitting(plan, real_perf_values, method='leastsq'):
    '''least squares or differential evolution fitting with bounds'''
    real_perf_values = np.array(real_perf_values)
    args = (plan,
            real_perf_values,
            calc_residuals,
            unpack_ff_lmfit_parms,
            ff_performance_over_time2)
    params = lmfit.Parameters()
    params.add(name='initial_p',
               value=real_perf_values[0],
               min=0,
               max=max(real_perf_values))
    params.add(name='k_1', value=1.0, min=0.01, max=5.0)
    params.add(name='tau_1', value=30.0, min=1.00, max=70.0)
    params.add(name='k_2', value=1.0, min=0.01, max=5.0)
    params.add(name='tau_2', value=15.0, min=1.00, max=70.0)
    lmfit.minimize(objective_f, params, method=method, args=args)
    model_perfs = ff_performance_over_time(plan,
                                           params['initial_p'],
                                           params['k_1'],
                                           params['tau_1'],
                                           params['k_2'],
                                           params['tau_2'])
    model_perfs = filter_model_perfs_2_real_perfs(model_perfs, real_perf_values)
    real_perf_values = list(filter(lambda x: x > 0.0, real_perf_values))
    assert(len(model_perfs) == len(real_perf_values))
    rmse = calc_rmse(real_perf_values, model_perfs)
    return (params['initial_p'].value,
            params['k_1'].value,
            params['tau_1'].value,
            params['k_2'].value,
            params['tau_2'].value), rmse
コード例 #4
0
ファイル: parameterfitting.py プロジェクト: bsh2/traipor
def ff_lmfit_fitting(plan, real_perf_values, method='leastsq'):
    '''least squares or differential evolution fitting with bounds'''
    real_perf_values = np.array(real_perf_values)
    args = (plan, real_perf_values, calc_residuals, unpack_ff_lmfit_parms,
            ff_performance_over_time2)
    params = lmfit.Parameters()
    params.add(name='initial_p',
               value=real_perf_values[0],
               min=0,
               max=max(real_perf_values))
    params.add(name='k_1', value=1.0, min=0.01, max=5.0)
    params.add(name='tau_1', value=30.0, min=1.00, max=70.0)
    params.add(name='k_2', value=1.0, min=0.01, max=5.0)
    params.add(name='tau_2', value=15.0, min=1.00, max=70.0)
    lmfit.minimize(objective_f, params, method=method, args=args)
    model_perfs = ff_performance_over_time(plan, params['initial_p'],
                                           params['k_1'], params['tau_1'],
                                           params['k_2'], params['tau_2'])
    model_perfs = filter_model_perfs_2_real_perfs(model_perfs,
                                                  real_perf_values)
    real_perf_values = list(filter(lambda x: x > 0.0, real_perf_values))
    assert (len(model_perfs) == len(real_perf_values))
    rmse = calc_rmse(real_perf_values, model_perfs)
    return (params['initial_p'].value, params['k_1'].value,
            params['tau_1'].value, params['k_2'].value,
            params['tau_2'].value), rmse