Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsilver committed Dec 12, 2023
1 parent c01936d commit d078cb4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions predicators/explorers/active_sampler_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,23 +371,20 @@ def _get_option_policy_for_task(self,

def _score_ground_op(
self, ground_op: _GroundSTRIPSOperator) -> Tuple[float, ...]:
history = self._ground_op_hist[ground_op]
num_tries = len(history)
success_rate = sum(history) / num_tries
total_trials = sum(len(h) for h in self._ground_op_hist.values())
# UCB-like bonus.
c = CFG.active_sampler_explore_bonus
bonus = c * np.sqrt(np.log(total_trials) / num_tries)
if CFG.active_sampler_explore_task_strategy == "planning_progress":
score = self._score_ground_op_planning_progress(ground_op)
if CFG.active_sampler_explore_use_ucb_bonus:
# UCB-like bonus.
c = CFG.active_sampler_explore_bonus
bonus = c * np.sqrt(np.log(total_trials) / num_tries)
score += bonus
elif CFG.active_sampler_explore_task_strategy == "success_rate":
history = self._ground_op_hist[ground_op]
num_tries = len(history)
success_rate = sum(history) / num_tries
total_trials = sum(len(h) for h in self._ground_op_hist.values())
score = (1.0 - success_rate)
if CFG.active_sampler_explore_use_ucb_bonus:
# UCB-like bonus.
c = CFG.active_sampler_explore_bonus
bonus = c * np.sqrt(np.log(total_trials) / num_tries)
score += bonus
elif CFG.active_sampler_explore_task_strategy == "random":
# Random scores baseline.
Expand Down

0 comments on commit d078cb4

Please sign in to comment.