Exemplo n.º 1
0
 def set_interest(self, household, firm):
     # Set nominal interest rate as 0,1,2,...,i,i+1,... where  i stands for 0.1*i percent and announce to the public
     #current_coefs = [self.alp_i, self.alp_p]
     current_irate = self.irate
     Tremble = uniform() < self.TrblActn
     Inertia = uniform() < self.inertia
     satisficing_output = self.val_output >= self.sl_output
     satisficing_infltn = self.val_infltn >= self.sl_infltn
     if not(Inertia):
         if Tremble or not(satisficing_output) or not(satisficing_infltn):
                 self.irate = uniform_range(max(self.min_irate, self.irate-(self.delta)), self.irate+(self.delta))
         else:
             self.irate = uniform_range(max(self.min_irate, self.irate-(self.delta)), self.irate+(self.delta))
     # self.irate = min(self.irate, int(self.max_irate/self.unit))
     if current_irate == self.irate:
         self.ActionChanged = False
     # if not(Inertia):
     #     if (Tremble or not(satisficing_output) or not(satisficing_infltn)):
     #         self.alp_i = randint(max(-2, self.alp_i - self.delta), min(5, self.alp_i + self.delta))
     #         self.alp_p = randint(max(-2, self.alp_p - self.delta), min(5, self.alp_p + self.delta))
     # # Rule for random choice randint(max(0, self.irate - self.delta), self.irate + self.delta)
     # self.irate = int(min(max(0, self.alp_i*household.c[irate_node] 
     #     + self.alp_p*self.inflation), self.max_irate/self.unit))
     # if current_coefs == [self.alp_i, self.alp_p] :
     #     self.ActionChanged = False
     Tremble = uniform() < self.TrbSatLv
     lamda = uniform()**self.gamma
     if not(Tremble):
         self.sl_output += lamda*self.LAMBDA*min(self.val_output - self.sl_output, 0)
         self.sl_infltn += lamda*self.LAMBDA*min(self.val_infltn - self.sl_infltn, 0)
     else:
         self.sl_output += lamda*(self.val_output-self.sl_output)
         self.sl_infltn += lamda*(self.val_infltn-self.sl_infltn)
     household.irate = firm.irate = self.irate
Exemplo n.º 2
0
 def set_price(self, bank,
               household):  # set price and announce it to the public
     irate_node = self.irate_node(self.irate)
     self.current_price = self.price[irate_node]
     Tremble = uniform() < self.TrblActn
     Inertia = uniform() < self.inertia
     Satisficing = self.Val[irate_node] >= self.SatLv[irate_node]
     # print 'price range:', self.price[irate_node]*(1-self.delta), self.price[irate_node]*(1+self.delta)
     if not (Inertia):
         if Tremble or not (Satisficing):
             self.price[irate_node] = uniform_range(
                 self.price[irate_node] * (1 - self.delta),
                 self.price[irate_node] * (1 + self.delta))
     if self.current_price != self.price[irate_node]:
         # if self.ActionChanged or self.current_price != self.price[irate_node]:
         self.ActionChanged = True
     # current_markup = self.markup[irate_node]
     # Tremble = uniform() < self.TrblActn
     # Inertia = uniform() < self.inertia
     # Satisficing = self.Val[irate_node] >= self.SatLv[irate_node]
     # if not(Inertia):
     #     if Tremble or not(Satisficing):
     #         self.markup[irate_node] = uniform_range(max(0, self.markup[irate_node]*(1-self.delta)), self.markup[irate_node]*(1+self.delta))
     # if self.ActionChanged or current_markup != self.markup[irate_node]:
     #     self.ActionChanged = True
     # price = (1+self.markup[irate_node])*(self.irate*self.unit)*(self.capital**(1-self.capital_power))/(self.capital_power*self.tech)
     household.price = bank.price = max(0.01, self.price[irate_node])
     Tremble = uniform() < self.TrbSatLv
     lamda = uniform()**self.gamma
     if not (Tremble):
         self.SatLv[irate_node] += lamda * self.LAMBDA * min(
             self.Val[irate_node] - self.SatLv[irate_node], 0)
     else:
         self.SatLv[irate_node] += lamda * (self.Val[irate_node] -
                                            self.SatLv[irate_node])
Exemplo n.º 3
0
 def set_price(self, bank, household):     # set price and announce it to the public
     irate_node = self.irate_node(self.irate)
     self.current_price = self.price[irate_node]
     Tremble = uniform() < self.TrblActn
     Inertia = uniform() < self.inertia
     Satisficing = self.Val[irate_node] >= self.SatLv[irate_node]
     # print 'price range:', self.price[irate_node]*(1-self.delta), self.price[irate_node]*(1+self.delta)
     if not(Inertia):
         if Tremble or not(Satisficing):
                 self.price[irate_node] = uniform_range(self.price[irate_node]*(1-self.delta), self.price[irate_node]*(1+self.delta))
     if self.current_price != self.price[irate_node]:
     # if self.ActionChanged or self.current_price != self.price[irate_node]:            
         self.ActionChanged = True        
     # current_markup = self.markup[irate_node]
     # Tremble = uniform() < self.TrblActn
     # Inertia = uniform() < self.inertia
     # Satisficing = self.Val[irate_node] >= self.SatLv[irate_node]
     # if not(Inertia):
     #     if Tremble or not(Satisficing):
     #         self.markup[irate_node] = uniform_range(max(0, self.markup[irate_node]*(1-self.delta)), self.markup[irate_node]*(1+self.delta))
     # if self.ActionChanged or current_markup != self.markup[irate_node]:
     #     self.ActionChanged = True
     # price = (1+self.markup[irate_node])*(self.irate*self.unit)*(self.capital**(1-self.capital_power))/(self.capital_power*self.tech)
     household.price = bank.price = max(0.01, self.price[irate_node])
     Tremble = uniform() < self.TrbSatLv
     lamda = uniform()**self.gamma
     if not(Tremble):
         self.SatLv[irate_node] += lamda*self.LAMBDA*min(self.Val[irate_node] - self.SatLv[irate_node], 0)
     else:
         self.SatLv[irate_node] += lamda*(self.Val[irate_node] - self.SatLv[irate_node])
Exemplo n.º 4
0
 def __init__(self,
              bank,
              TrblActn=0.05,
              TrbSatLv=0.05,
              LAMBDA=0.05,
              gamma=0.5,
              capital_power=0.4,
              inertia=0.9,
              delta=0.05,
              techs=[1, 1],
              irate_unit=0.005,
              irate_max=0.1,
              depreciate=0.05):
     self.TrblActn,self.TrbSatLv,self.LAMBDA, self.gamma, self.inertia = \
         TrblActn, TrbSatLv, LAMBDA, gamma, inertia
     self.capital, self.irate, self.profit, self.delta, self.techs = \
         100, 0, 0, delta, techs
     self.tech = choice(techs)
     self.depreciate = depreciate
     self.capital_power = capital_power
     self.irate_unit, self.irate_max = irate_unit, irate_max
     self.irate_nodes = range(int(irate_max / irate_unit))
     self.capital_demand = 0
     self.SatLv, self.Val = 0, 0
     self.markup = [uniform() for n in self.irate_nodes]
     self.price = [uniform_range(0.9, 1.0) for n in self.irate_nodes]
     self.k = 10
     # self.k = [10 for n in self.irate_nodes]
     self.SatLv = self.Val = [0 for n in self.irate_nodes]
     self.ActionChanged = True
Exemplo n.º 5
0
 def consume(self):       # choose how much to consume and save
     irate_node = self.irate_node(self.irate)
     # print '1. consumption:', self.asset
     self.consumption = self.c[irate_node]
     Tremble = uniform() < self.TrblActn
     Inertia = uniform() < self.inertia
     satisficing_consuption = self.val_c[irate_node] >= self.sl_c[irate_node]
     satisficing_asset = self.val_asset[irate_node] >= self.sl_asset[irate_node]
     if not(Inertia):
         if not(Tremble):
             if (not(satisficing_consuption) and (satisficing_asset)):
                 self.c[irate_node] = uniform_range(self.c[irate_node], min(1, self.c[irate_node]*(1+self.delta)))
             #     self.c[irate_node] = uniform_range(self.c[irate_node], 
             #         min(self.asset/self.price, self.c[irate_node] + self.delta))
             elif (satisficing_consuption and not(satisficing_asset)):
                 self.c[irate_node] = uniform_range(max(0, self.c[irate_node]*(1-self.delta)), self.c[irate_node])
             #     self.c[irate_node] = uniform_range(max(0, self.c[irate_node] - self.delta), 
             #         self.c[irate_node])
             elif (not(satisficing_consuption) and not(satisficing_asset)):
                 # self.c[irate_node] = uniform_range(max(0, self.c[irate_node] - self.delta), 
                 #     min(self.asset/self.price, self.c[irate_node] + self.delta))
                 self.c[irate_node] = uniform_range(max(0, self.c[irate_node]*(1-self.delta)), min(1, self.c[irate_node]*(1+self.delta)))
                 # self.c[irate_node] = uniform_range(max(0, self.c[irate_node]*(1-self.delta)), min(self.asset, self.c[irate_node]*(1+self.delta)))
                 # self.c[irate_node] = uniform_range(0, self.asset/self.price)
             # else:
             #     self.c[irate_node] = min(self.c[irate_node], self.asset/self.price)
         else:
             # self.c[irate_node] = uniform_range(max(0, self.c[irate_node] - self.delta), 
             #     min(self.asset/self.price, self.c[irate_node] + self.delta))
             self.c[irate_node] = uniform_range(max(0, self.c[irate_node]*(1-self.delta)), min(1, self.c[irate_node]*(1+self.delta)))
     # else:
     #     self.c[irate_node] = min(self.c[irate_node], self.asset/self.price)
     if self.consumption == self.c[irate_node]:
         self.ActionChanged = False        
     # self.consumption = self.c[irate_node]
     self.consumption = self.asset*self.c[irate_node]
     self.saving = self.asset - self.consumption
     self.asset = 0
     # print '1. after consumption: saving and consumption', self.saving, self.consumption
     Tremble = uniform() < self.TrbSatLv
     lamda = uniform()**self.gamma
     if not(Tremble):
         self.sl_c[irate_node] += lamda*self.LAMBDA*min(self.val_c[irate_node] - self.sl_c[irate_node],0)
         self.sl_asset[irate_node] += lamda*self.LAMBDA*min(self.val_asset[irate_node] - self.sl_asset[irate_node],0)
     else:
         self.sl_c[irate_node] += lamda*(self.val_c[irate_node] - self.sl_c[irate_node])
         self.sl_asset[irate_node] += lamda*(self.val_asset[irate_node] - self.sl_asset[irate_node])
Exemplo n.º 6
0
 def set_interest(self, household, firm):
     # Set nominal interest rate as 0,1,2,...,i,i+1,... where  i stands for 0.1*i percent and announce to the public
     #current_coefs = [self.alp_i, self.alp_p]
     current_irate = self.irate
     Tremble = uniform() < self.TrblActn
     Inertia = uniform() < self.inertia
     satisficing_output = self.val_output >= self.sl_output
     satisficing_infltn = self.val_infltn >= self.sl_infltn
     if not (Inertia):
         if Tremble or not (satisficing_output) or not (satisficing_infltn):
             self.irate = uniform_range(
                 max(self.min_irate, self.irate - (self.delta)),
                 self.irate + (self.delta))
         else:
             self.irate = uniform_range(
                 max(self.min_irate, self.irate - (self.delta)),
                 self.irate + (self.delta))
     # self.irate = min(self.irate, int(self.max_irate/self.unit))
     if current_irate == self.irate:
         self.ActionChanged = False
     # if not(Inertia):
     #     if (Tremble or not(satisficing_output) or not(satisficing_infltn)):
     #         self.alp_i = randint(max(-2, self.alp_i - self.delta), min(5, self.alp_i + self.delta))
     #         self.alp_p = randint(max(-2, self.alp_p - self.delta), min(5, self.alp_p + self.delta))
     # # Rule for random choice randint(max(0, self.irate - self.delta), self.irate + self.delta)
     # self.irate = int(min(max(0, self.alp_i*household.c[irate_node]
     #     + self.alp_p*self.inflation), self.max_irate/self.unit))
     # if current_coefs == [self.alp_i, self.alp_p] :
     #     self.ActionChanged = False
     Tremble = uniform() < self.TrbSatLv
     lamda = uniform()**self.gamma
     if not (Tremble):
         self.sl_output += lamda * self.LAMBDA * min(
             self.val_output - self.sl_output, 0)
         self.sl_infltn += lamda * self.LAMBDA * min(
             self.val_infltn - self.sl_infltn, 0)
     else:
         self.sl_output += lamda * (self.val_output - self.sl_output)
         self.sl_infltn += lamda * (self.val_infltn - self.sl_infltn)
     household.irate = firm.irate = self.irate
Exemplo n.º 7
0
 def __init__(self, bank, TrblActn=0.05, TrbSatLv=0.05, LAMBDA=0.05, gamma=0.5, capital_power=0.4,
             inertia=0.9, delta=0.05, techs=[1, 1], irate_unit=0.005, irate_max=0.1, depreciate=0.05):
     self.TrblActn,self.TrbSatLv,self.LAMBDA, self.gamma, self.inertia = \
         TrblActn, TrbSatLv, LAMBDA, gamma, inertia
     self.capital, self.irate, self.profit, self.delta, self.techs = \
         100, 0, 0, delta, techs
     self.tech = choice(techs)
     self.depreciate = depreciate
     self.capital_power = capital_power
     self.irate_unit, self.irate_max = irate_unit, irate_max
     self.irate_nodes = range(int(irate_max/irate_unit))
     self.capital_demand = 0
     self.SatLv, self.Val = 0, 0
     self.markup = [uniform() for n in self.irate_nodes]
     self.price = [uniform_range(0.9, 1.0) for n in self.irate_nodes]
     self.k = 10
     # self.k = [10 for n in self.irate_nodes]
     self.SatLv = self.Val = [0 for n in self.irate_nodes]
     self.ActionChanged = True
Exemplo n.º 8
0
 def consume(self):  # choose how much to consume and save
     irate_node = self.irate_node(self.irate)
     # print '1. consumption:', self.asset
     self.consumption = self.c[irate_node]
     Tremble = uniform() < self.TrblActn
     Inertia = uniform() < self.inertia
     satisficing_consuption = self.val_c[irate_node] >= self.sl_c[irate_node]
     satisficing_asset = self.val_asset[irate_node] >= self.sl_asset[
         irate_node]
     if not (Inertia):
         if not (Tremble):
             if (not (satisficing_consuption) and (satisficing_asset)):
                 self.c[irate_node] = uniform_range(
                     self.c[irate_node],
                     min(1, self.c[irate_node] * (1 + self.delta)))
             #     self.c[irate_node] = uniform_range(self.c[irate_node],
             #         min(self.asset/self.price, self.c[irate_node] + self.delta))
             elif (satisficing_consuption and not (satisficing_asset)):
                 self.c[irate_node] = uniform_range(
                     max(0, self.c[irate_node] * (1 - self.delta)),
                     self.c[irate_node])
             #     self.c[irate_node] = uniform_range(max(0, self.c[irate_node] - self.delta),
             #         self.c[irate_node])
             elif (not (satisficing_consuption)
                   and not (satisficing_asset)):
                 # self.c[irate_node] = uniform_range(max(0, self.c[irate_node] - self.delta),
                 #     min(self.asset/self.price, self.c[irate_node] + self.delta))
                 self.c[irate_node] = uniform_range(
                     max(0, self.c[irate_node] * (1 - self.delta)),
                     min(1, self.c[irate_node] * (1 + self.delta)))
                 # self.c[irate_node] = uniform_range(max(0, self.c[irate_node]*(1-self.delta)), min(self.asset, self.c[irate_node]*(1+self.delta)))
                 # self.c[irate_node] = uniform_range(0, self.asset/self.price)
             # else:
             #     self.c[irate_node] = min(self.c[irate_node], self.asset/self.price)
         else:
             # self.c[irate_node] = uniform_range(max(0, self.c[irate_node] - self.delta),
             #     min(self.asset/self.price, self.c[irate_node] + self.delta))
             self.c[irate_node] = uniform_range(
                 max(0, self.c[irate_node] * (1 - self.delta)),
                 min(1, self.c[irate_node] * (1 + self.delta)))
     # else:
     #     self.c[irate_node] = min(self.c[irate_node], self.asset/self.price)
     if self.consumption == self.c[irate_node]:
         self.ActionChanged = False
     # self.consumption = self.c[irate_node]
     self.consumption = self.asset * self.c[irate_node]
     self.saving = self.asset - self.consumption
     self.asset = 0
     # print '1. after consumption: saving and consumption', self.saving, self.consumption
     Tremble = uniform() < self.TrbSatLv
     lamda = uniform()**self.gamma
     if not (Tremble):
         self.sl_c[irate_node] += lamda * self.LAMBDA * min(
             self.val_c[irate_node] - self.sl_c[irate_node], 0)
         self.sl_asset[irate_node] += lamda * self.LAMBDA * min(
             self.val_asset[irate_node] - self.sl_asset[irate_node], 0)
     else:
         self.sl_c[irate_node] += lamda * (self.val_c[irate_node] -
                                           self.sl_c[irate_node])
         self.sl_asset[irate_node] += lamda * (self.val_asset[irate_node] -
                                               self.sl_asset[irate_node])