<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;
          }
        }
    主站蜘蛛池模板: 美女视频黄视大全视频免费的| 亚洲成人福利网站| 黄色毛片免费网站| 成人免费视频国产| 国产成人亚洲综合a∨| 国产免费人成视频在线观看| 亚洲高清一区二区三区电影| 永久免费av无码网站大全| 噜噜综合亚洲AV中文无码| 国产精品久免费的黄网站| 羞羞漫画页面免费入口欢迎你 | 一级做受视频免费是看美女| 亚洲国产中文v高清在线观看| 国产黄在线播放免费观看| 国产亚洲A∨片在线观看| 午夜视频免费在线观看| 亚洲人成在线播放| 永久免费bbbbbb视频| fc2免费人成在线| 久久精品国产69国产精品亚洲| 一级做a爰全过程免费视频| 亚洲AV无码成人专区| 四虎永久免费地址在线网站| 中文字幕乱理片免费完整的| 亚洲日韩区在线电影| 好男人视频社区精品免费| 美美女高清毛片视频黄的一免费| 国内精品99亚洲免费高清| 永久黄色免费网站| WWW国产亚洲精品久久麻豆| 77777亚洲午夜久久多人| 日本免费一区二区在线观看| 风间由美在线亚洲一区| 亚洲AV无码久久精品成人| 免费在线看v网址| 日本中文字幕免费看| 亚洲国产韩国一区二区| 免费人妻无码不卡中文字幕18禁| 黄页网站在线免费观看| 色婷婷六月亚洲婷婷丁香| 午夜高清免费在线观看|