Skip to content

Commit

Permalink
Fix weight calculation of CooldownModel
Browse files Browse the repository at this point in the history
The identifier of cooldown weights didn't contained the identifier of
the alternation only the containing rule name and the chosen alternative
index which doesn't informative enough to identify the target point.
  • Loading branch information
renatahodovan committed Oct 17, 2022
1 parent eb91428 commit 2cc3bc7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions grammarinator/runtime/cooldown_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Renata Hodovan, Akos Kiss.
# Copyright (c) 2020-2022 Renata Hodovan, Akos Kiss.
#
# Licensed under the BSD 3-Clause License
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
Expand All @@ -14,8 +14,8 @@ def __init__(self, model, weights=None, cooldown=1.0):
self._cooldown = cooldown

def choice(self, node, idx, choices):
i = self._model.choice(node, idx, [w * self._weights.get((node.name, i), 1) for i, w in enumerate(choices)])
self._weights[(node.name, i)] = self._weights.get((node.name, i), 1) * self._cooldown
i = self._model.choice(node, idx, [w * self._weights.get((node.name, idx, i), 1) for i, w in enumerate(choices)])
self._weights[(node.name, idx, i)] = self._weights.get((node.name, idx, i), 1) * self._cooldown
return i

def quantify(self, node, idx, min, max):
Expand Down

0 comments on commit 2cc3bc7

Please sign in to comment.