public void removeWorst ( List < S > solutionSet ) { // Find the worst; double worst = ( double ) solutionFitness . getAttribute ( solutionSet . get ( 0 ) ) ; int worstIndex = 0 ; double kappa = 0.05 ; for ( int i = 1 ; i < solutionSet . size ( ) ; i ++ ) { if ( ( double ) solutionFitness . getAttribute ( solutionSet . get ( i ) ) > worst ) { worst = ( double ) solutionFitness . getAttribute ( solutionSet . get ( i ) ) ; worstIndex = i ; } } // Update the population for ( int i = 0 ; i < solutionSet . size ( ) ; i ++ ) { if ( i != worstIndex ) { double fitness = ( double ) solutionFitness . getAttribute ( solutionSet . get ( i ) ) ; fitness -= Math . exp ( ( - indicatorValues . get ( worstIndex ) . get ( i ) / maxIndicatorValue ) / kappa ) ; solutionFitness . setAttribute ( solutionSet . get ( i ) , fitness ) ; } } // remove worst from the indicatorValues list indicatorValues . remove ( worstIndex ) ; for ( List < Double > anIndicatorValues_ : indicatorValues ) { anIndicatorValues_ . remove ( worstIndex ) ; } solutionSet . remove ( worstIndex ) ; }
Update the fitness before removing an individual