Examples of Population


Examples of aufnahme.fmg.edu.kit.aifb.AufnahmeTyp.Population

            this.xmlAufn.getAufnahme().addNewAusgaben();
        }
        Kommandozeilenausgaben ausg
            = this.xmlAufn.getAufnahme().getAusgaben();
        byte[] xmlFeld;
        Population aktPop;
        Calendar zeit;
        String sens;
       
        // Parameterliste:
        this.xmlAufn.getAufnahme().setParameterliste(
                this.pars.parStrPlain());

        // Zeitstempel:
        zeit = Calendar.getInstance();
        zeit.setTime(this.datum);
        this.xmlAufn.getAufnahme().setTimestamp(zeit);
       
        // Kommandozeilenausgaben (danach flushen):
        for (AbstractMsg m : this.pars.getMsgs(
                null,
                Long.MIN_VALUE,
                Long.MAX_VALUE)) {
            ausg.addNewEinzelzeile();
            ausg.getEinzelzeileArray(ausg.getEinzelzeileArray().length - 1)
                .setLogStufe(m.getType());
            ausg.getEinzelzeileArray(ausg.getEinzelzeileArray().length - 1)
                .setText(m.getMessage());
            ausg.getEinzelzeileArray(ausg.getEinzelzeileArray().length - 1)
                .setWeiteres("" + m.getZusatz());
           
            zeit = Calendar.getInstance();
            zeit.setTimeInMillis(m.getDatum());
           
            ausg.getEinzelzeileArray(ausg.getEinzelzeileArray().length - 1)
                .setZeitstempel(zeit);
        }
        this.pars.flushMsgs();

        // Feld:
        if (this.xmlAufn.getAufnahme().getUmgebung() == null) {
            this.xmlAufn.getAufnahme().addNewUmgebung();
            int x = this.umgebung.getFeld().length;
            int y = this.umgebung.getFeld()[0].length;
            this.xmlAufn.getAufnahme().getUmgebung().addNewGroesse();
            this.xmlAufn.getAufnahme().getUmgebung().getGroesse().setX(x);
            this.xmlAufn.getAufnahme().getUmgebung().getGroesse().setY(y);
            byte[][] inpFeld = this.umgebung.getInputFeld();
           
            xmlFeld = new byte[x * y];
            for (int i = 0; i < x; i++) {
                for (int j = 0; j < y; j++) {
                    xmlFeld[i * y + j] = inpFeld[i][j];
                }
            }
           
            try {
                this.xmlAufn.getAufnahme().getUmgebung().setFeld(
                        StaticMethods.compressByteStream(xmlFeld, this.pars));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
       
        // Populationen (danach flushen):
        for (PopSnapshot p : this.populationen) {
            int popID;
            this.xmlAufn.getAufnahme().addNewPopulation();
            aktPop = this.xmlAufn.getAufnahme().getPopulationArray(
                    this.xmlAufn.getAufnahme().getPopulationArray().length - 1);
            aktPop.setCycle(p.getId());
            popID = this.xmlAufn.getAufnahme().getPopulationArray().length - 1;
            aktPop.setID(popID);
           
            // Verschiebung der Gegenst�nde:
            if (aktPop.getGegVersch() == null) {
                aktPop.addNewGegVersch();
            }
            for (int i = 0; i < p.getVerschiebungen().length; i++) {
                Vector2D aktVersch = p.getVerschiebungen()[i];
                aktPop.getGegVersch().addNewVerschiebung();
                aktPop.getGegVersch().getVerschiebungArray()[i]
                     .setX(aktVersch.x);
                aktPop.getGegVersch().getVerschiebungArray()[i]
                     .setY(aktVersch.y);
                aktPop.getGegVersch().getVerschiebungArray()[i].setID(i);
            }
           
            // Dynamische Wände:
            if (aktPop.getDynWaende() == null) {
                DynWaendeTyp waende;
                DynWandTyp wand;
                waende = aktPop.addNewDynWaende();
                for (int i = 0; i < p.getTatdynDrehMittPkt().length; i++) {
                    if (p.getTatdynDrehMittPkt()[i] != null) {
                        wand = waende.addNewWand();
                        wand.setID(i);
                        wand.addNewDynDrehMittelpunkt();
                        wand.getDynDrehMittelpunkt().setX(
                                p.getTatdynDrehMittPkt()[i].x);
                        wand.getDynDrehMittelpunkt().setY(
                                p.getTatdynDrehMittPkt()[i].y);
                        wand.addNewDynSkalierung();
                        wand.getDynSkalierung().setX(
                                p.getTatdynSkalFaktor()[i].x);
                        wand.getDynSkalierung().setY(
                                p.getTatdynSkalFaktor()[i].y);
                        wand.addNewDynVersch();
                        wand.getDynVersch().setX(p.getTatdynVersch()[i].x);
                        wand.getDynVersch().setY(p.getTatdynVersch()[i].y);
                        wand.setDynDrehWinkel(p.getTatdynDrehWinkel()[i]);
                    }
                }
            }
           
            // Roboter:
            for (RobSnapshot r : p.getRobSchnapp()) {
                Roboter neuRob;
                aktPop.addNewRoboter();
                neuRob = aktPop
                        .getRoboterArray(aktPop.getRoboterArray().length - 1);
                // ID:
                neuRob.setID(r.getId());
                neuRob = aktPop
                        .getRoboterArray(aktPop.getRoboterArray().length - 1);
                // Position:
                neuRob.addNewPos();
                neuRob.getPos().setWinkel(r.getWinkel());
                neuRob.getPos().setX(r.getPosition().x);
                neuRob.getPos().setY(r.getPosition().y);
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

        System.out.println("Mutate Perturb");

        GenerateRandom rnd = new MersenneTwisterGenerateRandom();

        // Create a new population.
        Population pop = new BasicPopulation();
        pop.setGenomeFactory(new DoubleArrayGenomeFactory(5));

        // Create a trainer with a very simple score function.  We do not care
        // about the calculation of the score, as they will never be calculated.
        EvolutionaryAlgorithm train = new BasicEA(pop, new ScoreFunction() {
            @Override
            public double calculateScore(MLMethod method) {
                return 0;
            }

            @Override
            public boolean shouldMinimize() {
                return false;
            }
        });


        MutatePerturb opp = new MutatePerturb(0.1);
        train.addOperation(1.0, opp);


        // Create a peterb operator.  Use it 1.0 (100%) of the time.
        DoubleArrayGenome[] parents = new DoubleArrayGenome[1];
        parents[0] = (DoubleArrayGenome) pop.getGenomeFactory().factor();
        parents[0].setPopulation(pop);

        for (int i = 1; i <= 5; i++) {
            parents[0].getData()[i - 1] = i;
        }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

     * Create an initial random population of random paths through the cities.
     *
     * @return The random population.
     */
    private Population initPopulation() {
        Population result = new BasicPopulation(POPULATION_SIZE, null);

        BasicSpecies defaultSpecies = new BasicSpecies();
        defaultSpecies.setPopulation(result);
        for (int i = 0; i < POPULATION_SIZE; i++) {
            final IntegerArrayGenome genome = randomGenome();
            defaultSpecies.add(genome);
        }
        result.setGenomeFactory(new IntegerArrayGenomeFactory(cities.length));
        result.getSpecies().add(defaultSpecies);

        return result;
    }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

    public void solve() {
        StringBuilder builder = new StringBuilder();

        initCities();

        Population pop = initPopulation();

        ScoreFunction score = new TSPScore(cities);

        genetic = new BasicEA(pop, score);
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

        // Create a RBF network to get the length.
        final RBFNetwork network = new RBFNetwork(codec.getInputCount(), codec.getRbfCount(), codec.getOutputCount());
        int size = network.getLongTermMemory().length;

        // Create a new population, use a single species.
        Population result = new BasicPopulation(POPULATION_SIZE, new DoubleArrayGenomeFactory(size));
        BasicSpecies defaultSpecies = new BasicSpecies();
        defaultSpecies.setPopulation(result);
        result.getSpecies().add(defaultSpecies);

        // Create a new population of random networks.
        for (int i = 0; i < POPULATION_SIZE; i++) {
            final DoubleArrayGenome genome = new DoubleArrayGenome(size);
            network.reset(rnd);
            System.arraycopy(network.getLongTermMemory(), 0, genome.getData(), 0, size);
            defaultSpecies.add(genome);
        }

        // Set the genome factory to use the double array genome.
        result.setGenomeFactory(new DoubleArrayGenomeFactory(size));

        return result;

    }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

            final RBFNetworkGenomeCODEC codec = new RBFNetworkGenomeCODEC(4, 4, 3);

            final List<BasicData> trainingData = ds.extractSupervised(0,
                    codec.getInputCount(), codec.getRbfCount(), codec.getOutputCount());

            Population pop = initPopulation(rnd, codec);

            ScoreFunction score = new ScoreRegressionData(trainingData);

            BasicEA genetic = new BasicEA(pop, score);
            genetic.setSpeciation(new ArraySpeciation<DoubleArrayGenome>());
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

        // Create a RBF network to get the length.
        final RBFNetwork network = new RBFNetwork(codec.getInputCount(), codec.getRbfCount(), codec.getOutputCount());
        int size = network.getLongTermMemory().length;

        // Create a new population, use a single species.
        Population result = new BasicPopulation(POPULATION_SIZE, new DoubleArrayGenomeFactory(size));
        BasicSpecies defaultSpecies = new BasicSpecies();
        defaultSpecies.setPopulation(result);
        result.getSpecies().add(defaultSpecies);

        // Create a new population of random networks.
        for (int i = 0; i < POPULATION_SIZE; i++) {
            final DoubleArrayGenome genome = new DoubleArrayGenome(size);
            network.reset(rnd);
            System.arraycopy(network.getLongTermMemory(), 0, genome.getData(), 0, size);
            defaultSpecies.add(genome);
        }

        // Set the genome factory to use the double array genome.
        result.setGenomeFactory(new DoubleArrayGenomeFactory(size));

        return result;

    }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

            final RBFNetworkGenomeCODEC codec = new RBFNetworkGenomeCODEC(4, RBF_COUNT, 3);

            final List<BasicData> trainingData = ds.extractSupervised(0,
                    codec.getInputCount(), 4, codec.getOutputCount());

            Population pop = initPopulation(rnd, codec);

            ScoreFunction score = new ScoreRegressionData(trainingData);

            BasicEA genetic = new BasicEA(pop, score);
            genetic.setCODEC(codec);
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

     * @param rnd  A random number generator.
     * @param eval The expression evaluator.
     * @return The new population.
     */
    private Population initPopulation(GenerateRandom rnd, EvaluateExpression eval) {
        Population result = new BasicPopulation(POPULATION_SIZE, null);

        BasicSpecies defaultSpecies = new BasicSpecies();
        defaultSpecies.setPopulation(result);
        for (int i = 0; i < POPULATION_SIZE; i++) {
            final TreeGenome genome = randomGenome(rnd, eval);
            defaultSpecies.add(genome);
        }
        result.setGenomeFactory(new TreeGenomeFactory(eval));
        result.getSpecies().add(defaultSpecies);

        return result;
    }
View Full Code Here

Examples of com.heatonresearch.aifh.evolutionary.population.Population

        List<BasicData> training = ds.extractSupervised(0, 1, 1, 1);


        GenerateRandom rnd = new MersenneTwisterGenerateRandom();
        EvaluateExpression eval = new EvaluateExpression(rnd);
        Population pop = initPopulation(rnd, eval);
        ScoreFunction score = new ScoreSmallExpression(training,30);

        EvolutionaryAlgorithm genetic = new BasicEA(pop, score);
        genetic.addOperation(0.3, new MutateTree(3));
        genetic.addOperation(0.7, new CrossoverTree());
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.