Esempio n. 1
0
import os
import pandas as pd
import numpy as np
from pathlib import Path
from module.simulator import Simulator

simulator = Simulator()
submission_ini = pd.read_csv(
    os.path.join(Path(__file__).resolve().parent, 'sample_submission.csv'))
order_ini = pd.read_csv(
    os.path.join(Path(__file__).resolve().parent, 'order.csv'))


class Genome():
    def __init__(self,
                 score_ini,
                 input_len,
                 output_len_1,
                 output_len_2,
                 h1=50,
                 h2=50,
                 h3=50):
        # 평가 점수 초기화
        self.score = score_ini

        # 히든레이어 노드 개수
        self.hidden_layer1 = h1
        self.hidden_layer2 = h2
        self.hidden_layer3 = h3

        # Event 신경망 가중치 생성
Esempio n. 2
0
                        # Recording the remaining BLK stock to `blk_diffs`
                        blk_diffs.append(stock.loc[stock_idx, blk_type])

        # Calculating the score
        def f_xa(x, a):
            return 1 - (x / a) if x < a else 0

        N = order.iloc[:, 1:].sum().sum()
        p = sum([abs(blk_diff) for blk_diff in blk_diffs if blk_diff < 0])
        q = sum([blk_diff for blk_diff in blk_diffs if blk_diff > 0])

        score = 50 * f_xa(p, 10 * N) + 20 * f_xa(q, 10 * N) + 30

        return score, stock


if __name__ == "__main__":
    import timeit
    from module.simulator import Simulator as Old_Simulator

    sample = pd.read_csv("Dacon_baseline.csv")
    sim = Simulator()

    start_time = timeit.default_timer()
    score, stock = sim.get_score(sample)
    print("new simulator time :", timeit.default_timer() - start_time)

    old_sim = Old_Simulator()
    start_time = timeit.default_timer()
    old_score, old_stock = old_sim.get_score(sample)
    print("old simulator time :", timeit.default_timer() - start_time)