示例#1
0
    def hire(self, applicants, wage, world):
        hired = []
        while self.worker_change > 0 and applicants:
            # based on employment prob
            apps = []
            for a in applicants:
                ref = 'friend' if set(a.friends).intersection(self.workers) else 'ad_or_cold_call'
                p = offer_prob(world['year'], world['month'], a.sex, a.race, ref, precomputed_emp_dist=emp_dist)
                apps.append((a, p))
            apps_mass = sum(p for a, p in apps)
            apps = [(a, pr/apps_mass) for a, pr in apps]

            worker = random_choice(apps)
            if worker.employer is not None:
                worker.employer.fire(worker)
            worker.wage = wage
            worker.employer = self
            applicants.remove(worker)
            self.workers.append(worker)
            hired.append(worker)
            logger.info('person:{}'.format(json.dumps({
                'event': 'hired',
                'id': worker.id
            })))
            self.worker_change -= 1

        # increase wage to attract more employees
        if self.worker_change > 0:
            wage += self.config['wage_increment'] * (1.1+self.owner.altruism)
        return hired, self.worker_change, wage
示例#2
0
文件: city.py 项目: MaxwellRebo/hosny
 def hire_dist(self, person):
     # more employed friends, more likely to have a referral
     p_referral = st.beta.rvs(person._state['employed_friends'] + 1, 10)
     if random.random() < p_referral:
         referral = 'friend'
     else:
         referral = 'ad_or_cold_call'
     p = work.offer_prob(self.state['year'], self.state['month'], person._state['sex'], person._state['race'], referral)
     return [1-p, p]
示例#3
0
 def hire_dist(self, person):
     # more employed friends, more likely to have a referral
     p_referral = st.beta.rvs(person._state['employed_friends'] + 1, 10)
     if random.random() < p_referral:
         referral = 'friend'
     else:
         referral = 'ad_or_cold_call'
     p = work.offer_prob(self.state['year'], self.state['month'],
                         person._state['sex'], person._state['race'],
                         referral)
     return [1 - p, p]
示例#4
0
文件: firms.py 项目: langerv/hosny
    def hire(self, applicants, wage, world):
        hired = []
        while self.worker_change > 0 and applicants:
            # based on employment prob
            apps = []
            for a in applicants:
                ref = 'friend' if set(a.friends).intersection(
                    self.workers) else 'ad_or_cold_call'
                p = offer_prob(world['year'],
                               world['month'],
                               a.sex,
                               a.race,
                               ref,
                               precomputed_emp_dist=emp_dist)
                apps.append((a, p))
            apps_mass = sum(p for a, p in apps)
            apps = [(a, pr / apps_mass) for a, pr in apps]

            worker = random_choice(apps)
            if worker.employer is not None:
                worker.employer.fire(worker)
            worker.wage = wage
            worker.employer = self
            applicants.remove(worker)
            self.workers.append(worker)
            hired.append(worker)
            logger.info('person:{}'.format(
                json.dumps({
                    'event': 'hired',
                    'id': worker.id
                })))
            self.worker_change -= 1

        # increase wage to attract more employees
        if self.worker_change > 0:
            wage += self.config['wage_increment'] * (1.1 + self.owner.altruism)
        return hired, self.worker_change, wage