Пример #1
0
int stDoubleTuple_cmpFn(stDoubleTuple *doubleTuple1,
        stDoubleTuple *doubleTuple2) {
    int32_t i, j = stDoubleTuple_length(doubleTuple1) < stDoubleTuple_length(
            doubleTuple2) ? stDoubleTuple_length(doubleTuple1)
            : stDoubleTuple_length(doubleTuple2);
    for (i = 0; i < j; i++) {
        int32_t k = doubleCmp(stDoubleTuple_getPosition(doubleTuple1, i),
                stDoubleTuple_getPosition(doubleTuple2, i));
        if (k != 0) {
            return k;
        }
    }
    return intCmp(stDoubleTuple_length(doubleTuple1), stDoubleTuple_length(
            doubleTuple2));
}
Пример #2
0
	void compareAtIterAlgo1R(FILE *out,int iter) {
//	compare bound at iteration
//	given an iteration number, it determines the bound in f_res1 at that iteration (or at its last iter if the case) and then finds the iteration in f_res2 with the same or better bound. Prints those results.
//	does not count zero gap things
		
		fprintfRHeader(out);

		for(int i=0;i<getSolutions()->getNumInstances();i++) {
			if (iter < 0)
				return;

			int f_res1_iter,f_res2_iter;
			f_res1_iter = iter;

			double bound1_at_iter;
//clean out this a little

			if ((f_res1_iter >= getF_res(1)->getIter(i)-1) && (getF_res(1)->getIter(i) >= 0)) {
				f_res1_iter = getF_res(1)->getIter(i)-1;
				bound1_at_iter = getF_res(1)->getDoubleField(i,f_res1_iter,F_RES_UBOUND);
			} else	if (getF_res(1)->getIter(i) < 0) {
					bound1_at_iter = -COIN_DBL_MAX;
					f_res1_iter = -1;
			} else {
				bound1_at_iter = getF_res(1)->getDoubleField(i,f_res1_iter,F_RES_UBOUND);
			}

			//finds a bound in f_res2 which is equal or better than bound1_at_iter
			f_res2_iter = -1;
			for (int j=0;j<getF_res(2)->getIter(i)-1;j++) {
//				printf(":%d  alg1=%.2f alg2=%.2f\n",j,- bound1_at_iter,- getF_res(2)->getDoubleField(i,j,F_RES_UBOUND));
				if (doubleCmp(- bound1_at_iter , 
						- getF_res(2)->getDoubleField(i,j,F_RES_UBOUND)) != 2) {
					//either equal or bound2 better than bound1
					f_res2_iter = j;
					break;
				}
			}

			fprintfRLine(out,i,f_res1_iter,f_res2_iter);

		}
	}
Пример #3
0
	void compareAtLastIter(FILE *out) {
		fprintfReportHeader(out);
		
		int bound_tot = 0;
		int bound_tot_1 = 0;
		int bound_tot_2 = 0;
		int bound_tot_tail = 0;

		for(int i=0;i<getSolutions()->getNumInstances();i++) {
			char string[256] = "#";
			int f_res1_iter = getF_res(1)->getIter(i)-1;
			int f_res2_iter = getF_res(2)->getIter(i)-1;
			if ((f_res1_iter>=0)&&(f_res2_iter>=0)) {
				bound_tot++;
				switch (doubleCmp(- getF_res(1)->getDoubleField(i,f_res1_iter,F_RES_UBOUND),
						  - getF_res(2)->getDoubleField(i,f_res2_iter,F_RES_UBOUND))) {
					case 0:
						bound_tot_tail++;
						strcpy(string,"=");
						break;
					case 1:
						bound_tot_2++;
						strcpy(string,"2");
						break;
					case 2:
						bound_tot_1++;
						strcpy(string,"1");
						break;
					default: 
						break;
				}
			}
			fprintfReportLine(out,i,f_res1_iter,f_res2_iter,string);
		}
		double bound_tot_1_perc,bound_tot_2_perc,bound_tot_tail_perc;
		bound_tot_1_perc = 100 *((double) bound_tot_1 ) / ((double) bound_tot);
		bound_tot_2_perc = 100 *((double) bound_tot_2 ) / ((double) bound_tot);
		bound_tot_tail_perc = 100 *((double) bound_tot_tail ) / ((double) bound_tot);
		fprintf(out,"\n\n");
		fprintf(out,"Results for best bound on %d significant instances.\n",bound_tot);
		fprintf(out,"  Best bound:  algorithm_1 = %d [%.2f%%]   algorithm_2 = %d [%.2f%%]  ties = %d [%.2f%%]\n",bound_tot_1,bound_tot_1_perc,bound_tot_2,bound_tot_2_perc,bound_tot_tail,bound_tot_tail_perc);
	}
Пример #4
0
	void compareAtIterAlgo1(FILE *out,int iter) {
		fprintfReportHeader(out);
//	compare bound at iteration
//	given an iteration number, it determines the bound in f_res1 at that iteration (or at its last iter if the case) and then finds the iteration in f_res2 with the same or better bound. Prints those results.
//	does not count zero gap things

		int time_cmp_tot = 0;
		int time_cmp_tot_1 = 0;
		int time_cmp_tot_2 = 0;
		int time_cmp_tot_tail = 0;

		for(int i=0;i<getSolutions()->getNumInstances();i++) {
			if (iter < 0)
				return;

			char string[256] = "#";
			int f_res1_iter,f_res2_iter;
			f_res1_iter = iter;

			double bound1_at_iter;
//clean out this a little

			if ((f_res1_iter >= getF_res(1)->getIter(i)-1) && (getF_res(1)->getIter(i) >= 0)) {
				f_res1_iter = getF_res(1)->getIter(i)-1;
				bound1_at_iter = getF_res(1)->getDoubleField(i,f_res1_iter,F_RES_UBOUND);
			} else	if (getF_res(1)->getIter(i) < 0) {
					bound1_at_iter = -COIN_DBL_MAX;
					f_res1_iter = -1;
			} else {
				bound1_at_iter = getF_res(1)->getDoubleField(i,f_res1_iter,F_RES_UBOUND);
			}

			//finds a bound in f_res2 which is equal or better than bound1_at_iter
			f_res2_iter = -1;
			for (int j=0;j<getF_res(2)->getIter(i)-1;j++) {
//				printf(":%d  alg1=%.2f alg2=%.2f\n",j,- bound1_at_iter,- getF_res(2)->getDoubleField(i,j,F_RES_UBOUND));
				if (doubleCmp(- bound1_at_iter , 
						- getF_res(2)->getDoubleField(i,j,F_RES_UBOUND)) != 2) {
					//either equal or bound2 better than bound1
					f_res2_iter = j;
					break;
				}
			}

			if ((f_res1_iter == -1) && (f_res2_iter == -1)) {
				strcpy(string,"#");
			}
			else if (f_res2_iter == -1) {
				strcpy(string,"1");
				time_cmp_tot_1++;
				time_cmp_tot++;
			} else {
				time_cmp_tot++;
				switch (doubleCmp(getF_res(1)->getDoubleField(i,f_res1_iter,F_RES_TIME),
				                  getF_res(2)->getDoubleField(i,f_res2_iter,F_RES_TIME)) ) {
					case 0:
						time_cmp_tot_tail++;
						strcpy(string,"=");
						break;
					case 1:
						time_cmp_tot_1++;
						strcpy(string,"1");
						break;
					case 2:
						time_cmp_tot_2++;
						strcpy(string,"2");
						break;
					default: 
						break;
				}
			}

			fprintfReportLine(out,i,f_res1_iter,f_res2_iter,string);
		}

		double time_cmp_tot_1_perc,time_cmp_tot_2_perc,time_cmp_tot_tail_perc;
		time_cmp_tot_1_perc = 100 *((double) time_cmp_tot_1 ) / ((double) time_cmp_tot);
		time_cmp_tot_2_perc = 100 *((double) time_cmp_tot_2 ) / ((double) time_cmp_tot);
		time_cmp_tot_tail_perc = 100 *((double) time_cmp_tot_tail ) / ((double) time_cmp_tot);
		fprintf(out,"\n\n");
		fprintf(out,"Results for best time@bound@iter_alg1=%d on %d significant instances.\n",iter,time_cmp_tot);
		fprintf(out,"  Best time:  algorithm_1 = %d [%.2f%%]   algorithm_2 = %d [%.2f%%]  ties = %d [%.2f%%]\n",time_cmp_tot_1,time_cmp_tot_1_perc,time_cmp_tot_2,time_cmp_tot_2_perc,time_cmp_tot_tail,time_cmp_tot_tail_perc);

	}