without_exp

This commit is contained in:
HaoYizhi 2023-05-21 12:35:27 +08:00
parent 94583af801
commit b4e9512439
9 changed files with 20 additions and 17 deletions

4
.vscode/launch.json vendored
View File

@ -12,8 +12,8 @@
"console": "integratedTerminal", "console": "integratedTerminal",
"justMyCode": true, "justMyCode": true,
"args": [ "args": [
"--exp", "test", "--exp", "without_exp",
"--reset_db", "True" "--job", "24",
] ]
} }
] ]

3
SQL_running_check.sql Normal file
View File

@ -0,0 +1,3 @@
select id, e_id, idx_sample, seed, ts_done from iiabmdb.without_exp_sample where is_done_flag != -1;
select count(id) from iiabmdb.without_exp_sample where is_done_flag != -1;
select count(id) from iiabmdb.without_exp_sample;

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
db_name_prefix: test db_name_prefix: without_exp

View File

@ -53,7 +53,7 @@ class ControllerDB:
dct = {code: [product_code]} dct = {code: [product_code]}
list_dct.append(dct) list_dct.append(dct)
# list_dct = [{'140': ['1.4.5.1']}] # list_dct = [{'140': ['1.4.5.1']}]
list_dct = [{'133': ['1.4.4.1']}] # list_dct = [{'133': ['1.4.4.1']}]
# list_dct = [{'2': ['1.1.3']}] # list_dct = [{'2': ['1.1.3']}]
# list_dct = [{'135': ['1.3.2.1']}] # list_dct = [{'135': ['1.3.2.1']}]
# list_dct = [{'79': ['2.1.3.4']}] # list_dct = [{'79': ['2.1.3.4']}]

20
firm.py
View File

@ -63,7 +63,7 @@ class FirmAgent(ap.Agent):
def seek_alt_supply(self): def seek_alt_supply(self):
for product in self.a_lst_up_product_removed: for product in self.a_lst_up_product_removed:
print(f"{self.name} seek alt supply for {product.code}") # print(f"{self.name} seek alt supply for {product.code}")
if self.dct_n_trial_up_prod_removed[ if self.dct_n_trial_up_prod_removed[
product] <= self.model.int_n_max_trial: product] <= self.model.int_n_max_trial:
if self.dct_n_trial_up_prod_removed[product] == 0: if self.dct_n_trial_up_prod_removed[product] == 0:
@ -87,10 +87,10 @@ class FirmAgent(ap.Agent):
select_alt_supply = self.model.nprandom.choice( select_alt_supply = self.model.nprandom.choice(
self.dct_cand_alt_supply_up_prod_removed[product], self.dct_cand_alt_supply_up_prod_removed[product],
p=lst_prob) p=lst_prob)
print( # print(
f"{self.name} selct alt supply for {product.code} " # f"{self.name} selct alt supply for {product.code} "
f"from {select_alt_supply.name}" # f"from {select_alt_supply.name}"
) # )
assert product in select_alt_supply.a_lst_product, \ assert product in select_alt_supply.a_lst_product, \
f"{select_alt_supply} \ f"{select_alt_supply} \
does not produce requested product {product}" does not produce requested product {product}"
@ -113,7 +113,7 @@ class FirmAgent(ap.Agent):
self.dct_n_trial_up_prod_removed[product] += 1 self.dct_n_trial_up_prod_removed[product] += 1
def handle_request(self): def handle_request(self):
print(self.name, 'handle_request') # print(self.name, 'handle_request')
for product, lst_firm in self.dct_request_prod_from_firm.items(): for product, lst_firm in self.dct_request_prod_from_firm.items():
if self.dct_prod_capacity[product] > 0: if self.dct_prod_capacity[product] > 0:
if len(lst_firm) == 0: if len(lst_firm) == 0:
@ -183,10 +183,10 @@ class FirmAgent(ap.Agent):
self.dct_prod_capacity[product] -= 1 self.dct_prod_capacity[product] -= 1
self.dct_request_prod_from_firm[product].remove(down_firm) self.dct_request_prod_from_firm[product].remove(down_firm)
down_firm.a_lst_up_product_removed.remove(product) down_firm.a_lst_up_product_removed.remove(product)
print( # print(
f"{self.name} accept {product.code} request " # f"{self.name} accept {product.code} request "
f"from {down_firm.name}" # f"from {down_firm.name}"
) # )
else: else:
down_firm.dct_cand_alt_supply_up_prod_removed[product].remove(self) down_firm.dct_cand_alt_supply_up_prod_removed[product].remove(self)

6
xv.csv
View File

@ -1,4 +1,4 @@
n_max_trial,crit_supplier,firm_pref_request,firm_pref_accept,netw_pref_cust_n,netw_pref_cust_size,cap_limit,diff_new_conn,diff_remove n_max_trial,crit_supplier,firm_pref_request,firm_pref_accept,netw_pref_cust_n,netw_pref_cust_size,cap_limit,diff_new_conn,diff_remove
12,2,2,2,0.5,2,4,0.5,0.5 15,2,2,2,0.5,2,4,0.5,0.5
8,1,1,1,1,1,2,1,1 10,1,1,1,1,1,2,1,1
4,0.5,0.5,0.5,2,0.5,0,2,2 5,0.5,0.5,0.5,2,0.5,0,2,2

1 n_max_trial crit_supplier firm_pref_request firm_pref_accept netw_pref_cust_n netw_pref_cust_size cap_limit diff_new_conn diff_remove
2 12 15 2 2 2 0.5 2 4 0.5 0.5
3 8 10 1 1 1 1 1 2 1 1
4 4 5 0.5 0.5 0.5 2 0.5 0 2 2