Skip to content
Snippets Groups Projects
Commit 36342444 authored by maxime.petit's avatar maxime.petit
Browse files

Added new reward func

parent 67b8b07c
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ import sys ...@@ -2,6 +2,7 @@ import sys
import random import random
import torch import torch
import torch.nn.functional as F import torch.nn.functional as F
import numpy as np
from Util import getDevice from Util import getDevice
################################################################################ ################################################################################
...@@ -152,3 +153,32 @@ def rewardE(appliable, config, action, missingLinks): ...@@ -152,3 +153,32 @@ def rewardE(appliable, config, action, missingLinks):
return reward return reward
################################################################################ ################################################################################
################################################################################
def rewardF(appliable, config, action, missingLinks):
if appliable:
if "BACK" not in action.name :
reward = -1.0*action.getOracleScore(config, missingLinks)
else :
back = action.size
error_in_pop = [i for i in range(1,back) if config.historyPop[-i][3] < 0]
last_error = error_in_pop[-1] if len(error_in_pop) > 0 else 0
reward = last_error - back
else:
reward = -3.0
return 10*reward
################################################################################
################################################################################
def rewardG(appliable, config, action, missingLinks):
if appliable:
if "BACK" not in action.name :
reward = -action.getOracleScore(config, missingLinks)
else :
back = action.size
canceledRewards = [h[3] for h in config.historyPop[-back:]]
reward = np.log(1-sum(canceledRewards)) if -sum(canceledRewards) > 0 else -1
else:
reward = -3.0
return reward
################################################################################
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment