public void deleteCrowdIndiv_diff ( int crowdIdx , int curLocation , int nicheCount , S indiv ) { // find the solution indices within this crowdIdx subregion ArrayList < Integer > indList = new ArrayList <> ( ) ; for ( int i = 0 ; i < populationSize ; i ++ ) { if ( subregionIdx [ crowdIdx ] [ i ] == 1 ) { indList . add ( i ) ; } } // find the solution with the worst fitness value int worstIdx = indList . get ( 0 ) ; double maxFitness = fitnessFunction ( population . get ( worstIdx ) , lambda [ crowdIdx ] ) ; for ( int i = 1 ; i < nicheCount ; i ++ ) { int curIdx = indList . get ( i ) ; double curFitness = fitnessFunction ( population . get ( curIdx ) , lambda [ crowdIdx ] ) ; if ( curFitness > maxFitness ) { worstIdx = curIdx ; maxFitness = curFitness ; } } // use indiv to replace the worst one replace ( worstIdx , indiv ) ; subregionIdx [ crowdIdx ] [ worstIdx ] = 0 ; subregionIdx [ curLocation ] [ worstIdx ] = 1 ; }
delete one solution from the most crowded subregion which is different from indiv s subregion . just use indiv to replace the worst solution in that subregion