Skip to content

Commit

Permalink
Update effectiveness.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshukuno committed Mar 11, 2024
1 parent 48c13bc commit 20b501f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions popsborder/inspections.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

import numpy as np

from .inputs import get_validated_effectiveness


def inspect_first(consignment):
"""Inspect only the first box in the consignment"""
Expand Down Expand Up @@ -410,6 +412,8 @@ def inspect(config, consignment, n_units_to_inspect, detailed):
config, consignment, n_units_to_inspect
)

effectiveness = get_validated_effectiveness(config)

# Inspect selected boxes, count opened boxes, inspected items, and contaminated
# items to detection and completion
ret = types.SimpleNamespace(
Expand Down Expand Up @@ -454,7 +458,7 @@ def inspect(config, consignment, n_units_to_inspect, detailed):
ret.items_inspected_completion += 1
if not detected:
ret.items_inspected_detection += 1
if item:
if item and random.random() < effectiveness:
# Count all contaminated items in sample, regardless of
# detected variable
ret.contaminated_items_completion += 1
Expand Down Expand Up @@ -488,7 +492,7 @@ def inspect(config, consignment, n_units_to_inspect, detailed):
boxes_opened_detection.append(
math.floor(item_index / items_per_box)
)
if consignment.items[item_index]:
if consignment.items[item_index] and random.random() < effectiveness:
# Count every contaminated item in sample
ret.contaminated_items_completion += 1
if not detected:
Expand Down Expand Up @@ -522,7 +526,7 @@ def inspect(config, consignment, n_units_to_inspect, detailed):
ret.inspected_item_indexes.append(item_index)
if not detected:
ret.items_inspected_detection += 1
if item:
if item and random.random() < effectiveness:
# Count every contaminated item in sample
ret.contaminated_items_completion += 1
# If first contaminated box inspected,
Expand Down

0 comments on commit 20b501f

Please sign in to comment.