⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmstat.cpp

📁 基于多假设的地图匹配算法。程序能够根据车辆在行驶过程中收集到的GPS/DR数据正确得到当前车辆所在的道路位置。
💻 CPP
字号:
/******************************************************************************    File Name:   test/MMStat.cpp    Description: calculate the statistics of correct rates according to delay******************************************************************************//******************************************************************************    Author: alfred.liushu@gmail.com	    Upadate:        2007/12/19  File founded        2008/03/28  Worst results added    Copyright 2007-2008 Dept. of Automation, Tsinghua Unviersity******************************************************************************/#include <stdio.h>#include <getopt.h>#include "../MM.h"const UINT maxFileIDCount = 100;const char LoadCRFormat[] = "%*d,%lf";const char SaveCRFormat[] = "%5d,%14.6f\n";int main(int argc, char* argv[]){    int c;    UINT delayStep = 0;    DATATYPE radius = 0;    bool save = false;    bool newSave = false;    /*Input arguments*/    while ((c = getopt (argc, argv, "d:r:snh")) != -1)    {        switch (c) {        case 'd':            sscanf(optarg,"%d",&delayStep);            break;        case 'r':            sscanf(optarg,"%lf",&radius);            break;        case 's':            save = true;            break;        case 'n':            newSave = true;            break;        case 'h':            printf("    Provided options:\n");            printf("      -d delaytime     determine the result of given delay time\n");            printf("      -r radius        ignore mismatches around intersections nearer than radius metres, default is 0\n");            printf("      -s               save results to csv file in folder ./result/(if exists)\n");            printf("      -n               drop results already saved\n");            printf("      -h               get instructions on input options\n");            break;        }    }    /*Open correct rate file*/    FILE* fpCR;    char pathCR[StrLength]="";    sprintf(pathCR,"result/%d/correct_rate_list_r%g.csv",delayStep,radius);    if( (fpCR=fopen(pathCR,"r"))==NULL )    {        #ifdef DEBUG            printf("Fail to load correct rate file.\n");        #endif        return MM_Access;    }    fscanf(fpCR,"%*s");     /*Save average correct rate*/    FILE *fpAvg = NULL;    FILE *fpMin = NULL;    char str[StrLength] = "";    if(save==true)    {        /*Add result to the file*/        sprintf(str,"result/avgcr_r%g.csv",radius);        if( newSave==true || (fpAvg = fopen(str,"r"))==NULL )        {            if( (fpAvg = fopen(str,"w"))==NULL )            {                #ifdef DEBUG                    printf("Fail to open save file.\n");                #endif            }            else            {                fprintf(fpAvg,"Delay,AvgCorrectRate\n");            }        }        else        {            fclose(fpAvg);            if( (fpAvg = fopen(str,"a"))==NULL )            {                #ifdef DEBUG                    printf("Fail to open save file.\n");                #endif            }        }        /*Add result to the file*/        sprintf(str,"result/mincr_r%g.csv",radius);        if( newSave==true || (fpMin = fopen(str,"r"))==NULL )        {            if( (fpMin = fopen(str,"w"))==NULL )            {                #ifdef DEBUG                    printf("Fail to open save file.\n");                #endif            }            else            {                fprintf(fpMin,"Delay,MinCorrectRate\n");            }        }        else        {            fclose(fpMin);            if( (fpMin = fopen(str,"a"))==NULL )            {                #ifdef DEBUG                    printf("Fail to open save file.\n");                #endif            }        }    }    /*Calculate the average*/    UINT ui;    DATATYPE cr,sum,min;    for(ui=0,sum=0,min=1; ui<=maxFileIDCount; ui++)    {        fscanf(fpCR,LoadCRFormat,&cr);        if(feof(fpCR)) break;        sum += cr;        min = MIN(min,cr);    }    UINT totalStep = ui;    /*Output correct rate*/    DATATYPE avgCR = sum/DATATYPE(totalStep);    DATATYPE minCR = min;    if(fpAvg==NULL || fpMin==NULL)    {        printf("The average correct rate of %d second delay and %g metre ignored radius is %.4f%%.\n",delayStep,radius,avgCR*100);        printf("The minimum correct rate of %d second delay and %g metre ignored radius is %.4f%%.\n",delayStep,radius,minCR*100);    }    else    {        fprintf(fpAvg,SaveCRFormat,delayStep,avgCR);        fprintf(fpMin,SaveCRFormat,delayStep,minCR);    }    if(fpCR) fclose(fpCR);    if(fpAvg) fclose(fpAvg);    if(fpMin) fclose(fpMin);    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -