protected void initializeUniformWeight ( ) { if ( ( problem . getNumberOfObjectives ( ) == 2 ) && ( populationSize <= 300 ) ) { for ( int n = 0 ; n < populationSize ; n ++ ) { double a = 1.0 * n / ( populationSize - 1 ) ; lambda [ n ] [ 0 ] = a ; lambda [ n ] [ 1 ] = 1 - a ; } } else { String dataFileName ; dataFileName = "W" + problem . getNumberOfObjectives ( ) + "D_" + populationSize + ".dat" ; try { // String path = // Paths.get(VectorFileUtils.class.getClassLoader().getResource(filePath).toURI()).toString // (); InputStream in = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( dataDirectory + "/" + dataFileName ) ; InputStreamReader isr = new InputStreamReader ( in ) ; BufferedReader br = new BufferedReader ( isr ) ; int i = 0 ; int j = 0 ; String aux = br . readLine ( ) ; while ( aux != null ) { StringTokenizer st = new StringTokenizer ( aux ) ; j = 0 ; while ( st . hasMoreTokens ( ) ) { double value = new Double ( st . nextToken ( ) ) ; lambda [ i ] [ j ] = value ; j ++ ; } aux = br . readLine ( ) ; i ++ ; } br . close ( ) ; } catch ( Exception e ) { throw new JMetalException ( "initializeUniformWeight: failed when reading for file: " + dataDirectory + "/" + dataFileName , e ) ; } } }
Initialize weight vectors