void evaluate() /* Evaluar las particulas de la poblacion */ { unsigned int i, j; for(i = 0; i < popsize; i++) { for(j = 0; j < maxfun; j++) { // switch(function + j) { case 100: /* Kita's primer objetivo */ popFit[i][j] = kita_f1(i); break; case 101: /* Kita's segundo objetivo */ popFit[i][j] = kita_f2(i); break; case 200: /* Kursawe's primer objetivo */ popFit[i][j] = kursawe_f1(i); break; case 201: /* Kursawe's segundo objetivo */ popFit[i][j] = kursawe_f2(i); break; case 300: /* Deb's primer objetivo */ popFit[i][j] = deb_f1(i); break; case 301: /* Deb's segundo objetivo */ popFit[i][j] = deb_f2(i); break; case 350: //printf("%d %d\n",i,function); deb2(i); break; case 400: deb3(i); break; case 450: fonseca2(i); break; case 500: /* DTLZ6's primer objetivo */ popFit[i][j] = DTLZ6_f1(i); break; case 501: /* DTLZ6's segundo objetivo */ popFit[i][j] = DTLZ6_f2(i); break; case 502: /* DTLZ1's tercer objetivo */ popFit[i][j] = DTLZ6_f3(i); break; case 600: /* zdt1 primer objetivo*/ ZDT1(i); break; case 605: /* zdt2 primer objetivo*/ ZDT2(i); break; case 610: /* zdt3 primer objetivo*/ ZDT3(i); break; case 615: /* zdt4 primer objetivo*/ ZDT4(i); break; case 620: /* zdt6 segundo objetivo*/ ZDT6(i); break; case 700: DTLZ1(i); break; case 705: DTLZ2(i); break; case 710: DTLZ3(i); break; case 715: DTLZ4(i); break; case 720: DTLZ5(i); break; case 725: DTLZ6(i); break; case 730: DTLZ7(i); break; /** Agregar mas aqui **/ } /* end of switch */ } } }
/////////////////////////////////////////////////////////////////////////// ////scsReadDirectInitialization/////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //returns 0, if all was read and nothing (but push init_end) remains to be //done, else returns number of bytes to be copied static int scsReadDirectInitialization(scSymbol * deli, scType * type, bool packed, pmem * dest, int type_size, scSymbol * sym) { _value val; /* write to inits or consts*/ #if DEBUGLEVEL==0 deb2(": %s%s", sciValTypeStr(sctypGetValType(type)), packed ? " as packed" : ""); deb1(" (%db)", type_size); if (deli) //inside a function - initialize on the stack { deb0(" on the stack\n"); } else { deb0(" on the heap\n"); } #endif if (type->params && type->params[0]) { /*******************************************Pointer - OK*/ if (type->params[0] == '*' /*||(type->params[0]=='['&&type->params[1]==']') */ ) { //x* t; scType inner_type = *type; inner_type.params++; sctypSimplifyType(&inner_type); #if DEBUGLEVEL==0 deb0("* Pointer"); //Advance; deb1(" %s ", ST->lexema); #endif scAssert(scsReadDirectInitialization, type_size == 4); scget_back(ST); /*as STRING*/ if (ST->lexema[0] == '"') { if (sctypGetValType(&inner_type) != valCHAR) serr(scErr_Declaration, "Illegal array initialization with string"); if (deli) { _value val1, val2; char *s = ST->lexema + 1; s[strlen(s) - 1] = 0; // j=4; #if DEBUGLEVEL==0 deb1("Storing %s\n", s); #endif if (sym) { init_start = act.consts.pos; //inits will be earlier by 4 bytes. s = scStrdup(s); scvalConstantString(&val2, s); // pushstr_pmem(&act.consts,s); Gen_Opcode(opvcpuPUSH, &val2, NULL); } else { pushstr_pmem(&init_end, s); push_pmem(&act.consts, 4, s); //copy to consts anything as pointer Gen_Opcode(opvcpuMOV, scvalSetRegister(&val1, valINT, 0), scvalSetRegister(&val2, valINT, regES)); Gen_Opcode(opvcpuADD, scvalSetRegister(&val1, valINT, 0), scvalSetINT(&val2, init_start)); scvalSetINT(&val1, init_pos); val1.adr.flags = adrBP; val1.adr.address = init_pos; Gen_Opcode(opvcpuMOV, &val1, scvalSetRegister(&val2, valINT, 0)); } init_start += strlen(s) + 1; if (sym) { Advance; Advance; return 0; } //all done } else { int x = -2, y = init_start + act.inits.pos; char *s = ST->lexema + 1; // j=4; s[strlen(s) - 1] = 0; #if DEBUGLEVEL==0 deb1("Storing %s\n", s); deb3("(%d,%d,%d)", y, x, act.consts.pos); #endif push_pmem(&act.inits, 4, &y); //can be anything push_pmem(&init_end, 4, &y); //destination position push_pmem(&init_end, 4, &x); //size=-2:ES //copy to consts segment push_pmem(&init_end, 4, &act.consts.pos); #if DEBUGLEVEL==0 deb1("after %d,", init_end.pos); #endif pushstr_pmem(&act.consts, s); } Advance; Advance; return 4; } else if (lexeq("{")) { serr(scErr_Declaration, "Don't use {} in initialization of pointer."); } else /*as VARIABLE*/ { //exit to primitive read } } //Pointer* else /*******************************************Table*/ if (type->params[0] == '[') { //x t[xx]; scType tp = *type; int tabsize, initsize = 0, inner_type_size; #if DEBUGLEVEL==0 deb0("Table"); #endif tp.params++; tabsize = strtoul(tp.params, &tp.params, 10); scAssert(Read_Init_Type[], *tp.params == ']'); tp.params++; sctypSimplifyType(&tp); inner_type_size = sctypSizeOf(&tp); #if DEBUGLEVEL==0 deb2("[%d] of %d bytes;\n", tabsize, inner_type_size); #endif //Advance; if (ST->lexema[0] == '"') { char *data; /*as STRING*/ if (sctypGetValType(&tp) != valCHAR) serr(scErr_Declaration, "Illegal array initialization with string"); #if DEBUGLEVEL==0 deb1("char[%d] init\n", tabsize); #endif data = scStrdup(ST->lexema + 1); data[strlen(data) - 1] = 0; //erase " pushstr_pmem(dest, data); /* {char temp[100]; int i=tabsize-strlen(data)-1; while(i) if (i>100) {push_pmem(dest,100,temp);i-=100;} else {push_pmem(dest,i,temp);i=0;} }*/ initsize = strlen(data) + 1; /*initialize all the data, if packed */ if (packed && initsize < type_size) { char c = 0; int i; for (i = initsize; i < type_size; i++) push_pmem(dest, 1, &c); initsize = type_size; } scFree(data); Advance; return initsize; } else if (lexeq("{")) { int i = 0, j; for (; i < tabsize; i++) { Advance; j = scsReadDirectInitialization(deli, &tp, true, dest, inner_type_size, NULL); init_pos += inner_type_size; scAssert(scsReadDirectInitialization[], j); //same here initsize += j; if (i < tabsize - 1) { if (!lexeq(",")) serr2(scErr_Parse, parse_error, ST->lexema); } } if (lexeq(",")) { Advance; } if (!lexeq("}")) serr2(scErr_Parse, parse_error, ST->lexema); Advance; return initsize; } else //VARIABLE { serr2(scErr_Parse, parse_error, ST->lexema); } } //Table[] }