<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;
          }
        }
    主站蜘蛛池模板: 国产成人精品免费视| 日韩免费高清播放器| 国产成在线观看免费视频| 亚洲国产精品免费视频| 永久在线观看免费视频| 亚洲自偷自偷精品| 91精品视频免费| 在线观看日本亚洲一区| 国产精品四虎在线观看免费| 亚洲欧洲AV无码专区| 国产hs免费高清在线观看| 污污视频免费观看网站| 日韩精品亚洲aⅴ在线影院| 精品一区二区三区免费视频| 亚洲色偷偷综合亚洲AVYP| APP在线免费观看视频| 亚洲成人激情在线| 97免费人妻无码视频| 亚洲国产成人久久一区二区三区| 国产免费拔擦拔擦8x| 好湿好大好紧好爽免费视频| 久久亚洲国产视频| 免费阿v网站在线观看g| 国产精品亚洲专区无码不卡| 亚洲乱码中文字幕综合| 国产va在线观看免费| 67194在线午夜亚洲| 免费va在线观看| 久久免费区一区二区三波多野| 亚洲av乱码一区二区三区| 国产在线观看免费视频播放器| 精品国产呦系列在线观看免费 | 国产精品V亚洲精品V日韩精品| 99精品视频在线观看免费| 亚洲欧洲精品久久| 免费在线黄色网址| 91精品手机国产免费| 深夜A级毛片视频免费| 亚洲天堂在线播放| 免费国内精品久久久久影院| 国产精品免费观看调教网|