Example #1
0
    'time'
]

for set in range(6):
    preFill = nol[set] * ll[set] * nof[set] // 10
    st = VVR_Sim(num_color=noc[set],
                 num_model=nom[set],
                 num_lanes=nol[set],
                 lane_length=ll[set],
                 capacity=0,
                 cc_file='./csv_files/cost.csv')
    s = Sim(num_color=noc[set],
            num_model=nom[set],
            num_lanes=nol[set],
            lane_length=ll[set],
            capacity=0,
            VVR_temp=st,
            cc_file='./csv_files/cost.csv',
            color_dist_file='./csv_files/total_orders.csv',
            repeat=0)

    repeat_epoches = 10
    # print(s.mc_tab)
    # print(s.bank.get_view_state())
    # print(s.bank.front_hist())
    # print(s.bank.front_view())

    cc_sum = 0
    t_sum = 0
    for epoch in range(repeat_epoches):
        s.reset()
Example #2
0
# for set in range(6):
set = 3
pres = [0.2, 0.4, 0.5, 0.6, 0.8]
for pref in pres:
    preFill = nol[set] * ll[set] * nof[set] // 10
    st = VVR_Sim(num_color=noc[set],
                 num_model=nom[set],
                 num_lanes=nol[set],
                 lane_length=ll[set],
                 capacity=preFill,
                 preference=pref)
    s = Sim(num_color=noc[set],
            num_model=nom[set],
            num_lanes=nol[set],
            lane_length=ll[set],
            capacity=preFill,
            VVR_temp=st,
            repeat=100,
            preference=pref)

    repeat_epoches = 1
    # print(s.mc_tab)
    # print(s.bank.get_view_state())
    # print(s.bank.front_hist())
    # print(s.bank.front_view())

    cc_sum = 0
    td_sum = 0
    t_sum = 0
    for epoch in range(repeat_epoches):
        s.reset()
Example #3
0
paras = []
noc = [10, 20, 10, 20, 10, 20]
nom = [5, 10, 5, 10, 5, 10]
ll = [6, 6, 8, 8, 10, 10]
nol = [5, 5, 7, 7, 10, 10]
nof=[7,7,6,6,6,6]
ccs=[]
data=[noc,nom,nol,ll,nof]
times=[]
columns=['colors','models','lanes','lane length', 'filling','color change']


for set in range(6):
    preFill = nol[set]*ll[set]*nof[set] // 10
    st = VVR_Sim(num_color=noc[set], num_model=nom[set], num_lanes=nol[set], lane_length=ll[set], capacity=0)
    s = Sim(num_color=noc[set], num_model=nom[set], num_lanes=nol[set], lane_length=ll[set], capacity=0, VVR_temp=st)

    repeat_epoches=10
    # print(s.mc_tab)
    # print(s.bank.get_view_state())
    # print(s.bank.front_hist())
    # print(s.bank.front_view())

    cc_sum = 0
    for epoch in range(repeat_epoches):
        start_time = time.time()
        s.reset()
        for i in range(1000):
            # sp.bank_c.state=copy.deepcopy(s.bank_c.state)
            if i%200==0:
                print(i, ' out of 1000 finihsed!     ', epoch, ' out of 10 epcoh')
Example #4
0
from Simulator import Simulator as Sim
import GraphGenerator as graph
import os as os
from DataPool import DataPool as Data
from File_handler import File_handler as fileMaintainer

if __name__ == '__main__':
    print("Welcome to COVID-19 simulator!")
    people = input("How many people would you like in the simulation? ")
    days = input("Over how many days would you like to simulate? ")
    sim = Sim(people, days)
    sim.simulate()

    while True:
        num = int(
            input(
                "Which graph would you like to check? \n Press ( 1 ) for asymptamatic \n Press ( 2 ) for symptamatic \n Press ( 3 ) for hospitalised \n Press ( 4 ) for ICU-ed \n Press ( 5 ) for ventilator cases \n Press ( 6 ) for death \n Press ( 7 ) for immune \n Press ( 8 ) for recovered \n Press ( 9 ) to exit"
            ))
        if num is 9:
            break
        age = int(
            input(
                "Press ( 1 ) for checking the trend among kids \n Press ( 2 ) for checking the trend among the youth \n Press ( 3 ) for checking the trend among the adults \n Press ( 4 ) to check overall trend "
            ))

        if num is 1:
            if age is 1:
                graph.generate(sim, sim.asympKidNum)
            if age is 2:
                graph.generate(sim, sim.asympYoungNum)
            if age is 3:
Example #5
0
from VVR_Bank import VVR_Bank as Bank
import numpy as np
from Simulator import Simulator as Sim
from VVR_Simulator import VVR_Simulator as vSim
import time

st = vSim(
    num_color=14,
    num_model=7,
    num_lanes=7,
    lane_length=8,
)
s = Sim(num_color=14,
        num_model=7,
        num_lanes=7,
        lane_length=8,
        capacity=0,
        VVR_temp=st,
        cc_file='./csv_files/cost.csv')
preFill = 30
ccsum = 0
start_time = time.time()
for rep in range(1):
    s.reset()
    for i in range(1000):
        # sp.bank_c.state=copy.deepcopy(s.bank_c.state)
        if i % 10 == 0:
            print(i, ' out of 1000 finihsed')
        if i < 2000:
            s.BBA_rule_step_in()
        if i > preFill:
Example #6
0
if __name__ == "__main__":
    """
    This is the main method to get data, setup an agent, and simulate trading.
    """
    qlearning_values = []
    buyholdvalue = 0
    rounds = 10
    for i in range(0, rounds):
        print('Starting round: ' + str(i + 1) + '/' + str(rounds))
        starting_cash = 100000
        max_position = 100
        symbol = 'TSLA'
        df = get_data()

        # Train agent, then get trades for target timeframe
        agent = Agent(max_position=max_position, starting_cash=starting_cash)
        agent.train(df, symbol)
        orders = agent.test(df, symbol)

        # simulate trades
        simulator = Sim(max_position=max_position, starting_cash=starting_cash)
        qvalue, buyholdvalue = simulator.simulate(df, symbol, orders,
                                                  i == 9)  # graph last round
        qlearning_values.append(qvalue)

    print("Policy has earned and average of: $" +
          str(round(np.average(qlearning_values) - starting_cash, 2)))
    print("BuyHold has earned: $" +
          str(round(buyholdvalue - starting_cash, 2)))