Facebook
From Davide, 2 Weeks ago, written in Plain Text.
This paste is a reply to Por ti cono from Davide - view diff
Embed
Download Paste or View Raw
Hits: 136
  1. def support (self, rho, phi, delta, r, result):
  2.         """
  3.         Actual values for the {ukn, occ, ept, cft} hypotheses depend on the uncertainty theory used
  4.         Here we use a trivial 'hit-count' method
  5.         """
  6.  
  7.         delta_r = 0.02
  8.         k_occ =1.0
  9.         k_ept = 1.0
  10.        
  11.         def f_occ(phi, delta,rho, r,delta_r, k_occ):
  12.             # check that cell at (rho, phi) is in the field of view
  13.             if (phi <= delta/2 and -phi <= delta/2):
  14.                 if abs(rho - r) <= delta_r:
  15.                     return k_occ * (1 -  ((r - rho)/delta_r)**2)
  16.                 elif 0 <= rho < r - delta_r:
  17.                     return 0
  18.                 elif rho >= r + delta_r:
  19.                     return 0
  20.             else: # Unknown scenario
  21.                 return 1.0
  22.        
  23.         def f_ept(phi, delta,rho, r,delta_r, k_ept):
  24.             # check that cell at (rho, phi) is in the field of view
  25.             if (phi <= delta/2 and -phi <= delta/2):
  26.                 if abs(rho - r) <= delta_r:
  27.                     return k_ept * ((r - rho)/delta_r)**2
  28.                 elif rho >= r:
  29.                     return 0
  30.                 elif 0 <= rho< r- delta_r:
  31.                     return k_ept
  32.             else: # Unknown scenario
  33.                 return 1.0
  34.        
  35.         result.occ = f_occ(phi, delta,rho, r,delta_r, k_occ)
  36.         result.ept = f_ept(phi, delta,rho, r,delta_r, k_ept)
  37.         result.ukn = 0.0
  38.         result.cft = 0.0
  39.         return result
  40.        
  41. def fuse (self, old, new):
  42.         """
  43.         Fuse the new values for (ukn, occ, ept, cft) with the previous ones
  44.         Return the fused values
  45.         Fusion details depend on the uncertainty theory,
  46.         here we use a trivial count of the 'occ', 'ept' hits
  47.         """
  48.         # Fusion rule: Take maximum support value for each hypothesis
  49.         old.occ = min(old.occ, new.occ)
  50.         old.ept = min(old.ept, new.ept)
  51.         self.ukn = old.ukn
  52.         self.cft = old.cft
  53.        
  54.         return old