From 6610d7202274cc06e272e973a2655ec463277c29 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Tue, 13 Jul 2021 17:31:40 +0200 Subject: [PATCH] Reward func --- Rl.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Rl.py b/Rl.py index f0ed8f1..818af2e 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: -- GitLab