Examples of BitString


Examples of org.uncommons.maths.binary.BitString

     */
    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testTooManySeedCandidates()
    {
        CandidateFactory<BitString> factory = new BitStringFactory(candidateLength);
        BitString candidate = new BitString(candidateLength);
        // The following call should cause an exception since the 3 seed candidates
        // won't fit into a population of size 2.
        factory.generateInitialPopulation(2,
                                          Arrays.asList(candidate, candidate, candidate),
                                          FrameworkTestUtils.getRNG());
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

     */
    @Test
    public void testRandomMutation()
    {
        EvolutionaryOperator<BitString> mutation = new BitStringMutation(Probability.EVENS);
        BitString original = new BitString("111100101");
        List<BitString> population = Arrays.asList(original);
        for (int i = 0; i < 20; i++) // Perform several iterations to get different mutations.
        {
            population = mutation.apply(population, FrameworkTestUtils.getRNG());
            BitString mutated = population.get(0);
            assert mutated.getLength() == 9 : "Mutated bit string changed length.";
        }
    }
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

     * make the outcome predictable (all bits will be flipped).
     */
    @Test
    public void testSingleBitMutation()
    {
        BitString original = new BitString("111100101");
        EvolutionaryOperator<BitString> mutation = new BitStringMutation(Probability.ONE);                                                                        
        List<BitString> population = Arrays.asList(original);
        population = mutation.apply(population, FrameworkTestUtils.getRNG());
        BitString mutated = population.get(0);
        assert !mutated.equals(original) : "Mutation should be different from original.";
        assert mutated.getLength() == 9 : "Mutated bit string changed length.";
        int set = mutated.countSetBits();
        int unset = mutated.countUnsetBits();
        assert set == 5 || set == 7 : "Mutated bit string has wrong number of 1s: " + set;
        assert unset == 2 || unset == 4 : "Mutated bit string has wrong number of 0s: " + unset;
    }
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

   
    // the label is not included in the conditions
    this.nbConditions = DataSet.getDataSet().getNbAttributes() - 1;
   
    weights = new double[nbConditions];
    operators = new BitString(nbConditions);
    values = new double[nbConditions];
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.