BitSetBinaryRepresentation implements GenotypeRepresentation { public void setDoubleValue(double[] phenotypeValue) { if (this.genome == null || this.genomeLength == 0){ this.genome = new BitSet( MathUtils.sumSizes(this.descriptor.getVariablesLengths()) ); } double[] intValues = new double[this.descriptor.getNumVariables()]; for (int i = 0; i < this.descriptor.getNumVariables(); i++){ if (phenotypeValue[i] < this.descriptor.getVariablesLowerBounds()[i]){ phenotypeValue[i] = this.descriptor.getVariablesLowerBounds()[i]; } intValues[i] = Math.ceil((phenotypeValue[i] - this.descriptor.getVariablesLowerBounds()[i]) / this.descriptor.getVariablesPrecisions()[i]); } integerToBinary(intValues); } BitSetBinaryRepresentation(SimpleBinaryGenomeDescriptor descriptor);  BitSetBinaryRepresentation(BitSetBinaryRepresentation second); int getTotalLength(); int[] getValueLengths(); boolean getGeneAt(int idx); void setGeneAt(int idx, boolean value); void invertGeneAt(int idx); void swapGenes(GenotypeRepresentation secondRepresentation, int[] positions); void swapGenes(GenotypeRepresentation secondRepresentation, int from, int to); void receiveGenes(GenotypeRepresentation secondRepresentation, int[] positions); void receiveGenes(GenotypeRepresentation secondRepresentation, int from, int to); void andGenes(GenotypeRepresentation secondRepresentation, int[] positions); void andGenes(GenotypeRepresentation secondRepresentation, int from, int to); void orGenes(GenotypeRepresentation secondRepresentation, int[] positions); void orGenes(GenotypeRepresentation secondRepresentation, int from, int to); void xorGenes(GenotypeRepresentation secondRepresentation, int[] positions); void xorGenes(GenotypeRepresentation secondRepresentation, int from, int to); double[] getDoubleValue(); void setDoubleValue(double[] phenotypeValue); Representation copy();  }
@Test public void testSetDoubleValue1(){ this.representation.setDoubleValue(new double[]{13.0, 1.0, 1851.75+10e10, 123456.5}); boolean[] boolGenome = new boolean[this.representation.genomeLength]; for (int idx = 0; idx < boolGenome.length; idx++){ boolGenome[idx] = this.representation.genome.get(idx); } boolean[] expected = new boolean[]{ false, true, false, true, true, true, true, false, true, true, true, true, true, true, true, true, true, false, true, false, false }; assertEquals(expected.length, boolGenome.length); for (int i = 0; i < expected.length; i++){ assertEquals(expected[i], boolGenome[i]); } }