Package org.uncommons.maths.random

Examples of org.uncommons.maths.random.Probability


    @Test(dependsOnMethods = "testSlider",
          groups = "display-required")
    public void testReset()
    {
        Probability defaultValue = new Probability(0.75d);
        ProbabilityParameterControl control = new ProbabilityParameterControl(defaultValue);

        JFrame frame = new JFrame();
        frame.add(control.getControl(), BorderLayout.CENTER);
        FrameFixture frameFixture = new FrameFixture(robot, frame);
View Full Code Here


        final JSlider slider = new JSlider(min, max, value);
        slider.addChangeListener(new ChangeListener()
        {
            public void stateChanged(ChangeEvent changeEvent)
            {
                Probability probability = new Probability((double) slider.getValue() / range);
                numberGenerator.setValue(probability);
                valueLabel.setText(format.format(probability));
            }
        });
        slider.setMajorTickSpacing(10);
View Full Code Here


    public static BitString evolveBits(int length)
    {
        List<EvolutionaryOperator<BitString>> operators = new ArrayList<EvolutionaryOperator<BitString>>(2);
        operators.add(new BitStringCrossover(1, new Probability(0.7d)));
        operators.add(new BitStringMutation(new Probability(0.01d)));
        EvolutionaryOperator<BitString> pipeline = new EvolutionPipeline<BitString>(operators);
        GenerationalEvolutionEngine<BitString> engine = new GenerationalEvolutionEngine<BitString>(new BitStringFactory(length),
                                                                                                   pipeline,
                                                                                                   new BitStringEvaluator(),
                                                                                                   new RouletteWheelSelection(),
View Full Code Here

        });
        innerPanel.add(new JLabel("Selection Pressure: "));
        ProbabilityParameterControl selectionPressure = new ProbabilityParameterControl(Probability.EVENS,
                                                                                        Probability.ONE,
                                                                                        2,
                                                                                        new Probability(0.85d));

        selectionStrategy = new TournamentSelection(selectionPressure.getNumberGenerator());
        innerPanel.add(selectionPressure.getControl());
        innerPanel.add(new JLabel("Population Size: "));
        populationSizeSpinner = new JSpinner(new SpinnerNumberModel(500, 10, 50000, 1));
View Full Code Here

        parameters.add(new JLabel("Selection Pressure: "));
        parameters.add(Box.createHorizontalStrut(10));
        selectionPressureControl = new ProbabilityParameterControl(Probability.EVENS,
                                                                   Probability.ONE,
                                                                   2,
                                                                   new Probability(0.7));
        parameters.add(selectionPressureControl.getControl());
        parameters.add(Box.createHorizontalStrut(10));

        startButton = new JButton("Start");
        abort = new AbortControl();       
View Full Code Here

    {
        super(new SpringLayout());
        addPolygonControl = new ProbabilityParameterControl(Probability.ZERO,
                                                            ONE_TENTH,
                                                            3,
                                                            new Probability(0.02));
        add(new JLabel("Add Polygon: "));
        add(addPolygonControl.getControl());
        addPolygonControl.setDescription("For each IMAGE, the probability that a new "
                                         + "randomly-generated polygon will be added.");

        addVertexControl = new ProbabilityParameterControl(Probability.ZERO,
                                                           ONE_TENTH,
                                                           3,
                                                           new Probability(0.01));
        add(new JLabel("Add Vertex: "));
        add(addVertexControl.getControl());
        addVertexControl.setDescription("For each POLYGON, the probability that a new "
                                        + "randomly-generated vertex will be added.");

        removePolygonControl = new ProbabilityParameterControl(Probability.ZERO,
                                                               ONE_TENTH,
                                                               3,
                                                               new Probability(0.02));
        add(new JLabel("Remove Polygon: "));
        add(removePolygonControl.getControl());
        removePolygonControl.setDescription("For each IMAGE, the probability that a "
                                            + "randomly-selected polygon will be discarded.");

        removeVertexControl = new ProbabilityParameterControl(Probability.ZERO,
                                                              ONE_TENTH,
                                                              3,
                                                              new Probability(0.01));
        add(new JLabel("Remove Vertex: "));
        add(removeVertexControl.getControl());
        removeVertexControl.setDescription("For each POLYGON, the probability that a "
                                           + "randomly-selected vertex will be discarded.");

        movePolygonControl = new ProbabilityParameterControl(Probability.ZERO,
                                                             ONE_TENTH,
                                                             3,
                                                             new Probability(0.01));
        add(new JLabel("Reorder Polygons: "));
        add(movePolygonControl.getControl());
        movePolygonControl.setDescription("For each IMAGE, the probability that the z-positions "
                                          + "of two randomly-selected polygons will be swapped.");

        moveVertexControl = new ProbabilityParameterControl(Probability.ZERO,
                                                            ONE_TENTH,
                                                            3,
                                                            new Probability(0.03));
        add(new JLabel("Move Vertex: "));
        add(moveVertexControl.getControl());
        moveVertexControl.setDescription("For each POLYGON, the probability that a randomly-selected "
                                         + "vertex will be displaced.");

        crossOverControl = new ProbabilityParameterControl(Probability.ZERO,
                                                           Probability.ONE,
                                                           2,
                                                           Probability.ONE);
        add(new JLabel("Cross-over: "));
        add(crossOverControl.getControl());
        crossOverControl.setDescription("For each PAIR of parent IMAGES, the probability that "
                                        + "2-point cross-over is applied.");

        changeColourControl = new ProbabilityParameterControl(Probability.ZERO,
                                                              ONE_TENTH,
                                                              3,
                                                              new Probability(0.01));
        add(new JLabel("Change Colour: "));
        add(changeColourControl.getControl());
        changeColourControl.setDescription("For each POLYGON, the probability that its colour will be mutated.");

        // Set component names for easy look-up from tests.
View Full Code Here

        innerPanel.add(generationsLabel);
        innerPanel.add(generationsSpinner);

        selectionLabel = new JLabel("Selection Strategy: ");
        List<SelectionStrategy<? super List<String>>> strategies
            = SelectionStrategyControl.createDefaultOptions(new Probability(0.95d), 0.5d);
        this.selectionControl = new SelectionStrategyControl<List<String>>(strategies);
        innerPanel.add(selectionLabel);
        selectionControl.getControl().setSelectedIndex(selectionControl.getControl().getItemCount() - 1);
        innerPanel.add(selectionControl.getControl());
View Full Code Here

    public static String evolveString(String target)
    {
        StringFactory factory = new StringFactory(ALPHABET, target.length());
        List<EvolutionaryOperator<String>> operators = new ArrayList<EvolutionaryOperator<String>>(2);
        operators.add(new StringMutation(ALPHABET, new Probability(0.02d)));
        operators.add(new StringCrossover());
        EvolutionaryOperator<String> pipeline = new EvolutionPipeline<String>(operators);
        EvolutionEngine<String> engine = new GenerationalEvolutionEngine<String>(factory,
                                                                                 pipeline,
                                                                                 new StringEvaluator(target),
View Full Code Here

    public void testMaxDepth()
    {
        final int maxDepth = 3;
        CandidateFactory<Node> factory = new TreeFactory(2,
                                                         maxDepth,
                                                         new Probability(0.6),
                                                         Probability.EVENS);
        List<Node> trees = factory.generateInitialPopulation(20, ExamplesTestUtils.getRNG());
        for (Node tree : trees)
        {
            // Make sure that each tree is no bigger than the maximum permitted.
View Full Code Here

     * If the mutation doesn't happen, the candidates should be returned unaltered.
     */
    @Test
    public void testSomeMutations()
    {
        TreeFactory treeFactory = new TreeFactory(1, 4, new Probability(0.6d), new Probability(0.2d));
        EvolutionaryOperator<Node> mutation = new TreeMutation(treeFactory,
                                                               Probability.ONE); // Probability of 1 means guaranteed mutations.
        List<Node> candidates = treeFactory.generateInitialPopulation(20, ExamplesTestUtils.getRNG());

        Map<Node, Node> distinctTrees = new IdentityHashMap<Node, Node>();
View Full Code Here

TOP

Related Classes of org.uncommons.maths.random.Probability

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.