salary02/firm.py

106 lines
4.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from typing import Union, Any
import agentpy as ap
from random import uniform, randint
class FirmAgent(ap.Agent):
c_incentive: float
s_IsRH: bool
s_a_senior_yield: float
s_a_junior_yield: float
s_a_yield: float
s_salary: float
s_revenue: float
s_profit: float
l_senior_workers: list
l_junior_workers: list
l_applied_workers: list
def setup(self):
self.c_incentive = uniform(0, 1)
self.s_profit = randint(10, 20)
self.l_applied_workers = []
def apply(self, the_worker):
self.l_applied_workers.append(the_worker)
def select_worker(self):
'''
企业找到最想招聘的员工
:return:
'''
n_a_firms = len(self.l_applied_workers)
# 对员工产出进行排队和比较
max_s_yield: float
max_s_yield, best_worker = 0, None
for i in self.l_applied_workers:
y = max_s_yield
if y > max_s_yield:
max_s_yield = y
best_worker = i
# print(f'{self}: my best firm is {best_firm} from {n_firms} firms with utility {max_utility}')
# return best_worker
# 当企业是想要利用产出最高的员工时,从申请的员工中选出产出最高的员工
'''if self.s_IsRH :
# 计算该名员工的工资水平: 原有工资水平* 1+incentive
bw_salary = self.best_worker.salary()
# 将该名员工的产出与公司原有员工的产出进行对比如果高于senior列表中的最后一名的产出就进入senior_list, 否则进入junior_list
self.l_senior_workers.append(best_worker)
else:
self.l_junior_workers.append(best_worker)
# best_worker.apply(self)
else:
# 计算由于改名员工下一期的薪资总数(根据薪资函数更新)以及企业下一期的利润的差值,并选出最大值
'''
def S_a_Yield(self):
# 更新总产出
# s_total_senior_yield = self.s_a_senior_yield * len(self.l_senior_workers)
# s_total_junior_yield = self.s_a_junior_yield * len(self.l_senior_workers)
l_s_workers = self.l_senior_workers
l_j_workers = self.l_junior_workers
# s_a_yield = s_total_yield / len(self.l_senior_workers + self.l_junior_workers)
s_total_senior_yield, s_total_junior_yield = 0, 0
'''for i in range(len(self.l_senior_workers)):
# 加入工人主体的产出属性
s_total_senior_yield += '工人的yield'
for i in range (len(self.l_junior_workers)):
s_total_junior_yield += '工人的yield'
s_a_senior_yield = s_total_senior_yield / len(l_s_workers)
s_a_junior_yield = s_total_junior_yield / len(l_j_workers)
s_a_yield = 0.8*s_a_senior_yield+0.2*s_a_junior_yield
return s_a_yield
'''
return
def LogitShare(self):
'''
self.logitshare = exp(S_a_Yield)/ np.sum(exp(S_a_Yield))
:return:
'''
return
def Sum_salary(self, l_senior_workers, l_junior_workers):
'''
计算某公司整体的薪金水平
'''
l_all_workers = l_senior_workers + l_junior_workers
for i in l_all_workers:
#self.sum_salary = np.sum()
return
def S_Profit(self):
# self.s_profit =self.LogitShare() * EnvironmentAgent.s_e_Irevenue - self.Sum_salary()
return
def step(self):
'''
更新三个集合:
首先判断员工i在企业j第t时期的l_applied_workers列表里
第二步判断企业j 的s_IsRH是0或者是1
如果是1则将应聘员工中s_w_yield最大的员工从l_applied_workers列表转移到l_senior_workers或l_junior_workers列表
否则即如果是0则计算每名员工如果进入企业下一期企业利润的提升max的员工
从l_applied_workers列表转移到l_senior_workers或l_junior_workers列表。
'''