Исследование алгоритма оптимизации
Курсовой проект - Менеджмент
Другие курсовые по предмету Менеджмент
, struct creencias *esp) {i, j;(i = 0; i up[j]);
}
}
}violacionInic(float gmax[]) {i;(i = 0; i < NUMCONSTR; i++) {[i] = 0;
}
}violacion(struct individuo *ind, float gmax[]) {i;v;(TRUSSPROBL) {;
}>viol = 0;(i = 0; i g[i]: 0;
}{= fabs(ind->g[i]);
}(v > gmax[i]) {[i] = v;
}>viol += v/gmax[i];
}
}actualizaCreencias(struct individuo *pobl, struct creencias *esp, int t) {aceptados[TOP + 3];i, j, iinf, isup, dim, numHijo, sumando, celda, k = 20;sup, inf;celda *nodoAct;(t%k == 0) {(pobl);(i = 0; i < VARIABLES; i++) {= 0;= pobl[0].variable[i];= 0;= pobl[0].variable[i];(j = 1; j < TOP; j++) {(pobl[j].variable[i] < inf) {= j;= pobl[j].variable[i];
}(pobl[j].variable[i] > sup) {= j;= pobl[j].variable[i];
}
}( (inf L[i] = pobl[iinf].aptitud;
}
}( (sup > esp->u[i]) || (pobl[isup].aptitud U[i] = pobl[isup].aptitud;
}
}
raiz,pobl,esp);(&tiempo2);+=1000*(tiempo2.time-tiempo1.time)+tiempo2.millitm-tiempo1.millitm;">}(&tiempo1);(esp->raiz, pobl, esp);(&tiempo2);+= 1000*(tiempo2.time - tiempo1.time) + tiempo2.millitm - tiempo1.millitm;
}(&tiempo1);(i = 0; i u[j]) {= -1;;
}
}(numHijo == -1) {[i].celda = NULL;;
}(nodoAct = esp->raiz; nodoAct->d[0] != -1; nodoAct = &(nodoAct->hijo[numHijo])) {= 0;= 1;(j = 0; j unodo[dim])/2) {+= sumando;
}+= sumando;
}
}[i].celda = nodoAct;(pobl[i].factible) {[i].celda->factibles++;(pobl[i].celda->factibles == 1) {(pobl[i].celda->noFactibles == 0) {[i].celda->clase = FACTIBLE;
}{[i].celda->clase = SEMIFACTIBLE;(pobl[i].celda->profundidad > 1) {(pobl[i].celda, pobl, esp);= -1;;
}
}
}
}{[i].celda->noFactibles++;(pobl[i].celda->noFactibles == 1) {(pobl[i].celda->factibles == 0) {[i].celda->clase = NO_FACTIBLE;
}{[i].celda->clase = SEMIFACTIBLE;(pobl[i].celda->profundidad > 1) {(pobl[i].celda, pobl, esp);= -1;;
}
}
}
}
}(&tiempo2);+= 1000*(tiempo2.time - tiempo1.time) + tiempo2.millitm - tiempo1.millitm;
}expande(struct celda *nodoAct, struct individuo *pobl, struct creencias *esp) {i, j, numArbol, numHijo, sumando, dim, min;sumMin[PRUEBAS_ARBOL][TREEDIMS + 1];tmp;(nodoAct->hijo == NULL) {>hijo = (struct celda *) malloc(TREENODES*sizeof(struct celda));(i = 0; i profundidad - 1;
}
}(i = 0; i hijo[i].d[0] = -1;
}(nodoAct->padre == NULL) {(i = 0; i u[i];
}
}(VARIABLES > TREEDIMS) {(numArbol = 0; numArbol hijo[i].noFactibles = 0;
}[numArbol][1] = rnd(0, VARIABLES-1);[numArbol][2] = rnd(0, VARIABLES-2);[numArbol][3] = rnd(0, VARIABLES-3);(sumMin[numArbol][2] >= sumMin[numArbol][1]) {[numArbol][2]++;(sumMin[numArbol][3] >= sumMin[numArbol][1]) {[numArbol][3]++;
}(sumMin[numArbol][3] >= sumMin[numArbol][2]) {[numArbol][3]++;
}
}{(sumMin[numArbol][3] >= sumMin[numArbol][2]) {[numArbol][3]++;
}(sumMin[numArbol][3] >= sumMin[numArbol][1]) {[numArbol][3]++;
}
}(i = 0; i unodo[j]) {= -1;;
}
}(numHijo == -1) {;
}= 1;(j = 0; j unodo[dim])/2) {+= sumando;
}+= sumando;
}(pobl[i].factible) {>hijo[numHijo].factibles++;
}{>hijo[numHijo].noFactibles++;
}
}[numArbol][0] = 0;(i = 0; i hijo[i].noFactibles;
}
}= sumMin[0][0];= 0;(i = 1; i < PRUEBAS_ARBOL; i++) {(sumMin[i][0] < min) {= sumMin[i][0];= i;
}
}(i = 0; i d[i] = sumMin[numArbol][i + 1];
}
}{(i = 0; i d[i] = i;
}
}(i = 0; i unodo[j]) {= -1;;
}
}(numHijo == -1) {;
}= 1;(j = 0; j unodo[dim])/2) {+= sumando;
}+= sumando;
}(pobl[i].factible) {>hijo[numHijo].factibles++;
}{>hijo[numHijo].noFactibles++;
}
}(i = 0; i unodo[j];
}= i;= 1;(j = 0; j d[j]] = tmp;-= sumando;
}{>hijo[i].unodo[nodoAct->d[j]] = tmp;
}+= sumando;
}
}(i = 0; i hijo[i].clase = SEMIFACTIBLE;
}{>hijo[i].clase = FACTIBLE;
}
}{(nodoAct->hijo[i].noFactibles > 0) {>hijo[i].clase = NO_FACTIBLE;
}{>hijo[i].clase = DESCONOCIDA;
}
}
}(nodoAct->profundidad > 1) {(i = 0; i hijo[i]), pobl, esp);
}
}
}
}aceptar(struct individuo *pobl) {(pobl, TAMPOBL, sizeof(struct individuo), &compVictorias);
}compAptitud(const void *ind1, const void *ind2) {dif;( ((struct individuo *)ind2)->factible && ((struct individuo *)ind1)->factible ) {(((struct individuo *)ind2)->aptitud > ((struct individuo *)ind1)->aptitud) {-1;
}(((struct individuo *)ind2)->aptitud aptitud) {1;
}0;
}( ((struct individuo *)ind1)->factible ) {-1;
}( ((struct individuo *)ind2)->factible ) {1;
}(((struct individuo *)ind2)->viol > ((struct individuo *)ind1)->viol) {-1;
}(((struct individuo *)ind2)->viol viol) {1;
}0;
}generarHijos(struct individuo *pobl, struct creencias *esp) {i, j;x;(i = 0; i l[j]));
}if (pobl[i].variable[j] > esp->u[j]) {[i+TAMPOBL].variable[j] -= fabs(x*(esp->u[j] - esp->l[j]));
}if (pobl[i].celda == NULL) {[i+TAMPOBL].variable[j] += x*(esp->u[j]-esp->l[j]);
}if (pobl[i].celda->clase == NO_FACTIBLE) {(i, j, x, pobl, esp);
}{[i+TAMPOBL].variable[j] += x*(pobl[i].celda->unodo[j] - pobl[i].celda->lnodo[j]);
}(pobl[i+TAMPOBL].variable[j] > esp->up[j]) {[i+TAMPOBL].variable[j] = esp->up[j];
}if (pobl[i+TAMPOBL].variable[j] lp[j];
}
}
}
}mueve(int indiv, int dim, float x, struct individuo *pobl, struct creencias *esp) {celda *celdaNueva;= cercana(SEMIFACTIBLE, pobl[indiv].celda);(celdaNueva == NULL) {= cercana(DESCONOCIDA, pobl[indiv].celda);
}(celdaNueva == NULL) {[indiv+TAMPOBL].variable[dim] += x*(esp->u[dim] - esp->l[dim]);
}{[indiv+TAMPOBL].variable[dim] = x*(celdaNueva->unodo[dim] - celdaNueva->lnodo[dim]) + (celdaNueva->unodo[dim] + celdaNueva->lnodo[dim])/2;
}
}celda *cercana(int prioridad, struct celda *nodo) {i;celda *res;(; nodo->padre != NULL; nodo = nodo->padre) {(i = 0; i hijo[i]) == nodo) {;
}= busca(prioridad, &(nodo->padre->hijo[i]));(res != NULL) {res;
}
}
}NULL;
}celda *busca(int prioridad, struct celda *nodo) {i;celda *res;(nodo->d[0] == -1) {(nodo->clase <= prioridad) {nodo;
}{NULL;
}
}(i = 0; i hijo[i]));(res != NULL) {res;
}
}NULL;
}selecciona(struct individuo *pobl) {c = TAMPOBL/2;i, j, contr, indmin;min;hayFactibles;(i = 0; (!pobl[i].factible) || (i =i)? contr+1: contr;((pobl[i].factible && pobl[contr].factible)) {(pobl[i].aptitud < pobl[contr].aptitud) {[i].victorias++;
}
}{(!pob