Esempio n. 1
0
    def filter(self, z):

        # Prediction
        # xp = F * x
        self.xp = mm([self.F, self.x])

        # Pp = F * P * F' + Q
        self.Pp = ma(mm([self.F, self.P, self.F.transpose()]), self.Q)

        # Update prediction
        # S = H * Pp * H' + R
        self.S = ma(mm([self.H, self.Pp, self.H.transpose()]), self.R)

        # K = Pp * H' * S^-1
        self.K = mm([self.Pp, self.H.transpose(), miv(self.S)])
        self.K_list.append(self.K)

        # y = z - H * xp
        self.y = ms(z, mm([self.H, self.xp]))

        # x = xp + K * y
        self.x = ma(self.xp, mm([self.K, self.y]))

        # P = (I - K * H) * Pp'
        I = mid(self.K.shape[0])
        self.P = mm([ms(I, mm([self.K, self.H])), self.Pp.transpose()])
        self.P_list.append(self.P)

        return self.x.tolist()
Esempio n. 2
0
    def step(self):
        """
        Advance the Household Agent by one step
        Can be residential step or school step


        :return:
        """
        if self.model.schedule.steps < self.model.residential_steps:
            residential_move = True
        else:
            residential_move = False

        if residential_move:
            # only step the agents if the number considered is not exhausted
            if self.model.total_considered < self.model.residential_moves_per_step:
                # move residential
                U_res = self.get_res_satisfaction(self.pos)
                self.model.res_satisfaction.append(U_res)

                # print("U_res",U_res)
                if U_res < self.T:

                    # todo: implement different move schemes, for now only random
                    # find all empty places
                    # rank them
                    # take one with boltzmann probability.
                    self.evaluate_move(U_res, school=False)

                else:
                    self.model.res_happy += 1

                self.model.total_considered += 1
                #print("considered",self.model.total_considered)

        else:
            if self.model.total_considered < self.model.school_moves_per_step:
                # school moves
                # satisfaction in current school
                U = self.get_school_satisfaction(self.school,
                                                 self.dist_to_school)
                self.model.satisfaction.append(U)

                # If unhappy, compared to threshold move:
                if U < self.T:
                    #print('unhappy')
                    self.evaluate_move(U, school=True)

                else:
                    self.model.happy += 1
                    if self.model.total_considered > 0:
                        self.model.percent_happy = np.ma(
                            self.model.happy / self.model.total_considered)
Esempio n. 3
0
# label sublot character size and position (e.g. a,b,c,d)
lbfs = 20
lbpx = 0.04
lbpy = 0.96

# fig = plt.figure(facecolor='white', figsize = (8.5, 11))
fig = plt.figure(facecolor="white", figsize=(11.0, 8.5))

baroffset = 0.023


# --------- plots
plt.subplot(111)

ma = Basemap(boundinglat=bounding_lat, lon_0=lon_0, area_thresh=10000.0, projection=projection)
xa, ya = ma(*np.meshgrid(lon, lat))

ma.drawcoastlines()
ma.drawparallels(np.arange(-90.0, 90.0, 30.0))
ma.drawmeridians(np.arange(-180.0, 180.0, 30.0))
# revhaxby=cmap_map(lambda x: x[::-1], cm.GMT_haxby)

# tlvs=np.arange(-20.,22.,1.)
# tlvs=(-5000,-4500,-4000,-3500,-3000,-2500,-2000,-1500,-1000,-500,0,500,1000,1500,2000,2500,3000,3500,4000,4500,5000)
# tlvs=(0,500,1000,1500,2000,2500,3000,3500,4000,4500,5000)
# tlvs=np.arange(0,5000,100)
tlvs = np.arange(0, 2000, 100)

# cs1 = m1.contourf(x1, y1, obsnaug, lvs, cmap=bcm.GMT_haxby_r)
# csa = ma.contourf(xa, ya, etopo, tlvs, cmap=bcm.GMT_no_green)
# csa = ma.contourf(xa, ya, etopo, tlvs, cmap=bcm.GMT_globe)
Esempio n. 4
0
#label sublot character size and position (e.g. a,b,c,d)
lbfs = 20
lbpx = 0.04
lbpy = 0.96

#fig = plt.figure(facecolor='white', figsize = (8.5, 11))
fig = plt.figure(facecolor='white', figsize=(11., 8.5))

baroffset = 0.023

# --------- plots
plt.subplot(111)

ma = Basemap(boundinglat=bounding_lat,lon_0=lon_0,\
            area_thresh=10000.,projection=projection)
xa, ya = ma(*np.meshgrid(lon, lat))

ma.drawcoastlines()
ma.drawparallels(np.arange(-90., 90., 30.))
ma.drawmeridians(np.arange(-180., 180., 30.))
#revhaxby=cmap_map(lambda x: x[::-1], cm.GMT_haxby)

#tlvs=np.arange(-20.,22.,1.)
#tlvs=(-5000,-4500,-4000,-3500,-3000,-2500,-2000,-1500,-1000,-500,0,500,1000,1500,2000,2500,3000,3500,4000,4500,5000)
#tlvs=(0,500,1000,1500,2000,2500,3000,3500,4000,4500,5000)
#tlvs=np.arange(0,5000,100)
tlvs = np.arange(0, 2000, 100)

#cs1 = m1.contourf(x1, y1, obsnaug, lvs, cmap=bcm.GMT_haxby_r)
#csa = ma.contourf(xa, ya, etopo, tlvs, cmap=bcm.GMT_no_green)
#csa = ma.contourf(xa, ya, etopo, tlvs, cmap=bcm.GMT_globe)