diff --git a/Rl.py b/Rl.py index f0ed8f1423c730bbc24d57d2446b9bc4edb317cc..818af2ebcb3c88a4ece8f16dfb1f4ec40eb1a0a7 100644 --- a/Rl.py +++ b/Rl.py @@ -214,6 +214,27 @@ def rewardG(appliable, config, action, missingLinks): return reward ################################################################################ +################################################################################ +def rewardA(appliable, config, action, missingLinks): + if appliable: + if action.name != "BACK" : + reward = -action.getOracleScore(config, missingLinks) + else : + canceledRewards = [] + found = 0 + for i in range(len(config.historyPop))[::-1] : + if config.historyPop[i][0].name == "NOBACK" : + found += 1 + if found == action.size : + break + else : + canceledRewards.append(config.historyPop[i][3]) + reward = np.log(1-sum(canceledRewards)) if -sum(canceledRewards) > 0 else -1 + else: + reward = -forbiddenReward + return reward +################################################################################ + ################################################################################ def reward3G(appliable, config, action, missingLinks): if appliable: