Exemple #1
0
def env_reset():
    # Generate the channel gain for next time slot
    channel_d= np.random.exponential() * A_d * (light / (4 * 3.141592653589793 * F_c * distv[0]))**degree
    #s=np.array([channel_d,random.randint(0,3),random.randint(0,1),random.randint(0,1),random.randint(0,1),random.randint(0,1)])
    s=np.zeros((N_S,))
    s[0]=channel_d
    s[1]=random.randint(0,3)
    if random.random()<0.01:
        u=np.expand_dims(np.array([random.randint(0,3),random.randint(0,2),truc_norm()]), axis=0)
    elif random.random()<0.1:
        u=np.array([[random.randint(0,3),random.randint(0,2),truc_norm()],[random.randint(0,3),random.randint(0,2),truc_norm()]])
    else:
        u=np.array([[random.randint(0,3),random.randint(0,2),truc_norm()],[random.randint(0,3),random.randint(0,2),truc_norm()],[random.randint(0,3),random.randint(0,2),truc_norm()]])
    for i in range(history_length):
        action=np.array([random.randint(0,3),random.randint(0,1),random.randint(0,1),random.randint(0,1),random.randint(0,1)])
        _, s_, u_ ,_,_,_= env(action,s.squeeze(),u)
        s=s_
        u=u_
    return action,s,u
Exemple #2
0
def user_transit(users,provider_set):
    new_users=[]
    cur_qoe=0
    for i in range(users.shape[0]):
        if random.random()>d_rate[users[i,1]]:
            #the user doesnot departure
            #new_u=
            bit,qoe=user_mod(provider_set,users[i,1],users[i,0],users[i,2])
            #print(qoe)
            new_users.append([bit,users[i,1],users[i,2]])
            cur_qoe+=qoe
            #New Arrival
    for i in range(3):
        if random.random()<a_rate[i]:
            distance=truc_norm()
            bit,qoe=user_mod(provider_set,i,random.randint(0,num_of_bitrate-1),distance)
            new_users.append([bit,i,distance])
            cur_qoe+=qoe
            #new_users.append([,i])
    return np.array(new_users),cur_qoe