Skip to content

Commit

Permalink
Visit probability restricted to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
arindamsaha1507 committed Feb 8, 2024
1 parent 70d60d8 commit 7ec6682
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion facs/base/household.py
Expand Up @@ -45,7 +45,7 @@ def __post_init__(self):
raise ValueError("Household size must be at least 1.")

if self.size > 4:
warn("Household size is greater than 4.")
warn(f"Household size {self.size} is greater than 4.")

for _ in range(self.size):
self.agents.append(Person(self.house, self, self.ages))
Expand Down
3 changes: 3 additions & 0 deletions facs/base/location.py
Expand Up @@ -75,6 +75,9 @@ def register_visit(self, e, person, need, deterministic=False):
else:
return

if visit_probability > 1.0:
visit_probability = 1.0

if deterministic:
self.visit_probability_counter += min(visit_probability, 1)
if self.visit_probability_counter > 1.0:
Expand Down
2 changes: 1 addition & 1 deletion facs/base/utils.py
Expand Up @@ -18,7 +18,7 @@ def probability(prob):
"""Return True with probability prob."""

if prob < 0 or prob > 1:
raise ValueError("prob must be between 0 and 1")
raise ValueError(f"Probability (currently {prob}) must be between 0 and 1.")

return np.random.random() < prob

Expand Down

0 comments on commit 7ec6682

Please sign in to comment.