private List < Double > knnDistances ( S solution , L solutionList ) { List < Double > listOfDistances = new ArrayList <> ( ) ; for ( int i = 0 ; i < solutionList . size ( ) ; i ++ ) { double distanceBetweenSolutions = distance . getDistance ( solution , solutionList . get ( i ) ) ; if ( distanceBetweenSolutions != 0 ) { listOfDistances . add ( distanceBetweenSolutions ) ; } } return listOfDistances ; }
Computes the distance between a solution and the solutions of a list . Distances equal to 0 are ignored .