Package eas.simulation.spatial.sim2D.marbSimulation.endlAutomat

Examples of eas.simulation.spatial.sim2D.marbSimulation.endlAutomat.EndlicherAutomat


                        .getParValueArrayListString(EAPlugin.FIT_VERFAHREN_AT)
                        .get(0));
            } else {
                this.fitVs[i] = this.fitVs[i - 1];
            }
            this.vAut[i] = new EndlicherAutomat(this.earlErk, this.scriptInt);
            this.verhCodes[i] = this.getVAut()[i].generateSequence();
        }
    }
View Full Code Here


                this.vAut[i].generateFromSequence(
                        seq[i],
                        trans2[i],
                        pruefen, this.getPars());

                bereinigt = (new EndlicherAutomat()).bereinige(seq[i]);
                this.verhCodes[i] = StaticMethods.listSeqAusString(bereinigt);

                if (cond != null && i < cond.length && cond[i] != null) {
                    this.conds[i] = cond[i];
                }
View Full Code Here

                        ScriptInterpreter.MODUS_VERHALTEN),
                this.getPars());
       
        this.translatoren[transNum].generateFromSequence(seq, trans, pruefen, this.getPars());
       
        bereinigt = (new EndlicherAutomat()).bereinige(seq);
        this.transCodes[transNum] = StaticMethods.listSeqAusString(bereinigt);
       
//        if (trans != null) {
//            trans.setModus(altMod);
//        }
View Full Code Here

     * Increases the age of all reacheable states and transitions
     */
    public void aging() {
        List<Integer> vCode = getVerhCodes()[this.getAktAutNum()];
        String seq = StaticMethods.stringAusListSeq(vCode);
        EndlicherAutomat ea = new EndlicherAutomat();
        ea.generateFromSequence(seq, getTranslatoren()[this.getAktAutNum()], false, this.getPars());
        double prob =  this.getPars().getParValueDouble("reachProb");
        for (Integer nodeId: ea.getAdjazenzliste().keySet()) {
            Knoten node = ea.getAdjazenzliste().get(nodeId);
            if (ea.erreichbarVonStart(node.holeName(), prob)) {
                if (!node.getInfo().istStartZ()) {
                    node.getInfo().setAlter(node.getInfo().getAlter() + 1);
                }
                for (Transition t: node.getInfo().getBeds()) {
                    if (StaticMethods.condStrength(
                            t.getCond(),
                            eas.startSetup.marbBuilder.darstellungsModi.ConstantsDarstellung.STAERKE_ERST,
                            eas.startSetup.marbBuilder.darstellungsModi.ConstantsDarstellung.STAERKE_ZWEIT)
                            >= prob) {
                        t.setAlter(t.getAlter() + 1);
                    }
                }
            }
        }
        getVerhCodes()[this.getAktAutNum()] = ea.generateSequence();
    }
View Full Code Here

     * @return  Die neue Roboterliste, die nur den Eintrag 0 enthält.
     */
    @Override
    public RobCode[] rekombEinz(final RobEA[] rob) {
        RobCode[] robC = new RobCode[1];
        EndlicherAutomat kind = new EndlicherAutomat();
        int id = rob[0].id();
        long fitness;
        ArrayList<Long> vert = new ArrayList<Long>(rob.length);
        ArrayList<Integer> zustaende;
        boolean vorhandenAll;
        Iterator<Integer> it, it1, it2;
        Integer aktName;
        Knoten[] knotenListe = new Knoten[rob.length];
        Knoten zwischKnoten;
        Integer kn1, kn2;
        Knoten zKnoten;
        Condition zCond;
        int aktion;
        int param;      
        int alt;
        boolean istStart;
        RobEA aktRob;
        Condition[] condListe = new Condition[rob.length];
        int j = -1;
       
        /*
         * Ersetzt alle Vorkommnisse von <code>null</code> im Array rob durch
         * gültige im Array weiter vorne stehende Roboter. Dabei wird die
         * Liste der Roboter VOR dem ersten Vorkommnis von <code>null</code>
         * immer wieder über das Array gelegt und die null-Werte werden
         * überschrieben:
         *
         * [1 3 null null null null] => [1 3 1 3 1 3].
         *
         * Wenn nach dem ersten Vorkommnis von <code>null</code> ein gültiger
         * Roboter vorkommt (dies ist kein erwünschter Fall), dann wird er
         * im Array belassen.
         */
        for (int i = 0; i < rob.length; i++) {
            if (rob[i] == null) {
                if (j < 0) {
                    j = i;
                }
                rob[i] = rob[i % j];
            }
        }
       
        for (int i = 0; i < rob.length; i++) {
            if (rob[i].getFitness()[0] > 0) {
                vert.add(new Long(rob[i].getFitness()[0]));
            } else {
                vert.add(new Long(0));
            }
        }

        aktRob = (RobEA) MiscMath.randVerteilung(rob, vert, this.rand);
        zustaende = aktRob.vAuts()[0].getKnList();
        fitness = aktRob.getFitness()[0];
       
        vorhandenAll = true;
       
        it = zustaende.iterator();
        while (it.hasNext()) {
            aktName = it.next();
            for (int i = 0; i < rob.length; i++) {
                zwischKnoten = rob[i].vAuts()[0].holeKnoten(aktName);
                if (zwischKnoten != null) {
                    knotenListe[i] = zwischKnoten;
                } else {
                    vorhandenAll = false;
                    break;
                }
            }
           
            if (vorhandenAll) {
                zKnoten = (Knoten) MiscMath.randVerteilung(knotenListe,
                                                           vert,
                                                           this.rand);
            } else {
                zKnoten = aktRob.vAuts()[0].holeKnoten(aktName);
            }
           
            aktion = (zKnoten.getInfo()).getAktion();
            param = (zKnoten.getInfo()).getParam();
            alt = (zKnoten.getInfo()).getAlter();
            istStart = (zKnoten.getInfo()).istStartZ();
           
            kind.einfuegenKnoten(aktName, aktion, param, alt);
            if (istStart) {
                kind.setStart(kind.holeKnoten(aktName));
            }
        }
       
        it1 = zustaende.iterator();
        while (it1.hasNext()) {
            kn1 = it1.next();
            it2 = zustaende.iterator();
            while (it2.hasNext()) {
                kn2 = it2.next();
               
                vorhandenAll = true;
                if (aktRob.vAuts()[0].kanteExistiert(kn1, kn2)) {
                    for (int i = 0; i < rob.length; i++) {
                        if (rob[i].vAuts()[0].kanteExistiert(kn1, kn2)) {
                            condListe[i] = rob[i].vAuts()[0].getCondZuTrans(kn1,
                                                                           kn2);
                        } else {
                            vorhandenAll = false;
                            break;
                        }
                    }
                   
                    if (vorhandenAll) {
                        zCond = (Condition) MiscMath.randVerteilung(condListe,
                                                                    vert,
                                                                    this.rand);
                    } else {
                        zCond = aktRob.vAuts()[0].getCondZuTrans(kn1, kn2);
                    }
                   
                    kind.einfuegKante(kn1, kn2, zCond, 1);
                }
            }
        }

        /*
         * TODO: Alter der Knoten UND Kanten.
         */
       
        int[] fits = new int[1];
        String[] codes = new String[1];
        fits[0] = (int) fitness;
        codes[0] = kind.erzeugeStringSeq();
       
        robC[0] = new RobCode(
                id,
                fits,
                codes,
View Full Code Here

     * @param seq  Liste von Zahlen.
     *
     * @return  Die bereinigte Stringsequenz.
     */
    public static String stringAusListSeq(final List<Integer> seq) {
        EndlicherAutomat ea = new EndlicherAutomat();
       
        return ea.bereinige(ea.ausgabe(seq));
    }
View Full Code Here

    public static EndlicherAutomat gesamtAutomat(
            final EndlicherAutomat[] endAuts,
            final Condition[]        conds,
            final ParCollection params) {
        HashMap[] knotZuord = new HashMap[endAuts.length];
        EndlicherAutomat neu = new EndlicherAutomat();
        int lfdNr = 1;
        ArrayList<Integer> knot;
        ArrayList<Integer> knot1;
        Iterator<Integer> it, it1;
        Iterator<Transition> it3;
        Integer aktKnNum;
        Knoten aktKn;
        ZInfo info;
        Knoten zielKn;
        Integer zielKnNum;
        Condition aktBed;
        Condition neuBed = null;
        Condition zwischBed;
        int numOrig1, numOrig2;
        int idlBefehl;
        EndlicherAutomat[] endAs = new EndlicherAutomat[endAuts.length];
        LinkedList<Transition> trans;
        Transition tran;
        String[] args = {"log 4"};
       
        if (conds == null
                || endAuts.length != conds.length
                || endAuts.length == 0) {
            ParCollection parColl = GlobalVariables.getPrematureParameters();
            parColl.overwriteParameterList(args);
            StaticMethods.log(StaticMethods.LOG_ERROR,
                          "Gesamtautomat konnte nicht erzeugt werden.",
                          parColl);
        }
       
        for (int i = 0; i < endAs.length; i++) {
            endAs[i] = new EndlicherAutomat();
           
            if (params.getParValueBoolean("UseTranslatorWITHCompletingTransitions")) {
                endAs[i].generateFromSequence(
                        endAuts[i].erzeugeStringSeq(),
                        eas.simulation.spatial.sim2D.marbSimulation.translator.ConstantsTranslator.getStdTranslatorBE(params),
                        false, params);
            } else {
                endAs[i].generateFromSequence(
                        endAuts[i].erzeugeStringSeq(),
                        ConstantsTranslatorWOC.getStdTranslatorBE(params),
                        false, params);
            }
           
            if (endAs[i].istLeer()) {
                endAs[i].einfuegenKnoten(Integer.MAX_VALUE,
                        StaticMethods.posSuch(
                                eas.simulation.ConstantsSimulation.getBefehlNamenArray(params),
                                "stp"),
                        1,
                        1);
               
                endAs[i].setStart(endAs[i].holeKnoten(Integer.MAX_VALUE));
            }
        }
       
        // Neue Knoten zuordnen.
        for (int i = 0; i < endAs.length; i++) {
            knotZuord[i] = new HashMap<Integer, Integer>();
           
            knot = new ArrayList<Integer>(endAs[i].holAdj().keySet());
            it = knot.iterator();

            while (it.hasNext()) {
                aktKnNum = it.next();
                aktKn = endAs[i].holeKnoten(aktKnNum);
                info = aktKn.getInfo();
                neu.einfuegenKnoten(lfdNr,
                                    info.getAktion(),
                                    info.getParam(),
                                    info.getAlter());
               
                knotZuord[i].put(aktKnNum, lfdNr);
                lfdNr++;
            }
        }
       
        // Neue Kanten INTER Automaten zuordnen.
        for (int i = 0; i < endAs.length; i++) {
            zielKn = endAs[i].holeStartzustand();
           
            if (zielKn != null) {
                zielKnNum = (Integer) knotZuord[i].get(zielKn.holeName());
                neuBed = StaticMethods.ausFormatBed(conds[i].formatted());
                for (int j = 0; j < i; j++) {
                    zwischBed = StaticMethods.ausFormatBed(conds[j].formatted());
                    zwischBed.negiere();
                    neuBed = new InnerNode(neuBed,
                                           zwischBed,
                                           eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND);
                }
               
                for (int j = 0; j < endAs.length; j++) {
                    if (j != i) {
                        knot = new ArrayList<Integer>(
                                endAs[j].holAdj().keySet());
                        it = knot.iterator();
                       
                        while (it.hasNext()) {
                            aktKnNum = (Integer) knotZuord[j].get(it.next());
                            neu.einfuegKante(aktKnNum, zielKnNum, neuBed, 1);
                        }
                    }
                }
            }
        }

        // Neue Kanten INTRA Automaten zuordnen.
        for (int i = 0; i < endAs.length; i++) {
            knot1 = new ArrayList<Integer>(endAs[i].holAdj().keySet());
            it1 = knot1.iterator();
           
            while (it1.hasNext()) {
                numOrig1 = it1.next();
                aktKnNum = (Integer) knotZuord[i].get(numOrig1);
                aktKn = endAs[i].holeKnoten(numOrig1);
               
                if (aktKn.getInfo() != null
                        && aktKn.getInfo().getBedingungen() != null) {
                    trans = aktKn.getInfo().getBedingungen();
                    it3 = trans.iterator();
                   
                    while (it3.hasNext()) {
                        tran = it3.next();
                        numOrig2 = tran.getFolgezustand();
                        zielKnNum = (Integer) knotZuord[i].get(numOrig2);
                        aktBed = tran.getCond();
                       
                        if (aktBed != null) {
                            neu.einfuegKante(aktKnNum, zielKnNum, aktBed, 1);
                        }
                    }
                }
            }
        }

        // true - Kanten zu den einzelnen Startknoten einfügen.
        for (int i = 0; i < endAs.length; i++) {
            zielKn = endAs[i].holeStartzustand();
           
            if (zielKn != null) {
                zielKnNum = (Integer) knotZuord[i].get(zielKn.holeName());
               
                knot = new ArrayList<Integer>(endAs[i].holAdj().keySet());
                it = knot.iterator();
               
                while (it.hasNext()) {
                    aktKnNum = (Integer) knotZuord[i].get(it.next());
                    neu.einfuegKante(aktKnNum,
                                     zielKnNum,
                                     StaticMethods.ausBed("t"),
                                     1);
                }
            }
        }

        // Einen IDLE-Startknoten einfügen.
        idlBefehl = StaticMethods.posSuch(eas.simulation.ConstantsSimulation.getBefehlNamenArray(params),
                                      "IDL");
        neu.einfuegenKnoten(lfdNr, idlBefehl, 1, 1);
        neu.setStart(neu.holeKnoten(lfdNr));
        for (int i = 0; i < conds.length; i++) {
            if (i > 0) {
                neuBed = conds[i];
            } else {
                neuBed = StaticMethods.ausFormatBed(conds[i].formatted());
                for (int j = 1; j < conds.length; j++) {
                    zwischBed = StaticMethods.ausFormatBed(conds[j].formatted());
                    zwischBed.negiere();
                    neuBed = new InnerNode(
                            neuBed,
                            zwischBed,
                            eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER);
                }
            }

            if (conds.length == 1) {
                neuBed = StaticMethods.ausBed("t");
            }

            if (endAs[i].holeStartzustand() != null) {
                neu.einfuegKante(lfdNr,
                       (Integer)
                       knotZuord[i].get(endAs[i].holeStartzustand().holeName()),
                       neuBed,
                       1);
            }
View Full Code Here

           
            aktRob = (RobEA) MiscMath.randVerteilung(rob, vert, this.rand);
            zustaende = aktRob.vAuts()[i].getKnList();
            fitness[i] = aktRob.getFitness()[i];

            kind[i] = new EndlicherAutomat();
            vorhandenAll = true;
           
            // Zustände einfügen.
            it = zustaende.iterator();
            while (it.hasNext()) {
View Full Code Here

                        LinkedList<Integer>[] listeVStd = new LinkedList[1];
                        listeV[0] = new LinkedList<Integer>(
                                r1.getVerhCodes()[0]);
                        listeVStd[0] = new LinkedList<Integer>(r1
                                .erzeugeSequenz(0));
                        r.erzeugeAusSequenz(0, new EndlicherAutomat()
                                .bereinige(StaticMethods
                                        .stringAusListSeq(listeVStd[0])), null,
                                false);
                        r.setVerhCodes(listeV);
                        r.setTransCode(0, StaticMethods
                                .listSeqAusString(new EndlicherAutomat()
                                        .bereinige(ConstantsTranslator.STD_TRANS_STR)));
                    }
                    umg.setzeRobotRand(r1);
                    r1.setVersetzt(true);
View Full Code Here

     */
    @Override
    public Condition mutiere(final Condition cond) {
        StaticMethods.log(StaticMethods.LOG_ERROR, "Bedingungsmutation verwendet.",
                this.pars);
        EndlicherAutomat aut = new EndlicherAutomat();
        Long[] intObj = new Long[5];
        ArrayList<Long> vert = new ArrayList<Long>(5);

        aut.einfuegenKnoten(1, 1, 1, 1);
        aut.einfuegKante(1, 1, cond, 1);


        for (int i = 0; i < intObj.length; i++) {
            intObj[i] = new Long(i);
        }

        vert.add(new Long(10)); // 0 : mutationBedA
        vert.add(new Long(9)); //  1 : mutationBedBeinfacher
        vert.add(new Long(3)); //  2 : mutationBedZahl
        vert.add(new Long(6)); //  3 : mutationBedkomplexer
        vert.add(new Long(1)); //  4 : mutationBedSensVar

        Long rnd = (Long) MiscMath.randVerteilung(
                intObj,
                vert,
                this.getRand());

        switch(rnd.intValue()) {
        case 0:
            this.ageSemMutBedA(aut);
            break;
        case 1:
            this.ageSynMutBedBeinfacher(aut);
            break;
        case 2:
            this.ageSemMutBedZahl(aut);
            break;
        case 3:
            this.ageSynMutBedkomplexer(aut);
            break;
        case 4:
            this.ageSemMutBedSensVar(aut);
            break;
        default:
            break;
        }

        return aut.holeKnoten(1).getInfo().getBedingungen().get(0).getCond();
    }
View Full Code Here

TOP

Related Classes of eas.simulation.spatial.sim2D.marbSimulation.endlAutomat.EndlicherAutomat

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.