Пример #1
0
def randomSetting(seed, W, AI, K, R, mR, M, P, teams, shift):
    # ========================== Random Seed ===================================
    #seed = 3234
    #seed = random.randint(1,10000)
    np.random.seed(seed)
    random.seed(seed)

    T = len(teams)

    resource2team = util.resourceTeamDict(R, T, teams)

    Er, C = util.genResources(R, M, 200)
    E = util.computeTeamsRate(R, M, T, teams, Er)
    print E

    # suppose this is a zero-sum game
    U_plus = []  # covered (plus) utility of the defender
    U_minus = []  # uncovered (minus) utility of the defender
    for i in range(K):
        tmp_plus_utility = 0  #random.randint(100,500)
        U_plus.append(tmp_plus_utility)
        tmp_minus_utility = -random.randint(500, 2000)
        U_minus.append(tmp_minus_utility)

    N_wk = [
        [0 for k in range(K)] for w in range(W)
    ]  # N_wk[w][k] represents the number of people getting in time window w with type k

    N_wk = np.zeros((W, K))
    for k in range(K):
        startK = random.randint(AI, W)
        for w in range(startK - AI, startK):
            large_or_small = random.random()
            if large_or_small > 0.5:
                tmp_N = random.randint(150, 200)
            else:
                tmp_N = random.randint(10, 30)
            N_wk[w][k] = tmp_N

    mr = np.random.randint(5, 15, R)

    ar = np.random.randint(1, 3, R)

    phi = np.random.rand(R)  # phi[r] overflow penalty

    return resource2team, T, Er, E, C, U_plus, U_minus, N_wk, shift, mr, ar, phi
Пример #2
0
def randomSetting(seed, W, K, R, mR, M, P, teams, shift):
    # ========================== Random Seed ===================================
    #seed = 3234
    #seed = random.randint(1,10000)
    np.random.seed(seed)
    random.seed(seed)

    T = len(teams)
    print T
    resource2team = util.resourceTeamDict(R, T, teams)
    print resource2team

    Er = np.random.rand(R, M) / 2 + 0.5  # Er[m][r]
    Er = Er / 2
    print "Er"
    print Er

    Er, C = util.genResources(R, M, 600)
    E = util.computeTeamsRate(R, M, T, teams, Er)
    print E

    # suppose this is a zero-sum game
    U_plus = []  # covered (plus) utility of the defender
    U_minus = []  # uncovered (minus) utility of the defender
    for i in range(K):
        tmp_plus_utility = 0  #random.randint(100,500)
        U_plus.append(tmp_plus_utility)
        tmp_minus_utility = -random.randint(500, 2000)
        U_minus.append(tmp_minus_utility)
    print "\nutilities"
    print "plus"
    print U_plus
    print "minus"
    print U_minus

    N_wk = [
        [0 for k in range(K)] for w in range(W)
    ]  # N_wk[w][k] represents the number of people getting in time window w with type k

    #arrival_window= np.minimum(3,W)

    N_wk = np.zeros((W, K))
    for k in range(K):
        startK = random.randint(3, W)
        for w in range(startK - 3, startK):
            large_or_small = random.random()
            if large_or_small > 0.5:
                tmp_N = random.randint(50, 200)
            else:
                tmp_N = random.randint(10, 30)
            N_wk[w][k] = tmp_N
    """        
    for w in range(W):
        N_wk.append([])
        for k in range(K):
            large_or_small = random.random()
            if large_or_small > 0.5:
                tmp_N = random.randint(100, 300)
            else:
                tmp_N = random.randint(10, 30)
            N_wk[w].append(tmp_N)
    """
    #    print "number of passengers: {0}".format([sum(N_wk[w]) for w in range(W)])

    #C = np.random.randint(200, 500, R) # C[r] is the capacity of resource r
    #   print "\nC"
    #  print C
    #C = [100,80,75,50,30,15]
    mr = np.random.randint(5, 15, R)
    #   print "\nmr"
    #  print mr
    #mr = [5, 5, 5, 3, 2, 4] # maximum number of people to operate resource r
    ar = np.random.randint(1, 5, R)
    #   print "\nar"
    #  print ar
    #ar = [2, 1, 2, 1, 1, 2] # ar[r] number of people required to operate resource r

    phi = np.random.rand(R)  # phi[r] overflow penalty
    # print "\nphi"
    #print phi
    #phi = np.random.rand(W, R) # phi[w][r] overflow penalty

    return resource2team, T, Er, E, C, U_plus, U_minus, N_wk, shift, mr, ar, phi
Пример #3
0
def randomSetting(seed, W, K, R, mR, M, P, teams, shift):
    # ========================== Random Seed ===================================
    #seed = 3234
    #seed = random.randint(1,10000)
    np.random.seed(seed)
    random.seed(seed)

    T = len(teams)
    resource2team = util.resourceTeamDict(R, T, teams)
    print resource2team

    Er = np.random.rand(R, M) / 2 + 0.5  # Er[m][r]
    Er = Er / 2
    print "Er"
    print Er
    #Er = [[0.3, 0.5, 0.2], [0.6, 0.3, 0.4], [0.4, 0.6, 0.5]
    #     ,[0.6, 0.3, 0.8], [0.7, 0.4, 0.7], [0.7, 0.6, 0.9]]

    Er, C = util.genResources(R, M, 100)
    E = util.computeTeamsRate(R, M, T, teams, Er)
    print E

    # RatesEr = [0.357, 0.916, 0.511, 0.916, 1.204, 1.204,
    #     0.693, 0.357, 0.916, 0.357, 0.511, 0.916,
    #     0.223, 0.511, 0.693, 1.609, 1.204, 2.303]

    # suppose this is a zero-sum game
    U_plus = []  # covered (plus) utility of the defender
    U_minus = []  # uncovered (minus) utility of the defender
    for i in range(K):
        tmp_plus_utility = 0  #random.randint(100,500)
        U_plus.append(tmp_plus_utility)
        tmp_minus_utility = -random.randint(500, 2000)
        U_minus.append(tmp_minus_utility)
    print "\nutilities"
    print "plus"
    print U_plus
    print "minus"
    print U_minus

    N_wk = [
        [0 for k in range(K)] for w in range(W)
    ]  # N_wk[w][k] represents the number of people getting in time window w with type k

    arrival_window = 3

    for k in range(K):
        flight_time = random.randint(0, W - arrival_window) + arrival_window
        for w in range(flight_time - arrival_window, flight_time):
            large_or_small = random.random()
            if large_or_small > 0.5:
                tmp_N = random.randint(100, 300)
            else:
                tmp_N = random.randint(10, 30)
            N_wk[w][k] = tmp_N
    """        
    for w in range(W):
        N_wk.append([])
        for k in range(K):
            large_or_small = random.random()
            if large_or_small > 0.5:
                tmp_N = random.randint(100, 300)
            else:
                tmp_N = random.randint(10, 30)
            N_wk[w].append(tmp_N)
    """
    print "number of passengers: {0}".format([sum(N_wk[w]) for w in range(W)])

    #C = np.random.randint(200, 500, R) # C[r] is the capacity of resource r
    print "\nC"
    print C
    #C = [100,80,75,50,30,15]
    mr = np.random.randint(10, 30, R)
    print "\nmr"
    print mr
    #mr = [5, 5, 5, 3, 2, 4] # maximum number of people to operate resource r
    ar = np.random.randint(1, 5, R)
    print "\nar"
    print ar
    #ar = [2, 1, 2, 1, 1, 2] # ar[r] number of people required to operate resource r

    phi = np.random.rand(R) / 10  # phi[r] overflow penalty
    print "\nphi"
    print phi
    #phi = np.random.rand(W, R) # phi[w][r] overflow penalty

    return resource2team, T, E, C, U_plus, U_minus, N_wk, shift, mr, ar, phi