00001 #include "NSGAII_MIES.h" 00002 00003 //------------------------------------------------------------------------------ 00004 // Class NSGAII_MIES 00005 //------------------------------------------------- 00006 // Protected Members 00007 00008 /* Determine bestF value(s) for current population; only necessary for initial generation since otherwise taken care of in select() */ 00009 void NSGAII_MIES::determineBestF() 00010 { 00011 #ifdef DEBUG 00012 cout << "NSGAII_MIES::determineBestF()" << endl; 00013 #endif 00014 00015 /* Compare Individuals */ 00016 for (unsigned i = 0; i < mu; i++) 00017 { 00018 for (unsigned j = 0; j < mu; j++) 00019 { 00020 if (i == j) 00021 continue; 00022 00023 compare(P[i], P[j], bestF, false, false); 00024 } 00025 } 00026 } 00027 00028 /* In case of convergence study (i.e., with known optima supplied) determine whether optima have been reached */ 00029 bool NSGAII_MIES::optimumReached() 00030 { 00031 #ifdef DEBUG 00032 cout << "NSGAII_MIES::optimumReached()" << endl; 00033 #endif 00034 00035 vector<bool> reached(selectDimension, false); 00036 00037 if (generations == USHRT_MAX) // Convergence study 00038 { 00039 for (unsigned i = 0; i < selectDimension; i++) 00040 { 00041 if (direction[selectFunction[i]] == 1) 00042 { 00043 if (bestF[selectFunction[i]] >= optimalF[selectFunction[i]]) 00044 reached[i] = true; 00045 } 00046 else 00047 { 00048 if (bestF[selectFunction[i]] <= optimalF[selectFunction[i]]) 00049 reached[i] = true; 00050 } 00051 } 00052 } 00053 else // Study with fixed number of evaluations 00054 return false; 00055 00056 for (unsigned i = 0; i < selectDimension; i++) 00057 { 00058 if (!reached[i]) 00059 return false; 00060 } 00061 00062 return true; 00063 } 00064