Package fmg.fmg8.endlAutomat

Examples of fmg.fmg8.endlAutomat.EndlicherAutomat


    public static void main(final String[] args) {
        String[] p = {"log", "-1"};
        Parametersatz pars = new Parametersatz(p);
        ScriptInterpreter interp
            = new ScriptInterpreter(pars, ScriptInterpreter.MODUS_VERHALTEN);
        EndlicherAutomat a = new EndlicherAutomat(null, interp);
        String str = "";
       
//        for (int j = 0; j < 1000; j++) {
//            str = str + (j % Const.BEF_PAR.length) + "," + j * (13 + j);
//           
//            if (Const.BEF_PAR[j % Const.BEF_PAR.length] == 2) {
//                str = str + "," + (j + 1);
//            }
//           
//            str = str + ";";
//        }
//       
        str = "5, 422; 5, 4; 5, 232; 5, 239; 5, 293; 5, 1; 5, 262; ";
        str += "5, 8; 4, 1, 2; 6, 1, 3; 5, 423; 4, 3, 4;";
        str += "6, 3, 2; 6, 2, 3; 1, 2, 3;";
       
        SonstMeth.log(SonstMeth.LOG_STAGE1, "Raw script: " + str, pars);
       
        Script s = new Script(str);
        interp.generateAutomaton(a, s);
       
        (new Zwischenablage()).copyToClipboard(a.erzeugeStringSeq());
    }
View Full Code Here


                this.fitVs[i] = OpsFactory.getKonstFit(
                        this.pars.getFitnessVerfahren()[i]);
            } else {
                this.fitVs[i] = this.fitVs[i - 1];
            }
            this.vAut[i] = new EndlicherAutomat(this.earlErk, this.scriptInt);
            if (this.pars.getGraphisch().booleanValue()
                    && this.observer != null) {
                this.vAut[i].addObserver(this.observer);
            }
            this.verhCodes[i] = this.getVAut()[i].erzeugeSequenz();
View Full Code Here

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

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

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

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

    @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

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

       
        Translator trans = new Translator(
                transCode,
                new ScriptInterpreter(params, SonstMeth.MODUS_TRANSLATOR),
                params);
        Script s = trans.translate(new EndlicherAutomat().bereinige(seqCode));
        ScriptInterpreter sInt = new ScriptInterpreter(params, SonstMeth.MODUS_TRANSLATOR);
        EndlicherAutomat ea = new EndlicherAutomat();
        sInt.generateAutomaton(ea, s);
//        System.out.println(ea.erzeugeSequenz().size());
        System.exit(0);

        LinkedList<Integer> seq = ea.erzeugeSequenz();
        System.out.println();
        int zwisch = 0;
        LinkedList<String> array = new LinkedList<String>();
        String seqInt = "";
       
View Full Code Here

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

    public static void main(final String[] args) {
        String[] p = {"log", "-1"};
        Parametersatz pars = new Parametersatz(p);
        ScriptInterpreter interp
            = new ScriptInterpreter(pars, ScriptInterpreter.MODUS_VERHALTEN);
        EndlicherAutomat a = new EndlicherAutomat(null, interp);
        String str = "";
       
        for (int j = 0; j < 1000; j++) {
            str = str + (j % Const.BEF_PAR.length) + "," + j * (13 + j);
           
            if (Const.BEF_PAR[j % Const.BEF_PAR.length] == 2) {
                str = str + "," + (j + 1);
            }
           
            str = str + ";";
        }
       
        SonstMeth.log(SonstMeth.LOG_STAGE1, "Raw script: " + str, pars);
       
        Script s = new Script(str);
        interp.generateAutomaton(a, s);
       
        System.out.println(a.erzeugeStringSeq());
    }
View Full Code Here

           
            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

TOP

Related Classes of fmg.fmg8.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.