Package org.uncommons.maths.binary

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


     * @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

   
    // 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

    // 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

    // 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

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

     */
    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

     * @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

    {
        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

    @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

TOP

Related Classes of org.uncommons.maths.binary.BitString

Copyright © 2018 www.massapicom. 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.