AllMixedStrategyRewards = [] AllMixedStrategyActions = [] # MixedStrategyRewards = np.zeros(variables['NumAgents']) CorrelatedEquilRewards = np.zeros(variables["NumAgents"]) # MixedStrategyActions = np.zeros(variables['NumAgents']) CorrelatedEquilActions = np.zeros(variables["NumAgents"]) C = np.zeros((2, 2)) for i in [0, 1]: for j in [0, 1]: C[i, j] = environment.calculatecapacity(Agents[i], BSs[j], 1, variables, doFading=False) for strat in analysis_helper.findPossibleStrategies(C, variables["K_coexistence"]): AllMixedStrategyRewards.append( [ analysis_helper.calcUtilityFromStrategy(0, strat, variables["K_coexistence"], C), analysis_helper.calcUtilityFromStrategy(1, strat, variables["K_coexistence"], C), ] ) AllMixedStrategyActions.append([strat[0][1], strat[1][1]]) # bestmixed = analysis_helper.findBestMixedStrategy(C, variables["K_coexistence"]) # MixedStrategyRewards = MixedStrategyRewards + [analysis_helper.calcUtilityFromStrategy(0, bestmixed, variables["K_coexistence"], C), analysis_helper.calcUtilityFromStrategy(1, bestmixed, variables["K_coexistence"], C)] # MixedStrategyActions = MixedStrategyActions + [bestmixed[0][1], bestmixed[1][1]] foundcorre, corstrat, corrrewardsloc = analysis_helper.calc_correlated_equil(C, variables["K_coexistence"]) # print(foundcorre, corstrat, corrrewardsloc) if foundcorre: CorrelatedEquilRewards = CorrelatedEquilRewards + corrrewardsloc CorrelatedEquilActions[0] = CorrelatedEquilActions[0] + 1 - corstrat CorrelatedEquilActions[1] = CorrelatedEquilActions[1] + corstrat
logsumaverageRewards[configindex][index] = math.log(epsilon +np.mean(AgentRewards[0][-100:-1]), 2) + math.log(epsilon + np.mean(AgentRewards[1][-100:-1]), 2) if configindex is 0: foundcorre = False AllMixedStrategyRewards = [] CorrelatedEquilRewards = np.zeros(variables['NumAgents']) CorrelatedEquilRewards_constrained = np.zeros(variables['NumAgents']) C = np.zeros((2, 2)) for i in [0, 1]: for j in [0, 1]: C[i,j] = environment.calculatecapacity(Agents[i], BSs[j], 1, variables, doFading=False) stratsmixed = analysis_helper.findALLPossibleStrategies(C, variables["K_coexistence"]) for j in range(0, len(stratsmixed)): u1 = epsilon + analysis_helper.calcUtilityFromStrategy(0, stratsmixed[j], variables["K_coexistence"], C) u2 = epsilon + analysis_helper.calcUtilityFromStrategy(1, stratsmixed[j], variables["K_coexistence"], C) logval = math.log(u1, 2) + math.log(u2, 2) logsumaverageRewards_MixedStrategies[j][index] = logval logsumaverageRewards_MixedMax[index] = max(logsumaverageRewards_MixedMax[index], logval) foundcorre, corstrat, corrrewardsloc = analysis_helper.calc_correlated_equil_without_constraint(C, variables["K_coexistence"]) if foundcorre: CorrelatedEquilRewards = corrrewardsloc logsumaverageRewards_Correlated[index] = math.log(epsilon +CorrelatedEquilRewards[0], 2) + math.log(epsilon + CorrelatedEquilRewards[1], 2) foundcorre, corstrat, corrrewardsloc = analysis_helper.calc_correlated_equil(C, variables["K_coexistence"]) if foundcorre: CorrelatedEquilRewards_constrained = corrrewardsloc logsumaverageRewards_CorrelatedConstrained[index] = math.log(epsilon +CorrelatedEquilRewards_constrained[0], 2) + math.log(epsilon + CorrelatedEquilRewards[1], 2) print(output_file)