Пример #1
0
    def __init__(self, tax_rate, welfare, tax_rate_increment,
                 welfare_increment, starting_welfare_req):
        self._state = {'cash': 0}
        self.tax_rate = tax_rate
        self.tax_rate_increment = tax_rate_increment
        self.welfare = welfare
        self.welfare_increment = welfare_increment
        self.welfare_req = starting_welfare_req
        self.subsidies = {
            ConsumerGoodFirm: 0,
            CapitalEquipmentFirm: 0,
            RawMaterialFirm: 0,
            Hospital: 0
        }
        self.altruism = 0

        # all states map to the same actions
        action_ids = [i for i in range(len(self.actions))]
        states_actions = {s: action_ids for s in range(3)}
        self.learner = QLearner(states_actions,
                                self.reward,
                                discount=0.5,
                                explore=0.01,
                                learning_rate=0.5)

        # keep track of previous step's quality of life for comparison
        self.prev_qol = 0
Пример #2
0
    def __init__(self, labor_cost_per_good, material_cost_per_good,
                 labor_per_equipment, labor_per_worker, supply_increment,
                 profit_increment, wage_increment):
        self._super(Firm, self).__init__(
            state={
                'desired_supply': 1,
                'desired_equipment': 0,
                'worker_change': 0,
                'workers': [],
                'cash': 50000,
                'revenue': 0,
                'costs': 0,
                'price': 0,
                'profit': 0,
                'prev_profit': 0,
                'leftover': 0,
                'supply': 0,
                'n_sold': 0,
                'profit_margin': 1,
                'equipment': 0,
                'materials': 0,
            })

        self.material_cost_per_good = material_cost_per_good
        self.labor_cost_per_good = labor_cost_per_good
        self.labor_per_equipment = labor_per_equipment
        self.labor_per_worker = labor_per_worker
        self.supply_increment = supply_increment
        self.profit_increment = profit_increment
        self.wage_increment = wage_increment

        # all states map to the same actions
        action_ids = [i for i in range(len(self.actions))]
        states_actions = {s: action_ids for s in range(5)}
        self.learner = QLearner(states_actions,
                                self.reward,
                                discount=0.5,
                                explore=0.1,
                                learning_rate=0.8)
Пример #3
0
    def __init__(self, owner):
        self.owner = owner
        self.owner._state['firm_owner'] = True
        self.owner.firm = self
        self.desired_supply = 1

        # initialize
        self.workers = []
        self.revenue = 0
        self.costs = 0
        self.supply = 0
        self.n_sold = 0
        self.profit_margin = 1
        self.equipment = 0
        self.materials = 0

        # all states map to the same actions
        action_ids = [i for i in range(len(self.actions))]
        states_actions = {s: action_ids for s in range(5)}
        self.learner = QLearner(states_actions,
                                self.reward,
                                discount=0.5,
                                explore=0.01,
                                learning_rate=0.8)