<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

    旋轉(zhuǎn)門壓縮算法

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

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

        當(dāng)今,非常流行的數(shù)據(jù)壓縮算法是由美國OSI軟件公司研發(fā)的旋轉(zhuǎn)門壓縮算法,此算法已經(jīng)成功地運用在了PI實時數(shù)據(jù)庫系統(tǒng)當(dāng)中,此算法主要針對的對象是浮點數(shù)數(shù)據(jù)類型的數(shù)據(jù)。

        旋轉(zhuǎn)門壓縮算法分析:

    • 部分原文:

        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:

    在線數(shù)據(jù)壓縮算法分析

     

    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.

    在線數(shù)據(jù)壓縮算法分析

     

    Figure 2 – Recording a new value

    • 中文解釋:

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

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

        另外,算法的實現(xiàn)還需要計算以下幾個斜率:

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

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

       (3)中間斜率K =(當(dāng)前數(shù)據(jù)項數(shù)值 - 待保存數(shù)據(jù)項數(shù)值)/(當(dāng)前數(shù)據(jù)項時間 - 待保存數(shù)據(jù)項時間)

        通過計算壓縮變量上一保存數(shù)據(jù)項和當(dāng)前數(shù)據(jù)項與待保存數(shù)據(jù)項的斜率來進行壓縮控制。即:

        如果 K2KK1,待保存數(shù)據(jù)項被壓縮。

        如果 K<K2或者K>K1,待保存數(shù)據(jù)項被存儲。

     

    算法實現(xiàn)流程如下:

    1.第一個數(shù)據(jù)項處理:直接存入數(shù)據(jù)庫。

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

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

    4.循環(huán)執(zhí)行第三步中的壓縮條件判斷。




    #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表示上門和過程數(shù)據(jù)間的斜率*/ 
      float k2; /*k2表示下門和過程數(shù)據(jù)間的斜率*/ 
     
      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;
          }
        }
    主站蜘蛛池模板: 亚洲国产精品第一区二区| 亚洲国产精品无码久久九九| 亚洲AV无码成人精品区天堂| 色播在线永久免费视频网站| 久久国产成人精品国产成人亚洲| 人妻18毛片a级毛片免费看| 亚洲精品尤物yw在线影院| 无码 免费 国产在线观看91| 亚洲国产精品不卡毛片a在线| 精品免费AV一区二区三区| 亚洲午夜精品久久久久久浪潮| 四虎影视久久久免费| 亚洲午夜未满十八勿入网站2| 两个人的视频www免费| 久久精品国产亚洲AV麻豆~ | 男女啪啪免费体验区| 亚洲?v女人的天堂在线观看| 五月天婷婷免费视频| 亚洲AV综合色区无码另类小说| 99视频在线精品免费| 亚洲AV男人的天堂在线观看| 国产免费av一区二区三区| 国产裸体美女永久免费无遮挡| 亚洲第一极品精品无码久久| 又大又硬又爽又粗又快的视频免费| 亚洲区精品久久一区二区三区| 青青青国产免费一夜七次郎| 一级一黄在线观看视频免费| 亚洲av无码乱码国产精品fc2| 国产卡一卡二卡三免费入口| 国产偷国产偷亚洲高清在线| 亚洲国产精品VA在线看黑人| 97免费人妻无码视频| 日本精品久久久久久久久免费| 亚洲VA中文字幕不卡无码| 成人浮力影院免费看| 久久久久亚洲精品无码网址色欲| 亚洲人成网77777色在线播放| 四虎在线免费视频| 一级毛片a免费播放王色| 噜噜噜亚洲色成人网站∨|