Examples of EndlicherAutomat


Examples of fmg.fmg8.endlAutomat.EndlicherAutomat

     */
    public static void main(final String[] args) {
        Parametersatz params = new Parametersatz(args);
        Translator transNeu = Konstanten.STD_TRANSL_BE;

        EndlicherAutomat autNeu = new EndlicherAutomat();
       
        String t1Std
            = "001, 003, 004, 001, 000, 012, 001, 010, "
            + "000, 005, 000, 012, 003, 000, 012, 007, "
            + "000, 005, 000, 010, 000, 000, 002, 001, "
            + "000, 012, 001, 010, 000, 005, 000, 012, "
            + "003, 000, 012, 007, 000, 006, 000, 010, "
            + "000, 000, 003, 001, 000, 000, 000, 003, "
            + "005, 050, 001, 000, 000, 000, 002, 004, "
            + "050, 001, 000, 000, 000, 000, 000, 007, "
            + "000, 000, 000, 000, 000";
       
        String t1 = autNeu.bereinige(t1Std);
        String t2 = "";
       
        new ScriptInterpreter(
                params, SonstMeth.MODUS_VERHALTEN).generateAutomaton(
                        autNeu, transNeu.translate(t1));
        t2 = autNeu.erzeugeStringSeq();
       
        SonstMeth.unterscheide(t1Std, t2, params);
    }
View Full Code Here

Examples of fmg.fmg8.endlAutomat.EndlicherAutomat

     *
     * @return  Die mutierte Bedingung.
     */
    @Override
    public Condition mutiere(final Condition cond) {
        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) MathMeth.randVerteilung(intObj,
                                                  vert,
                                                  super.getRand());
       
        switch(rnd.intValue()) {
        case 0:
            this.mutationBedA(aut);
            break;
        case 1:
            this.mutationBedBeinfacher(aut);
            break;
        case 2:
            this.mutationBedZahl(aut);
            break;
        case 3:
            this.mutationBedkomplexer(aut);
            break;
        case 4:
            this.mutationBedSensVar(aut);
            break;
        default:
            break;
        }

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

Examples of fmg.fmg8.endlAutomat.EndlicherAutomat

     *
     * @return  Die neue Roboterliste, die nur den Eintrag 0 enth�lt.
     */
    public RobCode[] rekombEinz(final Roboter[] rob) {
        RobCode[] robC = new RobCode[1];
        EndlicherAutomat kind = new EndlicherAutomat();
        int id = rob[0].getId();
        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;
        Roboter 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 = (Roboter) MathMeth.randVerteilung(rob, vert, this.rand);
        zustaende = aktRob.vAuts()[0].getKnList();
        fitness = aktRob.getFitness()[0];
       
        vorhandenAll = true;
       
        it = zustaende.iterator();
        while (it.hasNext()) {
            aktName = (Integer) 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) MathMeth.randVerteilung(knotenListe,
                                                           vert,
                                                           this.rand);
            } else {
                zKnoten = aktRob.vAuts()[0].holeKnoten(aktName);
            }
           
            aktion = ((ZInfo) zKnoten.getInfo()).getAktion();
            param = ((ZInfo) zKnoten.getInfo()).getParam();
            alt = ((ZInfo) zKnoten.getInfo()).getAlter();
            istStart = ((ZInfo) zKnoten.getInfo()).istStartZ();
           
            kind.einfuegenKnoten(aktName, aktion, param, alt);
            if (istStart) {
                kind.setStart(kind.holeKnoten(aktName));
            }
        }
       
        it1 = zustaende.iterator();
        while (it1.hasNext()) {
            kn1 = (Integer) it1.next();
            it2 = zustaende.iterator();
            while (it2.hasNext()) {
                kn2 = (Integer) 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) MathMeth.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

Examples of fmg.fmg8.endlAutomat.EndlicherAutomat

           
            aktRob = (Roboter) MathMeth.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

Examples of fmg.fmg8.endlAutomat.EndlicherAutomat

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

Examples of fmg.fmg8.endlAutomat.EndlicherAutomat

    @SuppressWarnings("unchecked")
    public static EndlicherAutomat gesamtAutomat(
            final EndlicherAutomat[] endAuts,
            final Condition[]        conds) {
        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[] eas = new EndlicherAutomat[endAuts.length];
        LinkedList<Transition> trans;
        Transition tran;
        String[] args = {"log 4"};
       
        if (endAuts == null
                || conds == null
                || endAuts.length != conds.length
                || endAuts.length == 0) {
            SonstMeth.log(SonstMeth.LOG_ERROR,
                          "Gesamtautomat konnte nicht erzeugt werden.",
                          new Parametersatz(args));
        }
       
        for (int i = 0; i < eas.length; i++) {
            eas[i] = new EndlicherAutomat();
            eas[i].erzeugeAusSequenz(
                    endAuts[i].erzeugeStringSeq(),
                    fmg.fmg8.endlAutomat.translator.Konstanten.STD_TRANSL_BE,
                    false);
           
            if (eas[i].istLeer()) {
                eas[i].einfuegenKnoten(Integer.MAX_VALUE,
                        SonstMeth.posSuch(
                                fmg.fmg8.umgebung2D.Konstanten.BEF,
                                "stp"),
                        1,
                        1);
               
                eas[i].setStart(eas[i].holeKnoten(Integer.MAX_VALUE));
            }
        }
       
        // Neue Knoten zuordnen.
        for (int i = 0; i < eas.length; i++) {
            knotZuord[i] = new HashMap<Integer, Integer>();
           
            knot = new ArrayList<Integer>(eas[i].holAdj().keySet());
            it = knot.iterator();

            while (it.hasNext()) {
                aktKnNum = it.next();
                aktKn = eas[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 < eas.length; i++) {
            zielKn = eas[i].holeStartzustand();
           
            if (zielKn != null) {
                zielKnNum = (Integer) knotZuord[i].get(zielKn.holeName());
                neuBed = SonstMeth.ausFormatBed(conds[i].formatted());
                for (int j = 0; j < i; j++) {
                    zwischBed = SonstMeth.ausFormatBed(conds[j].formatted());
                    zwischBed.negiere();
                    neuBed = new InnerNode(neuBed,
                                           zwischBed,
                                           fmg.fmg8.endlAutomat.Konstanten.UND);
                }
               
                for (int j = 0; j < eas.length; j++) {
                    if (j != i) {
                        knot = new ArrayList<Integer>(
                                eas[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 < eas.length; i++) {
            knot1 = new ArrayList<Integer>(eas[i].holAdj().keySet());
            it1 = knot1.iterator();
           
            while (it1.hasNext()) {
                numOrig1 = it1.next();
                aktKnNum = (Integer) knotZuord[i].get(numOrig1);
                aktKn = eas[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 < eas.length; i++) {
            zielKn = eas[i].holeStartzustand();
           
            if (zielKn != null) {
                zielKnNum = (Integer) knotZuord[i].get(zielKn.holeName());
               
                knot = new ArrayList<Integer>(eas[i].holAdj().keySet());
                it = knot.iterator();
               
                while (it.hasNext()) {
                    aktKnNum = (Integer) knotZuord[i].get(it.next());
                    neu.einfuegKante(aktKnNum,
                                     zielKnNum,
                                     SonstMeth.ausBed("t"),
                                     1);
                }
            }
        }

        // Einen IDLE-Startknoten einf�gen.
        idlBefehl = SonstMeth.posSuch(fmg.fmg8.umgebung2D.Konstanten.BEF,
                                      "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 = SonstMeth.ausFormatBed(conds[i].formatted());
                for (int j = 1; j < conds.length; j++) {
                    zwischBed = SonstMeth.ausFormatBed(conds[j].formatted());
                    zwischBed.negiere();
                    neuBed = new InnerNode(
                            neuBed,
                            zwischBed,
                            fmg.fmg8.endlAutomat.Konstanten.ODER);
                }
            }

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

            if (eas[i].holeStartzustand() != null) {
                neu.einfuegKante(lfdNr,
                       (Integer)
                       knotZuord[i].get(eas[i].holeStartzustand().holeName()),
                       neuBed,
                       1);
            }
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.