public int location ( S solution ) { //Create a int [] to store the range of each objective int [ ] position = new int [ numberOfObjectives ] ; //Calculate the position for each objective for ( int obj = 0 ; obj < numberOfObjectives ; obj ++ ) { if ( ( solution . getObjective ( obj ) > gridUpperLimits [ obj ] ) || ( solution . getObjective ( obj ) < gridLowerLimits [ obj ] ) ) { return - 1 ; } else if ( solution . getObjective ( obj ) == gridLowerLimits [ obj ] ) { position [ obj ] = 0 ; } else if ( solution . getObjective ( obj ) == gridUpperLimits [ obj ] ) { position [ obj ] = ( ( int ) Math . pow ( 2.0 , bisections ) ) - 1 ; } else { double tmpSize = divisionSize [ obj ] ; double value = solution . getObjective ( obj ) ; double account = gridLowerLimits [ obj ] ; int ranges = ( int ) Math . pow ( 2.0 , bisections ) ; for ( int b = 0 ; b < bisections ; b ++ ) { tmpSize /= 2.0 ; ranges /= 2 ; if ( value > ( account + tmpSize ) ) { position [ obj ] += ranges ; account += tmpSize ; } } } } //Calculate the location into the hypercubes int location = 0 ; for ( int obj = 0 ; obj < numberOfObjectives ; obj ++ ) { location += position [ obj ] * Math . pow ( 2.0 , obj * bisections ) ; } return location ; }
Calculates the hypercube of a solution