2023-02-24 15:16:28 +08:00
|
|
|
import agentpy as ap
|
|
|
|
|
|
|
|
|
2023-02-24 17:53:55 +08:00
|
|
|
class FirmAgent(ap.Agent):
|
2023-03-14 18:53:00 +08:00
|
|
|
def setup(self, code, name, type_region, revenue_log, a_lst_product):
|
2023-02-24 15:16:28 +08:00
|
|
|
self.firm_network = self.model.firm_network
|
2023-02-27 22:02:46 +08:00
|
|
|
self.product_network = self.model.product_network
|
2023-02-24 17:53:55 +08:00
|
|
|
|
2023-06-18 21:03:11 +08:00
|
|
|
# self para
|
2023-02-24 17:53:55 +08:00
|
|
|
self.code = code
|
|
|
|
self.name = name
|
|
|
|
self.type_region = type_region
|
2023-07-02 13:00:13 +08:00
|
|
|
self.size_stat = []
|
2023-06-18 17:29:11 +08:00
|
|
|
self.dct_prod_up_prod_stat = {}
|
2023-06-18 21:03:11 +08:00
|
|
|
self.dct_prod_capacity = {}
|
2023-06-18 17:29:11 +08:00
|
|
|
|
2023-06-18 21:03:11 +08:00
|
|
|
# para in trial
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_n_trial_up_prod_disrupted = {}
|
|
|
|
self.dct_cand_alt_supp_up_prod_disrupted = {}
|
2023-02-27 22:02:46 +08:00
|
|
|
self.dct_request_prod_from_firm = {}
|
|
|
|
|
2023-06-18 21:03:11 +08:00
|
|
|
# external variable
|
2023-06-14 18:00:08 +08:00
|
|
|
self.is_prf_size = self.model.is_prf_size
|
|
|
|
self.is_prf_conn = bool(self.p.prf_conn)
|
2023-06-18 18:15:37 +08:00
|
|
|
self.str_cap_limit_prob_type = str(self.p.cap_limit_prob_type)
|
|
|
|
self.flt_cap_limit_level = float(self.p.cap_limit_level)
|
2023-05-15 18:18:41 +08:00
|
|
|
self.flt_diff_new_conn = float(self.p.diff_new_conn)
|
|
|
|
|
2023-07-02 13:00:13 +08:00
|
|
|
# init size_stat (self para)
|
2023-07-02 20:44:06 +08:00
|
|
|
# (size, time step)
|
|
|
|
self.size_stat.append((revenue_log, 0))
|
2023-07-02 13:00:13 +08:00
|
|
|
|
2023-06-18 21:03:11 +08:00
|
|
|
# init dct_prod_up_prod_stat (self para)
|
|
|
|
for prod in a_lst_product:
|
|
|
|
self.dct_prod_up_prod_stat[prod] = {
|
2023-07-02 15:03:51 +08:00
|
|
|
# (Normal / Disrupted / Removed, time step)
|
2023-07-28 15:14:59 +08:00
|
|
|
'p_stat': [('N', 0)],
|
|
|
|
# supply for each component and respective disrupted supplier
|
2023-07-28 18:07:30 +08:00
|
|
|
# set_disrupt_firm is refreshed to empty at each update
|
|
|
|
's_stat': {up_prod: {'stat': True,
|
|
|
|
'set_disrupt_firm': set()}
|
|
|
|
for up_prod in prod.a_predecessors()}
|
|
|
|
# Note: do not use fromkeys as it's a shallow copy
|
2023-06-18 21:03:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# init extra capacity (self para)
|
2023-06-18 22:12:47 +08:00
|
|
|
for product in a_lst_product:
|
2023-06-18 18:15:37 +08:00
|
|
|
# init extra capacity based on discrete uniform distribution
|
|
|
|
assert self.str_cap_limit_prob_type in ['uniform', 'normal'], \
|
|
|
|
"cap_limit_prob_type other than uniform, normal"
|
|
|
|
if self.str_cap_limit_prob_type == 'uniform':
|
|
|
|
extra_cap_mean = \
|
2023-07-02 13:00:13 +08:00
|
|
|
self.size_stat[0][0] / self.flt_cap_limit_level
|
2023-06-18 18:15:37 +08:00
|
|
|
extra_cap = self.model.nprandom.integers(extra_cap_mean-2,
|
|
|
|
extra_cap_mean+2)
|
|
|
|
extra_cap = 0 if round(extra_cap) < 0 else round(extra_cap)
|
|
|
|
self.dct_prod_capacity[product] = extra_cap
|
|
|
|
elif self.str_cap_limit_prob_type == 'normal':
|
|
|
|
extra_cap_mean = \
|
2023-07-02 13:00:13 +08:00
|
|
|
self.size_stat[0][0] / self.flt_cap_limit_level
|
2023-06-18 18:15:37 +08:00
|
|
|
extra_cap = self.model.nprandom.normal(extra_cap_mean, 1)
|
|
|
|
extra_cap = 0 if round(extra_cap) < 0 else round(extra_cap)
|
|
|
|
self.dct_prod_capacity[product] = extra_cap
|
|
|
|
|
2023-07-28 15:14:59 +08:00
|
|
|
def remove_edge_to_cus(self, disrupted_prod):
|
2023-07-02 15:03:51 +08:00
|
|
|
# para disrupted_prod is the product that self got disrupted
|
2023-03-14 18:53:00 +08:00
|
|
|
lst_out_edge = list(
|
2023-02-27 22:02:46 +08:00
|
|
|
self.firm_network.graph.out_edges(
|
|
|
|
self.firm_network.positions[self], keys=True, data='Product'))
|
2023-03-14 18:53:00 +08:00
|
|
|
for n1, n2, key, product_code in lst_out_edge:
|
2023-06-18 21:39:15 +08:00
|
|
|
if product_code == disrupted_prod.code:
|
2023-07-28 15:14:59 +08:00
|
|
|
# update customer up product supplier status
|
|
|
|
customer = ap.AgentIter(self.model, n2).to_list()[0]
|
|
|
|
for prod in customer.dct_prod_up_prod_stat.keys():
|
|
|
|
if disrupted_prod in \
|
|
|
|
customer.dct_prod_up_prod_stat[
|
|
|
|
prod]['s_stat'].keys():
|
2023-07-28 18:07:30 +08:00
|
|
|
customer.dct_prod_up_prod_stat[
|
|
|
|
prod]['s_stat'][disrupted_prod][
|
|
|
|
'set_disrupt_firm'].add(self)
|
|
|
|
print(f"{self.name} disrupt {customer.name}'s "
|
|
|
|
f"{prod.code} due to {disrupted_prod.code}")
|
2023-06-18 21:39:15 +08:00
|
|
|
# remove edge to customer
|
2023-02-27 22:02:46 +08:00
|
|
|
self.firm_network.graph.remove_edge(n1, n2, key)
|
2023-03-14 12:53:49 +08:00
|
|
|
|
2023-07-28 15:14:59 +08:00
|
|
|
def disrupt_cus_prod(self, prod, disrupted_up_prod):
|
|
|
|
# para prod is the product that has disrupted_up_prod
|
|
|
|
# para disrupted_up_prod is the product that
|
|
|
|
# self's component exists disrupted supplier
|
|
|
|
num_lost = \
|
|
|
|
len(self.dct_prod_up_prod_stat[prod]['s_stat']
|
2023-07-28 18:07:30 +08:00
|
|
|
[disrupted_up_prod]['set_disrupt_firm'])
|
2023-07-28 15:14:59 +08:00
|
|
|
num_remain = \
|
|
|
|
len([u for u, _, _, d in
|
|
|
|
self.firm_network.graph.in_edges(self.get_firm_network_node(),
|
|
|
|
keys=True,
|
|
|
|
data='Product')
|
|
|
|
if d == disrupted_up_prod.code])
|
|
|
|
lost_percent = num_lost / (num_lost + num_remain)
|
|
|
|
lst_size = \
|
|
|
|
[firm.size_stat[-1][0] for firm in self.model.a_lst_total_firms]
|
|
|
|
std_size = (self.size_stat[-1][0] - min(lst_size) + 1) \
|
|
|
|
/ (max(lst_size) - min(lst_size) + 1)
|
|
|
|
prob_disrupt = 1 - std_size * (1 - lost_percent)
|
|
|
|
if self.model.nprandom.choice([True, False],
|
|
|
|
p=[prob_disrupt,
|
|
|
|
1 - prob_disrupt]):
|
|
|
|
self.dct_n_trial_up_prod_disrupted[disrupted_up_prod] = 0
|
|
|
|
self.dct_prod_up_prod_stat[
|
|
|
|
prod]['s_stat'][disrupted_up_prod]['stat'] = False
|
|
|
|
status, _ = self.dct_prod_up_prod_stat[
|
|
|
|
prod]['p_stat'][-1]
|
|
|
|
if status != 'D':
|
|
|
|
self.dct_prod_up_prod_stat[
|
|
|
|
prod]['p_stat'].append(('D', self.model.t))
|
2023-07-28 18:07:30 +08:00
|
|
|
print(f"{self.name}'s {prod.code} turn to D status due to "
|
|
|
|
f"disrupted supplier of {disrupted_up_prod.code}")
|
2023-06-18 17:29:11 +08:00
|
|
|
|
|
|
|
def seek_alt_supply(self, product):
|
|
|
|
# para product is the product that self is seeking
|
2023-07-28 15:29:16 +08:00
|
|
|
print(f"{self.name} seek alt supply for {product.code}")
|
2023-06-18 21:39:15 +08:00
|
|
|
if self.dct_n_trial_up_prod_disrupted[
|
2023-06-18 17:29:11 +08:00
|
|
|
product] <= self.model.int_n_max_trial:
|
2023-06-18 21:39:15 +08:00
|
|
|
if self.dct_n_trial_up_prod_disrupted[product] == 0:
|
2023-06-18 17:29:11 +08:00
|
|
|
# select a list of candidate firm that has the product
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_cand_alt_supp_up_prod_disrupted[product] = \
|
2023-06-18 17:29:11 +08:00
|
|
|
self.model.a_lst_total_firms.select([
|
2023-06-18 22:12:47 +08:00
|
|
|
firm.is_prod_in_current_normal(product)
|
2023-06-18 17:29:11 +08:00
|
|
|
for firm in self.model.a_lst_total_firms
|
|
|
|
])
|
2023-06-18 21:39:15 +08:00
|
|
|
if self.dct_cand_alt_supp_up_prod_disrupted[product]:
|
2023-06-10 18:59:38 +08:00
|
|
|
# select based on connection
|
|
|
|
lst_firm_connect = []
|
2023-06-14 18:00:08 +08:00
|
|
|
if self.is_prf_conn:
|
2023-06-10 20:56:34 +08:00
|
|
|
for firm in \
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_cand_alt_supp_up_prod_disrupted[product]:
|
2023-07-27 12:56:22 +08:00
|
|
|
node_self = self.get_firm_network_node()
|
|
|
|
node_firm = firm.get_firm_network_node()
|
|
|
|
if self.model.firm_network.graph.\
|
|
|
|
has_edge(node_self, node_firm) or \
|
|
|
|
self.model.firm_network.graph.\
|
|
|
|
has_edge(node_firm, node_self):
|
2023-06-10 20:56:34 +08:00
|
|
|
lst_firm_connect.append(firm)
|
2023-06-10 18:59:38 +08:00
|
|
|
if len(lst_firm_connect) == 0:
|
2023-06-11 16:09:30 +08:00
|
|
|
# select based on size or not
|
2023-06-14 18:00:08 +08:00
|
|
|
if self.is_prf_size:
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_size = \
|
2023-07-02 15:03:51 +08:00
|
|
|
[firm.size_stat[-1][0] for firm in
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_cand_alt_supp_up_prod_disrupted[
|
2023-07-02 15:03:51 +08:00
|
|
|
product]]
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_prob = [size / sum(lst_size)
|
|
|
|
for size in lst_size]
|
|
|
|
select_alt_supply = self.model.nprandom.choice(
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_cand_alt_supp_up_prod_disrupted[product],
|
2023-06-11 16:09:30 +08:00
|
|
|
p=lst_prob)
|
|
|
|
else:
|
|
|
|
select_alt_supply = self.model.nprandom.choice(
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_cand_alt_supp_up_prod_disrupted[product])
|
2023-06-10 18:59:38 +08:00
|
|
|
elif len(lst_firm_connect) > 0:
|
2023-06-11 16:09:30 +08:00
|
|
|
# select based on size of connected firm or not
|
2023-06-14 18:00:08 +08:00
|
|
|
if self.is_prf_size:
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_firm_size = \
|
2023-07-02 13:00:13 +08:00
|
|
|
[firm.size_stat[-1][0]
|
|
|
|
for firm in lst_firm_connect]
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_prob = \
|
|
|
|
[size / sum(lst_firm_size)
|
|
|
|
for size in lst_firm_size]
|
|
|
|
select_alt_supply = \
|
|
|
|
self.model.nprandom.choice(lst_firm_connect,
|
|
|
|
p=lst_prob)
|
|
|
|
else:
|
|
|
|
select_alt_supply = \
|
|
|
|
self.model.nprandom.choice(lst_firm_connect)
|
2023-07-28 15:29:16 +08:00
|
|
|
print(
|
|
|
|
f"{self.name} selct alt supply for {product.code} "
|
|
|
|
f"from {select_alt_supply.name}"
|
|
|
|
)
|
2023-06-18 22:12:47 +08:00
|
|
|
assert select_alt_supply.is_prod_in_current_normal(product), \
|
2023-02-27 22:02:46 +08:00
|
|
|
f"{select_alt_supply} \
|
|
|
|
does not produce requested product {product}"
|
|
|
|
|
|
|
|
if product in select_alt_supply.dct_request_prod_from_firm.\
|
|
|
|
keys():
|
|
|
|
select_alt_supply.dct_request_prod_from_firm[
|
|
|
|
product].append(self)
|
|
|
|
else:
|
|
|
|
select_alt_supply.dct_request_prod_from_firm[product] = [
|
|
|
|
self
|
|
|
|
]
|
2023-07-28 15:29:16 +08:00
|
|
|
print(
|
|
|
|
select_alt_supply.name, 'dct_request_prod_from_firm', {
|
|
|
|
key.code: [v.name for v in value]
|
|
|
|
for key, value in
|
|
|
|
select_alt_supply.dct_request_prod_from_firm.items()
|
|
|
|
})
|
2023-02-27 22:02:46 +08:00
|
|
|
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_n_trial_up_prod_disrupted[product] += 1
|
2023-02-27 22:02:46 +08:00
|
|
|
|
|
|
|
def handle_request(self):
|
2023-07-28 15:29:16 +08:00
|
|
|
print(self.name, 'handle_request')
|
2023-03-14 18:53:00 +08:00
|
|
|
for product, lst_firm in self.dct_request_prod_from_firm.items():
|
2023-03-06 22:38:57 +08:00
|
|
|
if self.dct_prod_capacity[product] > 0:
|
2023-03-14 18:53:00 +08:00
|
|
|
if len(lst_firm) == 0:
|
2023-03-06 22:38:57 +08:00
|
|
|
continue
|
2023-03-14 18:53:00 +08:00
|
|
|
elif len(lst_firm) == 1:
|
|
|
|
self.accept_request(lst_firm[0], product)
|
|
|
|
elif len(lst_firm) > 1:
|
2023-03-06 22:38:57 +08:00
|
|
|
# handling based on connection
|
2023-03-16 16:08:45 +08:00
|
|
|
lst_firm_connect = []
|
2023-06-14 18:00:08 +08:00
|
|
|
if self.is_prf_conn:
|
2023-06-10 20:56:34 +08:00
|
|
|
for firm in lst_firm:
|
2023-07-27 12:56:22 +08:00
|
|
|
node_self = self.get_firm_network_node()
|
|
|
|
node_firm = firm.get_firm_network_node()
|
|
|
|
if self.model.firm_network.graph.\
|
|
|
|
has_edge(node_self, node_firm) or \
|
|
|
|
self.model.firm_network.graph.\
|
|
|
|
has_edge(node_firm, node_self):
|
2023-06-10 20:56:34 +08:00
|
|
|
lst_firm_connect.append(firm)
|
2023-03-16 16:08:45 +08:00
|
|
|
if len(lst_firm_connect) == 0:
|
2023-06-11 16:09:30 +08:00
|
|
|
# handling based on size or not
|
2023-06-14 18:00:08 +08:00
|
|
|
if self.is_prf_size:
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_firm_size = \
|
2023-07-02 13:00:13 +08:00
|
|
|
[firm.size_stat[-1][0] for firm in lst_firm]
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_prob = \
|
|
|
|
[size / sum(lst_firm_size)
|
|
|
|
for size in lst_firm_size]
|
|
|
|
select_customer = \
|
|
|
|
self.model.nprandom.choice(lst_firm,
|
|
|
|
p=lst_prob)
|
|
|
|
else:
|
|
|
|
select_customer = \
|
|
|
|
self.model.nprandom.choice(lst_firm)
|
2023-03-16 16:08:45 +08:00
|
|
|
self.accept_request(select_customer, product)
|
2023-06-10 18:59:38 +08:00
|
|
|
elif len(lst_firm_connect) > 0:
|
2023-06-11 16:09:30 +08:00
|
|
|
# handling based on size of connected firm or not
|
2023-06-14 18:00:08 +08:00
|
|
|
if self.is_prf_size:
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_firm_size = \
|
2023-07-02 13:00:13 +08:00
|
|
|
[firm.size_stat[-1][0]
|
|
|
|
for firm in lst_firm_connect]
|
2023-06-11 16:09:30 +08:00
|
|
|
lst_prob = \
|
|
|
|
[size / sum(lst_firm_size)
|
|
|
|
for size in lst_firm_size]
|
|
|
|
select_customer = \
|
|
|
|
self.model.nprandom.choice(lst_firm_connect,
|
|
|
|
p=lst_prob)
|
|
|
|
else:
|
|
|
|
select_customer = \
|
|
|
|
self.model.nprandom.choice(lst_firm_connect)
|
2023-03-16 16:08:45 +08:00
|
|
|
self.accept_request(select_customer, product)
|
2023-07-02 15:08:02 +08:00
|
|
|
else:
|
|
|
|
for down_firm in lst_firm:
|
|
|
|
down_firm.dct_cand_alt_supp_up_prod_disrupted[
|
|
|
|
product].remove(self)
|
|
|
|
|
2023-07-28 15:29:16 +08:00
|
|
|
print(
|
|
|
|
f"{self.name} denied {product.code} request "
|
|
|
|
f"from {down_firm.name} for lack of capacity"
|
|
|
|
)
|
2023-02-27 22:02:46 +08:00
|
|
|
|
|
|
|
def accept_request(self, down_firm, product):
|
2023-06-18 17:29:11 +08:00
|
|
|
# para product is the product that self is selling
|
2023-07-27 12:50:52 +08:00
|
|
|
# connected firm has no probability
|
|
|
|
node_self = self.get_firm_network_node()
|
|
|
|
node_d_firm = down_firm.get_firm_network_node()
|
|
|
|
if self.model.firm_network.graph.has_edge(node_self, node_d_firm) or \
|
|
|
|
self.model.firm_network.graph.has_edge(node_d_firm, node_self):
|
|
|
|
prod_accept = 1.0
|
|
|
|
else:
|
|
|
|
prod_accept = self.flt_diff_new_conn
|
2023-03-14 18:53:00 +08:00
|
|
|
if self.model.nprandom.choice([True, False],
|
|
|
|
p=[prod_accept, 1 - prod_accept]):
|
2023-03-14 12:53:49 +08:00
|
|
|
self.firm_network.graph.add_edges_from([
|
|
|
|
(self.firm_network.positions[self],
|
2023-03-14 18:53:00 +08:00
|
|
|
self.firm_network.positions[down_firm], {
|
|
|
|
'Product': product.code
|
2023-05-15 13:37:05 +08:00
|
|
|
})
|
2023-03-14 12:53:49 +08:00
|
|
|
])
|
|
|
|
self.dct_prod_capacity[product] -= 1
|
|
|
|
self.dct_request_prod_from_firm[product].remove(down_firm)
|
2023-06-18 17:29:11 +08:00
|
|
|
|
|
|
|
for prod in down_firm.dct_prod_up_prod_stat.keys():
|
|
|
|
if product in down_firm.dct_prod_up_prod_stat[
|
2023-07-28 18:07:30 +08:00
|
|
|
prod]['s_stat'].keys():
|
2023-06-18 17:29:11 +08:00
|
|
|
down_firm.dct_prod_up_prod_stat[
|
2023-07-28 18:07:30 +08:00
|
|
|
prod]['s_stat'][product]['stat'] = True
|
2023-06-18 17:29:11 +08:00
|
|
|
down_firm.dct_prod_up_prod_stat[
|
2023-07-28 15:14:59 +08:00
|
|
|
prod]['p_stat'].append(('N', self.model.t))
|
2023-06-18 21:39:15 +08:00
|
|
|
del down_firm.dct_n_trial_up_prod_disrupted[product]
|
|
|
|
del down_firm.dct_cand_alt_supp_up_prod_disrupted[product]
|
2023-06-18 17:29:11 +08:00
|
|
|
|
2023-07-28 15:29:16 +08:00
|
|
|
print(
|
|
|
|
f"{self.name} accept {product.code} request "
|
|
|
|
f"from {down_firm.name}"
|
|
|
|
)
|
2023-05-15 13:37:05 +08:00
|
|
|
else:
|
2023-06-18 21:39:15 +08:00
|
|
|
down_firm.dct_cand_alt_supp_up_prod_disrupted[product].remove(self)
|
2023-02-27 22:02:46 +08:00
|
|
|
|
2023-07-28 15:29:16 +08:00
|
|
|
print(
|
|
|
|
f"{self.name} denied {product.code} request "
|
|
|
|
f"from {down_firm.name}"
|
|
|
|
)
|
2023-07-02 13:00:13 +08:00
|
|
|
|
2023-02-27 22:02:46 +08:00
|
|
|
def clean_before_trial(self):
|
|
|
|
self.dct_request_prod_from_firm = {}
|
2023-03-07 12:29:27 +08:00
|
|
|
|
|
|
|
def clean_before_time_step(self):
|
2023-06-18 21:39:15 +08:00
|
|
|
self.dct_n_trial_up_prod_disrupted = \
|
|
|
|
dict.fromkeys(self.dct_n_trial_up_prod_disrupted.keys(), 0)
|
|
|
|
self.dct_cand_alt_supp_up_prod_disrupted = {}
|
2023-06-05 10:47:37 +08:00
|
|
|
|
2023-07-02 23:16:05 +08:00
|
|
|
# update the status of firm
|
|
|
|
for prod in self.dct_prod_up_prod_stat.keys():
|
2023-07-28 15:14:59 +08:00
|
|
|
status, ts = self.dct_prod_up_prod_stat[prod]['p_stat'][-1]
|
2023-07-02 23:16:05 +08:00
|
|
|
if ts != self.model.t:
|
2023-07-28 15:14:59 +08:00
|
|
|
self.dct_prod_up_prod_stat[prod]['p_stat'].append(
|
2023-07-02 23:16:05 +08:00
|
|
|
(status, self.model.t))
|
2023-07-28 18:07:30 +08:00
|
|
|
# refresh set_disrupt_firm
|
2023-07-28 15:14:59 +08:00
|
|
|
for up_prod in self.dct_prod_up_prod_stat[prod]['s_stat'].keys():
|
|
|
|
self.dct_prod_up_prod_stat[prod][
|
2023-07-28 18:07:30 +08:00
|
|
|
's_stat'][up_prod]['set_disrupt_firm'] = set()
|
2023-07-02 23:16:05 +08:00
|
|
|
|
2023-06-05 10:47:37 +08:00
|
|
|
def get_firm_network_node(self):
|
|
|
|
return self.firm_network.positions[self]
|
2023-06-18 22:12:47 +08:00
|
|
|
|
|
|
|
def is_prod_in_current_normal(self, prod):
|
|
|
|
if prod in self.dct_prod_up_prod_stat.keys():
|
2023-07-28 15:14:59 +08:00
|
|
|
if self.dct_prod_up_prod_stat[prod]['p_stat'][-1][0] == 'N':
|
2023-06-18 22:12:47 +08:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return False
|