public void buildNewReferenceSet2 ( ) { for ( int i = 0 ; i < getPopulation ( ) . size ( ) ; i ++ ) { DoubleSolution individual = getPopulation ( ) . get ( i ) ; double distanceAux = SolutionUtils . distanceToSolutionListInSolutionSpace ( individual , referenceSet1 ) ; distanceToSolutionListAttribute . setAttribute ( individual , distanceAux ) ; } int size = referenceSet2Size ; if ( getPopulation ( ) . size ( ) < referenceSet2Size ) { size = getPopulation ( ) . size ( ) ; } for ( int i = 0 ; i < size ; i ++ ) { // Find the maximumMinimumDistanceToPopulation double maxMinimum = 0.0 ; int index = 0 ; for ( int j = 0 ; j < getPopulation ( ) . size ( ) ; j ++ ) { DoubleSolution auxSolution = getPopulation ( ) . get ( j ) ; if ( distanceToSolutionListAttribute . getAttribute ( auxSolution ) > maxMinimum ) { maxMinimum = distanceToSolutionListAttribute . getAttribute ( auxSolution ) ; index = j ; } } DoubleSolution individual = getPopulation ( ) . get ( index ) ; getPopulation ( ) . remove ( index ) ; // Update distances to REFSET in population for ( int j = 0 ; j < getPopulation ( ) . size ( ) ; j ++ ) { double aux = SolutionUtils . distanceBetweenSolutionsInObjectiveSpace ( getPopulation ( ) . get ( j ) , individual ) ; if ( aux < distanceToSolutionListAttribute . getAttribute ( individual ) ) { DoubleSolution auxSolution = getPopulation ( ) . get ( j ) ; distanceToSolutionListAttribute . setAttribute ( auxSolution , aux ) ; } } // Insert the individual into REFSET2 marked . setAttribute ( individual , false ) ; referenceSet2 . add ( individual ) ; // Update distances in REFSET2 for ( int j = 0 ; j < referenceSet2 . size ( ) ; j ++ ) { for ( int k = 0 ; k < referenceSet2 . size ( ) ; k ++ ) { if ( i != j ) { double aux = SolutionUtils . distanceBetweenSolutionsInObjectiveSpace ( referenceSet2 . get ( j ) , referenceSet2 . get ( k ) ) ; DoubleSolution auxSolution = referenceSet2 . get ( j ) ; if ( aux < distanceToSolutionListAttribute . getAttribute ( auxSolution ) ) { distanceToSolutionListAttribute . setAttribute ( auxSolution , aux ) ; } } } } } }
Build the referenceSet2 by moving to it the most diverse referenceSet2Size individuals from the population in respect to the referenceSet1 .