2nd commit
This commit is contained in:
parent
62e3360f65
commit
dba7e9882a
|
@ -1 +1 @@
|
|||
worker.py
|
||||
env.py
|
44
env.py
44
env.py
|
@ -40,7 +40,7 @@ class Env(ap.Model):
|
|||
# 工人、企业列表
|
||||
self.a_lst_worker = ap.AgentList(self)
|
||||
self.a_lst_firm = ap.AgentList(self)
|
||||
self.e_revenue = 1193e+7
|
||||
self.e_revenue = 5815100000000
|
||||
|
||||
# 在工人列表中添加工人
|
||||
for i in range(self.n_worker):
|
||||
|
@ -51,7 +51,7 @@ class Env(ap.Model):
|
|||
# 在企业列表中添加企业,放入一个is_RH_ratio, 即有多大比例的企业是属于RH类型的
|
||||
for i in range(self.n_firm):
|
||||
# 对于企业属性true or false 的判断, 影响到firm 板块下, self.s_IsRH = is_RH 语句的判断
|
||||
f = FirmAgent(self, self.p.is_RH_ratio >= uniform(0, 1))
|
||||
f = FirmAgent(self, self.p.is_RH_ratio >= uniform(0, 1), self.p.is_FH_ratio >= uniform(0, 1))
|
||||
self.a_lst_firm.append(f)
|
||||
|
||||
def update_e_revenue(self):
|
||||
|
@ -114,14 +114,24 @@ class Env(ap.Model):
|
|||
n_bankrupt_firms = 0
|
||||
for f in self.a_lst_firm:
|
||||
if f.s_value < 0:
|
||||
# 两种方式,第一种是直接淘汰企业(此处设定为清空企业员工,清空企业利润值和价值,相当于重新添加了一个新的企业?)
|
||||
# 直接淘汰企业(此处设定为清空企业员工,清空企业利润值和价值,相当于重新添加了一个新的企业?)
|
||||
n_bankrupt_firms += 1
|
||||
# for work in f.l_senior_workers:
|
||||
# work.s_is_hired = False
|
||||
# for work in f.l_junior_workers:
|
||||
# work.s_is_hired = False
|
||||
# f.s_profit = 0
|
||||
# f.s_value = 0
|
||||
for work in f.l_senior_workers:
|
||||
work.s_is_hired = False
|
||||
for work in f.l_junior_workers:
|
||||
work.s_is_hired = False
|
||||
f.s_profit = 0
|
||||
f.s_value = 0
|
||||
else:
|
||||
if f.s_profit < 0:
|
||||
if f.s_IsFH:
|
||||
# 第一种方式,末位淘汰制,淘汰所有员工中生产价值最低的
|
||||
f.l_junior_workers.sort(key=lambda x: x['s_yield'], reverse=True)
|
||||
for work in f.l_junior_workers:
|
||||
# f.l_junior_workers.sort(key=lambda x: x['s_yield'], reverse=True)
|
||||
if work == f.l_junior_workers[-1]:
|
||||
work.s_is_hired = False
|
||||
else:
|
||||
# 第二种方式,末位淘汰制,淘汰所有员工中单位产值(产值/工资)价值最低的
|
||||
f.l_all_w = f.l_junior_workers + f.l_senior_workers
|
||||
for work in f.l_all_w:
|
||||
|
@ -129,17 +139,6 @@ class Env(ap.Model):
|
|||
f.l_all_w.sort(key=lambda x: x['unit_yield_salary'], reverse=True)
|
||||
if work == f.l_all_w[-1]:
|
||||
work.s_is_hired = False
|
||||
|
||||
|
||||
# 第二种方式,末位淘汰制,淘汰所有员工中生产价值最低的
|
||||
# f.l_junior_workers.sort(key=lambda x: x['s_yield'], reverse=True)
|
||||
# for work in f.l_junior_workers:
|
||||
# # f.l_junior_workers.sort(key=lambda x: x['s_yield'], reverse=True)
|
||||
# if work == f.l_junior_workers[-1]:
|
||||
# work.s_is_hired = False
|
||||
|
||||
|
||||
|
||||
# for f in self.a_lst_firm:
|
||||
# if f.s_profit < 0: # TODO
|
||||
# n_bankrupt_firms += 1
|
||||
|
@ -222,12 +221,13 @@ if __name__ == '__main__':
|
|||
# plt.show()
|
||||
|
||||
parameters = {
|
||||
'n_worker': 500,
|
||||
'n_firm': 10,
|
||||
'n_worker': 1000,
|
||||
'n_firm': 100,
|
||||
'percent_search': 0.2,
|
||||
'alpha': 0.5,
|
||||
# 'alpha': ap.Range(0, 1, 0.5),
|
||||
'is_RH_ratio': 0.5,
|
||||
'is_FH_ratio': 0.5,
|
||||
}
|
||||
sample = ap.Sample(parameters)
|
||||
# sample = ap.Sample(parameters, n=3)
|
||||
|
|
BIN
env_data.xlsx
BIN
env_data.xlsx
Binary file not shown.
4
firm.py
4
firm.py
|
@ -15,6 +15,7 @@ if TYPE_CHECKING:
|
|||
class FirmAgent(ap.Agent):
|
||||
c_incentive: float
|
||||
s_IsRH: bool
|
||||
s_IsFH: bool
|
||||
s_avg_senior_yield: float
|
||||
s_avg_junior_yield: float
|
||||
s_a_yield: float
|
||||
|
@ -32,13 +33,14 @@ class FirmAgent(ap.Agent):
|
|||
# super().__init__(model, args, kwargs)
|
||||
# self.l_all_workers = None
|
||||
|
||||
def setup(self, is_RH):
|
||||
def setup(self, is_RH, is_FH):
|
||||
self.c_incentive = uniform(0, 1)
|
||||
# self.s_profit = randint(10, 20)
|
||||
self.l_senior_workers, self.l_junior_workers = [], []
|
||||
self.l_all_workers = []
|
||||
self.l_applied_workers = []
|
||||
self.s_IsRH = is_RH
|
||||
self.s_IsFH = is_FH
|
||||
self.initial_f_salary = randint(8000, 10000)
|
||||
self.s_profit = 0
|
||||
self.s_value = 0
|
||||
|
|
Loading…
Reference in New Issue