예제 #1
0
def nominee_runs(player, computer, day_results):
    """
    Scheme of 2 nominee runs in Player's matches.
    In speedway each team picks best riders for two last runs (14 and 15 run).
    """
    run_squads = []
    all_runs_squads = []
    for num in range(2):
        run_squads.append(computer.nominee[0])
        computer.nominee.pop(0)
        run_squads.append(computer.nominee[0])
        computer.nominee.pop(0)
        run_squads.append(player.nominee[0])
        player.nominee.pop(0)
        run_squads.append(player.nominee[0])
        player.nominee.pop(0)
        all_runs_squads.append(run_squads)
        run_squads = []
    run_num = 14
    results = None
    for run in all_runs_squads:
        print("\n W biegu nr: ", run_num, "pojadą: \n")
        print(run[0].name + " " + run[0].surname + " (" + run[0].team_name +
              ") " + str(run[0].match_stats) + "\n" + run[1].name + " " +
              run[1].surname + " (" + run[1].team_name + ") " +
              str(run[1].match_stats) + "\n" + run[2].name + " " +
              run[2].surname + " (" + run[2].team_name + ") " +
              str(run[2].match_stats) + "\n" + run[3].name + " " +
              run[3].surname + " (" + run[3].team_name + ") " +
              str(run[3].match_stats) + "\n")
        run = single_run_menu(run, player, computer)
        single_run(run, run_num)
        run_num += 1
        if player.riders[0].home:
            print(player.team_name + " " + str(player.match_points) + " : " +
                  str(computer.match_points) + " " + computer.team_name)
            results = player.team_name + " " + str(player.match_points) + " : " + str(computer.match_points) + \
                " " + computer.team_name
        else:
            print(computer.team_name + " " + str(computer.match_points) +
                  " : " + str(player.match_points) + " " + player.team_name)
            results = computer.team_name + " " + str(computer.match_points) + " : " + str(player.match_points) + \
                " " + player.team_name
    day_results.append(results)
예제 #2
0
def thirteen_regular_runs(player, computer):
    """ Scheme of 13 regular runs in Player's matches."""
    RUNS = ((0, 1, 0, 1), (5, 6, 5, 6), (2, 3, 2, 3), (4, 6, 4, 6),
            (0, 1, 2, 3), (2, 3, 4, 5), (4, 5, 0, 1), (0, 1, 4, 6),
            (2, 3, 0, 1), (4, 6, 2, 3), (1, 2, 1, 4), (0, 5, 2, 5), (3, 4, 0,
                                                                     3))
    # RUNS is official runs scheme from Polish speedway league.
    # First two numbers in single run represents home riders numbers, next two represents away riders numbers
    run_squads = []
    all_runs_squads = []
    for num in range(13):
        run_squads.append(computer.match_team[RUNS[num][0]])
        run_squads.append(computer.match_team[RUNS[num][1]])
        run_squads.append(player.match_team[RUNS[num][2]])
        run_squads.append(player.match_team[RUNS[num][3]])
        all_runs_squads.append(run_squads)
        run_squads = []
    run_num = 1
    for run in all_runs_squads:
        print("\n W biegu nr: ", run_num, "pojadą: \n")
        print(run[0].name + " " + run[0].surname + " (" + run[0].team_name +
              ") " + str(run[0].match_stats) + "\n" + run[1].name + " " +
              run[1].surname + " (" + run[1].team_name + ") " +
              str(run[1].match_stats) + "\n" + run[2].name + " " +
              run[2].surname + " (" + run[2].team_name + ") " +
              str(run[2].match_stats) + "\n" + run[3].name + " " +
              run[3].surname + " (" + run[3].team_name + ") " +
              str(run[3].match_stats) + "\n")
        run = single_run_menu(run, player, computer)
        single_run(run, run_num)
        run_num += 1
        if player.riders[0].home:
            # In speedway home team name is always shown on the lef side of score, away team name on the right side
            print("\t\t\t" + player.team_name + " " +
                  str(player.match_points) + " : " +
                  str(computer.match_points) + " " + computer.team_name)
        else:
            print("\t\t\t" + computer.team_name + " " +
                  str(computer.match_points) + " : " +
                  str(player.match_points) + " " + player.team_name)
예제 #3
0
ret_sub.loc[:, 'Ret-56'] = (ret_sub['Return'].shift(55))

ret_sub.loc[:, 'Ret-57'] = (ret_sub['Return'].shift(56))

ret_sub.loc[:, 'Ret-58'] = (ret_sub['Return'].shift(57))

ret_sub.loc[:, 'Ret-59'] = (ret_sub['Return'].shift(58))

ret_sub.loc[:, 'Ret-60'] = (ret_sub['Return'].shift(59))

# return forward 1
ret_sub.loc[:, 'ExRet_f1'] = ret_sub['ExRet'].shift(-1)
ret_sub.dropna(inplace=True)
feature = ret_sub[feature_list]

teststart = len(
    ret_sub[ret_sub['YM'] < 200512]
)  # note: it's <199912 not <=, so that the first month of test would be predicting 200001 using feature observed at 199912

if __name__ == '__main__':
    print(os.getcwd())
    Y_pred_df = single_run(test_year, feature.values,
                           ret_sub['ExRet_f1'].values, filename)
    print(os.getcwd())
    # make a folder to store result
    folder = './result_new/'
    if not os.path.exists(folder):
        os.makedirs(folder)
    # save data
    Y_pred_df.to_csv(os.path.join(folder, filename + '_yhat.csv'))
예제 #4
0
for rt in routing:
    for pw in TxPw:
        for mc in MAC:
            for n in nodes:
                if mc == ',CSMA':
                    mc_label = 'CSMA'
                else:
                    mc_label = 'TDMA'
                if rt == ',star':
                    rt_label = 'Star'
                else:
                    rt_label = 'Mesh'
                if pw == ',varyTxPower=\\\"0dBm\\\"':
                    pw_label = '0dBm'
                elif pw == ',varyTxPower=\\\"-10dBm\\\"':
                    pw_label = '-10dBm'
                else:
                    pw_label = '-20dBm'
                print('Running sim ' + str(sim_ind) + '/' + str(total_sims))
                sim_ind += 1
                label = str(
                    n) + '|' + mc_label + '|' + pw_label + '|' + rt_label
                res = single_run(n, rt, mc, pw, rate, sim_time)
                results.append([label, res[0], res[1], res[2]])

for i in range(len(results)):
    text_file.write(results[i][0] + '\t' + str(results[i][1] * 100) + '\t' +
                    str(results[i][2]) + '\t' + str(results[i][3]) + '\n')

text_file.close()
예제 #5
0
파일: main.py 프로젝트: 2015dingm/Fintech
    # return forward 1
    ret_sub.loc[:, 'ExRet_f1'] = ret_sub['ExRet'].shift(-1)
    ret_sub.dropna(inplace=True)
    feature_num = len(ret_sub)
    teststart = len(
        ret_sub[ret_sub['YM'] < 200512]
    )  # note: it's <199912 not <=, so that the first month of test would be predicting 200001 using feature observed at 199912

    feature_sub_list.append(ret_sub[feature_list])
    exret_sub_list.append(ret_sub['ExRet_f1'])
    teststart_list.append(teststart)
    feature_num_list.append(feature_num)

feature = pd.concat(feature_sub_list, axis=0, ignore_index=True)
exret = pd.concat(exret_sub_list, axis=0, ignore_index=True)

if __name__ == '__main__':
    print(os.getcwd())
    Y_pred_df = single_run(test_year, feature, exret, filename)
    print(os.getcwd())
    # make a folder to store result
    folder = './result_new/'
    if not os.path.exists(folder):
        os.makedirs(folder)
    # save data
    for asset in range(1, 56):
        Y_pred_df[asset - 1].to_csv(
            os.path.join(folder,
                         filename + '_asset' + str(asset) + '_yhat.csv'))