-
Notifications
You must be signed in to change notification settings - Fork 2
/
firms.py
66 lines (49 loc) · 1.85 KB
/
firms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import parameters
class Firm:
def __init__(self, unique_number, first_year, last_year=0, output=0):
self.unique_number = unique_number
self.members = {}
self.first_year = first_year
self.last_year = last_year
self.output = output
# constant returns coefficient
self.a = parameters.random.uniform(0.001, .5)
# increasing returns coefficient
self.b = parameters.random.uniform(.751, 1.25)
# increasing returns exponent
# keeping Beta at value 2
self.beta = 2
def get_id(self):
return self.unique_number
def get_b(self):
return self.b
def get_a(self):
return self.a
def get_beta(self):
return self.beta
def update_members(self, worker):
worker.update_firm(self.get_id())
self.members[worker.get_id()] = worker
def withdraw_members(self, worker):
worker.update_firm(None)
del self.members[worker.get_id()]
def num_members(self):
return len(self.members)
def total_effort(self):
E = 0
for key in list(self.members.keys()):
E += self.members[key].get_effort()
return E
def employee_share(self):
return self.output / len(self.members)
def update_output(self):
self.output = self.a * self.total_effort() + self.b * self.total_effort() ** self.beta
def get_output(self):
return self.output
def set_last_year(self, last_year):
self.last_year = last_year
def get_age(self, year):
return year - self.first_year
def __str__(self):
return 'Firm. ID: %s, Num. Employees %s, Output %.2f, a %.2f, b %.2f, beta %.2f' % \
(self.unique_number, len(self.members), self.output, self.a, self.b, self.beta)