int main() { int i,k; init(); /* initialize values*/ //printf("va\t vb\t vc\t sa\t sb\t sc\t f\t pa\t pb\t pc\n"); for(i=0;i<noi;i++) { update_param(i); //printf("a=%lf \n b=%lf\n c=%lf\n",gbesta,gbestb,gbestc); for(k=0;k<nop;k++) {/* following line to be added to view iterations*/ //printf("%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n",vc[k],sa[k],sb[k],sc[k],f[k],pbesta[k],pbestb[k],pbestc[k]); updatea(k); /*update to find new a value*/ updateb(k); /*update particle to new b value*/ updatec(k); cal_fn(k); /* calculate function fn value*/ find_pbest(k); update_param(k); /* find the personal best for this particle*/ } find_gbest(); /* find global best position traversed so far*/ } printf("a=%lf \n b=%lf\nc=%lf\n",gbesta,gbestb,gbestc); double mare=0,tmre=0; printf("Estimated effort \t actual effort\n"); printf("---------------------------------------------\n"); for(i=0;i<nop;i++) /* calculation of efort values from final values of a,b,c*/ { gfunc=gbesta*pow(size[i],gbestb)+(gbestc*me[i]); mare=gfunc-eval[i]; mare=mare<0?-mare:mare; tmre+=mare; printf("%lf\t\t %lf\n",gfunc,eval[i]); } /* displaying the MARE value*/ tmre=tmre/nop; printf("total mre=%lf\n",tmre); return 0; }
int main() { int i,k; init(); /* initialize values*/ for(i=0;i<noi;i++) { for(k=0;k<nop;k++) { updatea(k); /*update to find new a value*/ updateb(k); /*update particle to new b value*/ updatec(k); updated(k); cal_fn(k); /* calculate function fn value*/ find_pbest(k); /* find the personal best for this particle*/ } find_gbest(); /* find global best position traversed so far*/ } printf("a=%lf \n b=%lf\nc=%lf\nd=%lf\n",gbesta,gbestb,gbestc,gbestd); printf("estimated value \t actual value\n"); printf("---------------------------------------\n"); double mare=0,tmre=0; /* final effort values calculated using a,b,c,d values obtained*/ for(i=0;i<nop;i++) { gfunc=gbesta*pow(size[i],gbestb)+(gbestc*me[i])+gbestd; mare=gfunc-eval[i]; mare=mare<0?-mare:mare; tmre+=mare; printf("%lf\t\t%lf\n",gfunc,eval[i]); } tmre=tmre/nop; printf("total mre=%lf",tmre); return 0; }
int main() { int i,k; init(); /* initialize values*/ for(i=0;i<noi;i++) { for(k=0;k<nop;k++) { updatea(k); /*update to find new a value*/ updateb(k); /*update particle to new b value*/ updatec(k); cal_fn(k); /* calculate function fn value*/ find_pbest(k); /* find the personal best for this particle*/ } find_rankings(); find_gbest(); /* find global best position traversed so far*/ } printf("a=%lf \n b=%lf\nc=%lf\n",gbesta,gbestb,gbestc); double mare=0,tmre=0; printf("Estimated effort \t actual effort\n"); printf("---------------------------------------------\n"); for(i=0;i<val;i++) /* calculation of efoort values from final values of a,b,c*/ { gfunc=gbesta*pow(size[i],gbestb)*eaf[i]+gbestc; printf("%lf\t\t %lf\n",gfunc,eval[i]); } printf("\n number of values below 25=%d",find_count(gbesta,gbestb,gbestc)); //end:printf("\n %lf",gfunc); printf("\n #### MARE =%lf###\n",fn(gbesta,gbestb,gbestc)*100); return 0; }
int main() { int n, q, z = 1, x, y, ans, t, m, i; n = read_int(); q = read_int(); //scanf("%d%d", &n, &q); char s[10]; max = q; for(z = 1; z <= q; z++) { scanf("%s", s); if(strcmp(s, "ColSet") == 0) { //scanf("%d%d", &x, &y); x = read_int(); y = read_int(); if(cs0[x]||cs1[x]) if(cs0[x] > cs1[x])updatec(0, cs0[x], -1); else updatec(1, cs1[x], -1); if(y == 0) { cs0[x] = z; updatec(0, cs0[x], 1); } else { cs1[x] = z; updatec(1, cs1[x], 1); } } else if(strcmp(s, "RowSet") == 0) { //scanf("%d%d", &x, &y); x = read_int(); y = read_int(); if(rs0[x]||rs1[x]) if(rs0[x] > rs1[x])updater(0, rs0[x], -1); else updater(1, rs1[x], -1); if(y == 0) { rs0[x] = z; updater(0, rs0[x], 1); } else { rs1[x] = z; updater(1, rs1[x], 1); } } else if(strcmp(s, "RowQuery") == 0) { //scanf("%d", &x); x = read_int(); if(rs0[x] >= rs1[x]) { ans = readc(1, z) - readc(1, rs0[x]); printf("%d\n", n-ans); } else { ans = readc(0, z) - readc(0, rs1[x]); printf("%d\n", ans); } } else if(strcmp(s, "ColQuery") == 0) { //scanf("%d", &x); x = read_int(); if(cs0[x] >= cs1[x]) { ans = readr(1, z) - readr(1, cs0[x]); printf("%d\n", n-ans); } else { ans = readr(0, z) - readr(0, cs1[x]); printf("%d\n", ans); } } } return 0; }