<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    咖啡伴侶

    呆在上海
    posts - 163, comments - 156, trackbacks - 0, articles - 2

    旋轉門壓縮算法

    Posted on 2011-09-14 13:46 oathleo 閱讀(5664) 評論(0)  編輯  收藏 所屬分類: 自己
    對于工業生產現場來說,過程實時數據變化很快,數據存儲量很大,如果每個數據都存儲,在經歷不長時間后就會占據大量磁盤空間。一般來說,工業生產的很多數 據是線性變化的,或者是符合某種規律變化的,如果數據庫能夠根據某些條件進行判斷,將某些可忽略的數據,不進行存儲,而當需要查找該數據時,可以通過線性 或步進插值計算出來,就可以大幅度提高存儲效率,同時節約磁盤空間。

        上述描述的情況就是在線數據壓縮。所謂數據壓縮,就是丟棄那些對于在準確重現現場設備(以下稱為測點)歷史曲線時不是必需的測點數據。

        當今,非常流行的數據壓縮算法是由美國OSI軟件公司研發的旋轉門壓縮算法,此算法已經成功地運用在了PI實時數據庫系統當中,此算法主要針對的對象是浮點數數據類型的數據。

        旋轉門壓縮算法分析:

    • 部分原文:

        With the swinging door algorithm, a value is stored if a straight line drawn between the last stored value and the next value does not come within the compression deviation specification of all the intermediate points. Two slopes are required to carry out this test. The following figure shows the slopes as they are initialized after a value is stored:

    在線數據壓縮算法分析

     

    Figure1 – Swinging Door slopes after recording a value

        The dotted lines are the two slopes. Let the compression deviation specification be 8. One of the lines is drawn from the last recorded value plus 8 through whichever value maximizes the slope of the line. This is the top dotted line in Figure 1. The other dotted line is drawn from the last recorded value minus 8 through whichever value minimizes the slope of the line. The third line is drawn between the last recorded value and the new value. This is the solid line in Figure 1. The previous value is recorded if the slope of the top dotted line is greater than the slope of the solid line or the slope of the solid line is greater than the slope of the bottom dotted line.

        The algorithm ensures that each discarded value falls within the compression deviation specification of the solid line. The compression deviation specification is also the maximum error in a trend of archived values. The next figure shows the lines after four more values have been received.

        The next figure shows the arrival of a value which causes the previous value to be recorded.

    在線數據壓縮算法分析

     

    Figure 2 – Recording a new value

    • 中文解釋:

        對于旋轉門壓縮算法來說,先由上一保存數據項和當前數據項來畫出一條直線(在二維坐標圖上),如果待保存數據項不在當前數據項和上一保存數據項的壓縮偏差范圍之內,則待保存數據項被保存。實驗中還需要兩條斜線(旋轉門)。圖1(Figure 1)中顯示了這兩個旋轉門,傳入系統的第一個測點數據項會直接被保存,否則因為數據庫中沒有被保存的測點數據項就無法確定旋轉門了。

        壓縮偏差是旋轉門壓縮算法中的重要參數,它是人為設定的絕對誤差值,可以簡單的理解為在絕對誤差范圍內,數據被壓縮掉,在絕對誤差范圍外,數據不被壓縮。

        另外,算法的實現還需要計算以下幾個斜率:

       (1)上斜率 K1 =(當前數據項數值 -(上一保存數據項數值 - 壓縮偏差))/(當前數據項時間 - 上一保存數據項時間)

       (2)下斜率 K2 =(當前數據項數值 -(上一保存數據項數值 + 壓縮偏差))/(當前數據項時間 - 上一保存數據項時間)

       (3)中間斜率K =(當前數據項數值 - 待保存數據項數值)/(當前數據項時間 - 待保存數據項時間)

        通過計算壓縮變量上一保存數據項和當前數據項與待保存數據項的斜率來進行壓縮控制。即:

        如果 K2KK1,待保存數據項被壓縮。

        如果 K<K2或者K>K1,待保存數據項被存儲。

     

    算法實現流程如下:

    1.第一個數據項處理:直接存入數據庫。

    2.第二個數據項處理:計算前后兩數據項的上下兩個斜率,并將上下斜率作為后續判斷的依據。

    3.兩個數據項以上處理:計算上中下斜率,進行判斷:(1)如果沒有通過旋轉門壓縮檢測,把上一個數據項信息保存,并將新的上下斜率保存作為后續判斷的依據;(2)如果通過旋轉門壓縮檢測,則不需要保存。

    4.循環執行第三步中的壓縮條件判斷。




    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <unistd.h>
    #include <math.h>
    static int maxnum = 3600;
    void main(int argc,char **argv[])
    {
      int now=0, start=0; 
      FILE *fd, *fd1;
     
      fd = fopen("test", "r");
      fd1 = fopen("test.zip", "w");
     
      float E=10.01;
      float mem, mem_old;
      float upgate; /*定義上門*/ 
      float downgate; /*定義下門*/ 
      float k1; /*k1表示上門和過程數據間的斜率*/ 
      float k2; /*k2表示下門和過程數據間的斜率*/ 
     
      fread(&mem, sizeof(float), 1, fd);
      mem_old = mem;
     
      for(;;) {
       if(now == maxnum-1) {
           fwrite(&mem, sizeof(float), 1, fd1);
           break;
        }
       fwrite(&mem, sizeof(float), 1, fd1);
        start = now;
        upgate=mem+E; 
        downgate=mem-E; 
        k1=-10000; 
        k2=-10000; 
        for(;;) {
         now++;
         mem_old = mem;
         fread(&mem, sizeof(float), 1, fd);
         if(fabs(mem-upgate)>0.001){
          if((mem-upgate)/(now -start)>k1) k1=(mem-upgate)/(now-start); 
           else {
            now=now++;
            fwrite(&mem_old, sizeof(float), 1, fd1);
            break;
           }
          }
          if(fabs(mem-downgate)>0.001){
            if((downgate-mem)/(now-start)>k2) k2=(downgate-mem)/(now-start); 
           else {
            now=now++;
            fwrite(&mem_old, sizeof(float), 1, fd1);
            break;
           }     
          } 
       if(now == maxnum-1) {
            break;
          }
        }
    主站蜘蛛池模板: 亚洲an日韩专区在线| 人人爽人人爽人人片av免费| 日韩成人免费aa在线看| 狼色精品人妻在线视频免费| 亚洲人成网77777亚洲色| 真实国产乱子伦精品免费| 亚洲人片在线观看天堂无码| 亚洲情a成黄在线观看| 性色午夜视频免费男人的天堂| 亚洲国产成人精品激情| 亚洲精品久久久www| 久久成人国产精品免费软件| 无遮挡呻吟娇喘视频免费播放 | 在线观看国产区亚洲一区成人| 亚在线观看免费视频入口| 亚洲日韩精品无码AV海量| 久久伊人亚洲AV无码网站| 青青青国产在线观看免费网站 | 国产精品亚洲w码日韩中文| 老司机在线免费视频| 国产免费高清69式视频在线观看| 亚洲国产福利精品一区二区| 亚洲五月午夜免费在线视频| 在线看片v免费观看视频777| 成人免费一区二区三区 | AAAAA级少妇高潮大片免费看| 亚洲色图激情文学| 亚洲无av在线中文字幕| 韩国18福利视频免费观看| 久久精品一区二区免费看| 免费一级毛片在线播放视频免费观看永久 | 热99re久久免费视精品频软件| 日韩精品在线免费观看| 久青草国产免费观看| 99999久久久久久亚洲| 亚洲国产成人久久精品动漫 | 亚洲日韩国产精品无码av| 亚洲一区精品无码| 亚洲Av无码乱码在线观看性色| 免费A级毛片无码免费视| 午夜无码A级毛片免费视频|