Examples of BitString


Examples of org.uncommons.maths.binary.BitString

     * @param n The number of trials.
     * @return The number of successful outcomes from {@literal n} trials.
     */
    private int binomialWithEvenProbability(int n)
    {
        BitString bits = new BitString(n, rng);
        return bits.countSetBits();
    }
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

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

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

Examples of org.uncommons.maths.binary.BitString

public class BitsExampleTest
{
    @Test
    public void testEvolution()
    {
        BitString result = BitsExample.evolveBits(8);
        assert result.toString().equals("11111111") : "Wrong result returned: " + result.toString();
    }
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

     */
    private BitString mutateBitString(BitString bitString, Random rng)
    {
        if (mutationProbability.nextValue().nextEvent(rng))
        {
            BitString mutatedBitString = bitString.clone();
            int mutations = mutationCount.nextValue();
            for (int i = 0; i < mutations; i++)
            {
                mutatedBitString.flipBit(rng.nextInt(mutatedBitString.getLength()));
            }
            return mutatedBitString;
        }
        return bitString;
    }
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

     * @return A random bit string of the length configured for this
     * factory.
     */
    public BitString generateRandomCandidate(Random rng)
    {
        return new BitString(length, rng);
    }
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

    {
        if (parent1.getLength() != parent2.getLength())
        {
            throw new IllegalArgumentException("Cannot perform cross-over with different length parents.");
        }
        BitString offspring1 = parent1.clone();
        BitString offspring2 = parent2.clone();
        // Apply as many cross-overs as required.
        for (int i = 0; i < numberOfCrossoverPoints; i++)
        {
            // Cross-over index is always greater than zero and less than
            // the length of the parent so that we always pick a point that
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testDifferentLengthParents()
    {
        EvolutionaryOperator<BitString> crossover = new BitStringCrossover(new ConstantGenerator<Integer>(1));
        List<BitString> population = new ArrayList<BitString>(2);
        population.add(new BitString(32, FrameworkTestUtils.getRNG()));
        population.add(new BitString(33, FrameworkTestUtils.getRNG()));
        // This should cause an exception since the parents are different lengths.
        crossover.apply(population, FrameworkTestUtils.getRNG());
    }
View Full Code Here

Examples of org.uncommons.maths.binary.BitString

    @Test
    public void testSeededPopulation()
    {
        CandidateFactory<BitString> factory = new BitStringFactory(candidateLength);
        BitString seed1 = new BitString("1111100000");
        BitString seed2 = new BitString("1010101010");
        List<BitString> seeds = new ArrayList<BitString>(2);
        seeds.add(seed1);
        seeds.add(seed2);
        List<BitString> population = factory.generateInitialPopulation(populationSize,
                                                                       seeds,
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.