Package fmg.fmg8.endlAutomat.conditions

Examples of fmg.fmg8.endlAutomat.conditions.Condition


            int koordX = this.links;
            int koordY = this.oben;
           
            int kX;
            int kY;
            Transition bed;
            int folgeZustand;
            String bedingung;
            int xAusgleich;
            int zaehler = 0;
           
            // Knoten
            it = knotenListe.iterator();
            while (it.hasNext()) {
                knot = it.next();

                if (this.gesetzteKn.containsKey(knot.holeName())) {
                    kX = (int) this.gesetzteKn.get(knot.holeName()).x;
                    kY = (int) this.gesetzteKn.get(knot.holeName()).y;
                    this.setzeKnoten(knot,
                                     darstellung,
                                     kX,
                                     kY,
                                     (Knoten) ausgKn);

                    if (g.istStartZ(knot)) {
                        darstellung.hinzuPfeil(kX - 60,
                                               kY - 60,
                                               kX - 45,
                                               kY - 45,
                                               0.5,
                                               false);
                    }
                } else {
                    this.setzeKnoten(knot,
                                     darstellung,
                                     koordX,
                                     koordY,
                                     (Knoten) ausgKn);

                    this.gesetzteKn.put(knot.holeName(),
                                        new Vektor2D(koordX, koordY));

                    if (g.istStartZ(knot)) {
                        darstellung.hinzuPfeil(koordX - 60,
                                               koordY - 60,
                                               koordX - 45,
                                               koordY - 45,
                                               0.5,
                                               false);
                    }

                    zaehler++;
                   
                    if (zaehler < Math.ceil(Math.sqrt(knAnzahl))) {
                        koordX = koordX + gitterX;
                    } else {
                        koordX = this.links;
                        koordY = koordY + gitterY;
                        zaehler = 0;
                    }
                }
            }

            // Kanten
            it1 = knotenListe.iterator();
            while (it1.hasNext()) {
                knot1 = (Knoten) it1.next();
                koord1 = (Vektor2D) this.gesetzteKn.get(knot1.holeName());

                it2 = (new ArrayList<Integer>(
                                knot1.holeNachfolger().keySet())).iterator();
                while (it2.hasNext()) {
                    boolean gebogen = true;
                   
                    knot2 = g.holeKnoten((Integer) it2.next());
                    koord2 = (Vektor2D) this.gesetzteKn.get(knot2.holeName());
                    Condition cond
                        = knot1.getInfo().getTransZuZustand(
                                knot2.holeName()).get(0).getCond();
                    double staerke = SonstMeth.condStrength(cond,
                                                   Konstanten.STAERKE_ERST,
                                                   Konstanten.STAERKE_ZWEIT);
                   
                    if (koord1.distanz(koord2) < 140
                            && !koord1.equals(koord2)) {
                        gebogen = false;
                    }
                   
                    darstellung.hinzuPfeil(
                            (int) koord1.x,
                            (int) koord1.y,
                            (int) koord2.x,
                            (int) koord2.y,
                            staerke,
                            gebogen);
                }
            }

            // Kantenbeschriftungen
            it1 = knotenListe.iterator();
            while (it1.hasNext()) {
                int kantNum = 1;
                knot1 = (Knoten) it1.next();
                koord1 = this.gesetzteKn.get(knot1.holeName());

                it3 = ((ZInfo) knot1.getInfo()).getBeds().iterator();
                while (it3.hasNext()) {
                    Polygon p = new Polygon();
                    bed = it3.next();
                    folgeZustand = bed.getFolgezustand();
                    bedingung = bed.getCond().toString();
                    knot2 = g.holeKnoten(new Integer(folgeZustand));
                    koord2 = this.gesetzteKn.get(knot2.holeName());

                    p.addPoint((int) koord1.x, (int) koord1.y);
                    p.addPoint((int) koord2.x, (int) koord2.y);
View Full Code Here


     */
    public void naechsterZustand() {
        int aktion;
        int parameter;
        LinkedList<Transition> bedingungen;
        Transition aktBed;
        ZInfo zusatz;
        int folgeZ = 0;
        Iterator<Transition> it;
        int i = 0;
       
        while (i < this.conds.length) {
            if (this.conds[i].evaluiere(this)) {
                if (this.initial || i != this.aktAut) {
                    this.aktAut = i;
                    this.vAut[this.aktAut].setzeChanged();
                    this.vAut[this.aktAut].notifyObservers(
                            new Integer(this.aktAut));
                    this.initial = false;
                }
                break;
            }
            i++;
        }
       
        this.expAktZyklen++;
        this.fitAktZyklen[this.aktAut]++;
        this.fitRedAktZyklen[this.aktAut]++;
        this.aktivZyklen[this.aktAut]++;
        this.mutAktZyklen++;
        this.aktMemZyk++;
        this.condMutAktZyklen++;
       
        if (this.fitRedAktZyklen[this.aktAut] > this.fitRedZyklen) {
            this.setFitness(this.aktAut,
                            (int) ((double) this.getFitness()[this.aktAut]
                                    / this.fitRedWert));
            this.fitRedAktZyklen[this.aktAut] = 0;
        }
       
        if (this.fitAktZyklen[this.aktAut] > this.fitZyklen) {
            this.befehle.clear();
            this.befehle.add(new Integer(this.lastBf));

            this.setFitness(this.aktAut,
                            this.getFitness()[this.aktAut]
                            + this.fitVs[this.aktAut].fitness(
                                    (Roboter) this));

            this.fitAktZyklen[this.aktAut] = 0;
        }

        if (this.pars.getEvol().booleanValue()) {
            if (this.aktMemZyk > this.pars.getMemInt().longValue()) {
                this.resetToBest();
            }
           
            if (this.mutAktZyklen > this.mutZyklen) {
                this.mutV = true;
                this.mutiere();
                this.mutAktZyklen = 0;
                this.mutV = false;
            } else {
                this.mutV = false;
            }
           
            if (this.condMutAktZyklen > this.pars.getCondMutZyk()) {
                this.mutiereBeds();
                this.condMutAktZyklen = 0;
            }
        }
       
        if (this.aktZustand[this.aktAut] == null) {
            this.aktZustand[this.aktAut]
                            = this.vAut[this.aktAut].holeStartzustand();
        }

        if (this.isSelektiert()) {
            if (this.aktZustand[this.aktAut] != null) {
                this.vAut[this.aktAut].setzeChanged();
                this.vAut[this.aktAut].notifyObservers(
                        this.aktZustand[this.aktAut]);
            }
        }

        if (this.aktZustand[this.aktAut] != null) {
            zusatz = (ZInfo) this.aktZustand[this.aktAut].getInfo();
            aktion = zusatz.getAktion();
            parameter = zusatz.getParam();

            this.gesamtAktion(aktion, parameter);
           
            this.lastBf = aktion;
           
            bedingungen = zusatz.getBeds();
            it = bedingungen.iterator();
            this.aktZustand[this.aktAut] = null;
            while (it.hasNext() && folgeZ == 0) {
                aktBed = (Transition) it.next();
                if (aktBed.evaluiere(this)) {
                    folgeZ = aktBed.getFolgezustand();
                    this.aktZustand[this.aktAut]
                        = this.vAut[this.aktAut].holeKnoten(
                                new Integer(folgeZ));
                }
            }
View Full Code Here

    public void naechsterZustand() {
        int aktion;
        int parameter;
        LinkedList<Transition> bedingungen;
        Transition aktBed;
        ZInfo zusatz;
        int folgeZ = 0;
        Iterator<Transition> it;
        int i = 0;
       
        while (i < this.conds.length) {
            if (this.conds[i].evaluiere(this)) {
                if (this.initial || i != this.aktAut) {
                    this.aktAut = i;
                    this.vAut[this.aktAut].setzeChanged();
                    this.vAut[this.aktAut].notifyObservers(
                            new Integer(this.aktAut));
                    this.initial = false;
                }
                break;
            }
            i++;
        }
       
        this.expAktZyklen++;
        this.fitAktZyklen[this.aktAut]++;
        this.fitRedAktZyklen[this.aktAut]++;
        this.aktivZyklen[this.aktAut]++;
        this.mutAktZyklen++;
        this.aktMemZyk++;
        this.condMutAktZyklen++;
       
        if (this.fitRedAktZyklen[this.aktAut] > this.fitRedZyklen) {
            this.setFitness(this.aktAut,
                            (int) ((double) this.getFitness()[this.aktAut]
                                    / this.fitRedWert));
            this.fitRedAktZyklen[this.aktAut] = 0;
        }
       
        if (this.fitAktZyklen[this.aktAut] > this.fitZyklen) {
            this.befehle.clear();
            this.befehle.add(new Integer(this.lastBf));

            this.setFitness(this.aktAut,
                            this.getFitness()[this.aktAut]
                            + this.fitVs[this.aktAut].fitness(
                                    (Roboter) this));

            this.fitAktZyklen[this.aktAut] = 0;
        }

        if (this.pars.getEvol().booleanValue()) {
            if (this.aktMemZyk > this.pars.getMemInt().longValue()) {
                this.resetToBest();
            }
           
            if (this.mutAktZyklen > this.mutZyklen) {
                this.mutV = true;
                this.mutiere();
                this.mutAktZyklen = 0;
                this.mutV = false;
            } else {
                this.mutV = false;
            }
           
            if (this.condMutAktZyklen > this.pars.getCondMutZyk()) {
                this.mutiereBeds();
                this.condMutAktZyklen = 0;
            }
        }
       
        if (this.aktZustand[this.aktAut] == null) {
            this.aktZustand[this.aktAut]
                            = this.vAut[this.aktAut].holeStartzustand();
        }

        if (this.isSelektiert()) {
            if (this.aktZustand[this.aktAut] != null) {
                this.vAut[this.aktAut].setzeChanged();
                this.vAut[this.aktAut].notifyObservers(
                        this.aktZustand[this.aktAut]);
            }
        }

        if (this.aktZustand[this.aktAut] != null) {
            zusatz = (ZInfo) this.aktZustand[this.aktAut].getInfo();
            aktion = zusatz.getAktion();
            parameter = zusatz.getParam();

            this.gesamtAktion(aktion, parameter);
           
            this.lastBf = aktion;
           
            bedingungen = zusatz.getBeds();
            it = bedingungen.iterator();
            this.aktZustand[this.aktAut] = null;
            while (it.hasNext() && folgeZ == 0) {
                aktBed = (Transition) it.next();
                if (aktBed.evaluiere(this)) {
View Full Code Here

                while (it2.hasNext()) {
                    boolean gebogen = true;
                   
                    knot2 = g.holeKnoten((Integer) it2.next());
                    koord2 = (Vektor2D) this.gesetzteKn.get(knot2.holeName());
                    Condition cond
                        = knot1.getInfo().getTransZuZustand(
                                knot2.holeName()).get(0).getCond();
                    double staerke = SonstMeth.condStrength(cond,
                                                   Konstanten.STAERKE_ERST,
                                                   Konstanten.STAERKE_ZWEIT);
View Full Code Here

    private void insertEdge(final int knotNam1,
                            final int knotNam2,
                            final EndlicherAutomat aut) {
        Knoten knot1 = aut.holeKnoten(knotNam1);
        Knoten knot2 = aut.holeKnoten(knotNam2);
        Condition c;
       
        if (knot1 == null) {
            this.insertNode(knotNam1, aut);
        }
        if (knot2 == null) {
View Full Code Here

        int quellKnotNam = qKnotNam, zielKnotNam = zKnotNam;
        Knoten knot1;
        Knoten knot2;
        List<Transition> vorhTrans;
        List<Condition> vorhConds;
        Condition c;
        Condition[] cZwisch;
        ArrayList<Integer> knListe;
       
        /* Falls eine Kante zwischen den Knoten bereits existierte, erzeuge
         * eine Kante zwischen anderen (welchen?) Knoten... Zu �berpr�fen.
         */
        if (aut.holeKnoten(qKnotNam) != null
                && aut.holeKnoten(qKnotNam).getInfo() != null
                && aut.holeKnoten(qKnotNam).holeNachfolger().containsKey(
                        zielKnotNam)) {
            quellKnotNam = this.instrCounter;
            this.instrCounter++;
            zielKnotNam = this.instrCounter;
            this.instrCounter++;
           
            knListe = aut.getKnList();
            quellKnotNam = knListe.get(
                    SonstMeth.modZwischen(quellKnotNam, 0, knListe.size() - 1));
            zielKnotNam = knListe.get(
                    SonstMeth.modZwischen(zielKnotNam, 0, knListe.size() - 1));

            // Wenn immer noch eine Kante existiert, f�ge nichts ein.
            if (aut.holeKnoten(quellKnotNam) != null
                  && aut.holeKnoten(quellKnotNam).getInfo() != null
                  && aut.holeKnoten(quellKnotNam).holeNachfolger().containsKey(
                          zielKnotNam)) {
                SonstMeth.log(
                        SonstMeth.LOG_STAGE1,
                        "Erg�nzungskante nicht eingef�gt, da die ersten beiden"
                        + " Versuche bereits Kanten aufwiesen.",
                        this.pars);
                return;
            }
        }

        knot1 = aut.holeKnoten(quellKnotNam);
        knot2 = aut.holeKnoten(zielKnotNam);

        // F�ge Knoten neu ein, falls sie noch nicht existieren.
        if (knot1 == null) {
            this.insertNode(quellKnotNam, aut);
            knot1 = aut.holeKnoten(quellKnotNam);
        }
        if (knot2 == null) {
            this.insertNode(zielKnotNam, aut);
            knot2 = aut.holeKnoten(zielKnotNam);
        }

        if (knot1.getInfo() == null || knot1.getInfo().getBeds().size() == 0) {
            c = new ConstLeaf(true);
        } else {
            int i = 0;
            vorhTrans = knot1.getInfo().getBeds();
            vorhConds = new ArrayList<Condition>(vorhTrans.size());

            for (Transition t : vorhTrans) {
                vorhConds.add(t.getCond());
            }
           
            cZwisch = new Condition[vorhConds.size()];
           
            for (Condition condition : vorhConds) {
                cZwisch[i] = SonstMeth.ausFormatBed(condition.formatted());
                cZwisch[i].negiere();
                i++;
            }
           
            c = cZwisch[0];
            for (int j = 1; j < cZwisch.length; j++) {
                c = new InnerNode(
                        c,
                        cZwisch[j],
                        fmg.fmg8.endlAutomat.Konstanten.UND);
            }
        }
       
        c = c.simplify();
       
        // BO
//        System.out.println();
//        System.out.println(
//            aut.holeKnoten(quellKnotNam).getInfo().getBedingungen());
//        System.out.println(c);
//        c = c;
        // EO
       
        if (!c.equals(new ConstLeaf(false))) {
            aut.einfuegKante(
                    quellKnotNam,
                    zielKnotNam,
                    c,
                    1);
View Full Code Here

                                    "SteuerFenster.KanteNeu"));
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.AusSequenz"))) {
                    int autNum = this.aktGrph.getAktAut();
                    String condS = this.aktGrph.getConditions()[autNum];
                    Condition cond = SonstMeth.ausBed(condS);
                   
                    this.aktGrph.getRob().erzeugeAusSequenz(
                        this.aktGrph.getAktAut(),
                        this.aktGrph.holeAktTxtSeq(),
                        cond,
                        this.aktGrph.getRob().getAktTAut(),
                        true);
                    this.loescheSelKnot();
                    SonstMeth.log(
                            SonstMeth.LOG_DEBUG,
                            "Aus Sequenz mit aktuellem Translator.",
                            this.pars);
                } else if (cmd.equals("Aus Std-Sequenz")) {
                    int autNum = this.aktGrph.getAktAut();
                    String condS = this.aktGrph.getConditions()[autNum];
                    Condition cond = SonstMeth.ausBed(condS);
                   
                    this.aktGrph.getRob().erzeugeAusSequenz(
                        this.aktGrph.getAktAut(),
                        this.aktGrph.holeAktTxtSeq(),
                        cond,
                        true);
                    this.loescheSelKnot();
                    SonstMeth.log(
                            SonstMeth.LOG_DEBUG,
                            "Aus Sequenz mit Standardkodierung "
                            + "ohne Translator.",
                            this.pars);
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.AusSequenzen"))) {
                    this.aktGrph.erzeugeAlleAusSeq(
                            this.aktGrph.getSeqs(),
                            SonstMeth.ausBeds(this.aktGrph.getConditions()),
                            true);
                    this.loescheSelKnot();
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.GraphLoeschen"))) {
                    AllgemeinerDialog nachfrage;
                    ArrayList<String> buttons = new ArrayList<String>();
                    buttons.add(Messages.getString("SteuerFenster.OK"));
                    buttons.add(Messages.getString("SteuerFenster.Abbrechen"));

                    nachfrage = new AllgemeinerDialog(
                                    this,
                                    "Soll der aktuelle Endliche Automat "
                                    + "<" + this.aktGrph
                                    + "> wirklich von der Festplatte gel�scht"
                                    + " UND aus der Darstellung entfernt "
                                    + "werden?",
                                    Messages.getString(
                                                "SteuerFenster.GraphLoeschen"),
                                    buttons,
                                    null);
                    nachfrage.setVisible(true);

                    if (nachfrage.getResult().equals(Messages.getString(
                                    "SteuerFenster.OK"))) {
                        this.loescheGraph(this.aktGrph, true);
                        this.waehleGraph(0);
                    }
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.NeuerGraph"))) {
                    this.neuerGraph();
                    this.waehleGraph(this.graphZaehl - 1);
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.GraphLeeren"))) {
                    AllgemeinerDialog nachfrage;
                    ArrayList<String> buttons = new ArrayList<String>();
                    buttons.add(Messages.getString("SteuerFenster.OK"));
                    buttons.add(Messages.getString("SteuerFenster.Abbrechen"));

                    nachfrage = new AllgemeinerDialog(
                                    this,
                                    "Sollen ALLE KNOTEN des aktuellen "
                                    + "Endlichen Automaten "
                                    + "<" + this.aktGrph
                                    + "> wirklich gel�scht"
                                    + " werden?",
                                    Messages.getString(
                                                  "SteuerFenster.GraphLeeren"),
                                    buttons,
                                    null);
                    nachfrage.setVisible(true);

                    if (nachfrage.getResult().equals(Messages.getString(
                                    "SteuerFenster.OK"))) {
                        this.aktGrph.leereAktGraph();
                        this.selKn(null);
                    }
                } else if (cmd.equals(Messages.getString(
                                    "SteuerFenster.AlleLeeren"))) {
                    AllgemeinerDialog nachfrage;
                    ArrayList<String> buttons = new ArrayList<String>();
                    buttons.add(Messages.getString("SteuerFenster.OK"));
                    buttons.add(Messages.getString("SteuerFenster.Abbrechen"));
               
                    nachfrage = new AllgemeinerDialog(
                                    this,
                                    "Sollen ALLE KNOTEN ALLER AUTOMATEN "
                                        + " wirklich gel�scht werden?",
                                    Messages.getString(
                                                  "SteuerFenster.AlleLeeren"),
                                    buttons,
                                    null);
                    nachfrage.setVisible(true);
               
                    if (nachfrage.getResult().equals(Messages.getString(
                                    "SteuerFenster.OK"))) {
                        Vis aktGraph;
                        Iterator<Vis> it = this.graphen.iterator();
                        while (it.hasNext()) {
                            aktGraph = (Vis) it.next();
                            aktGraph.leereAlleGraphen();
                            aktGraph.neuZeichnen();
                        }
                        this.selKn(null);
                    }
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.GraphKopieren"))) {
                    String[] seq = this.aktGrph.getRob().erzeugeStrSeqs();
                    Condition[] conds = this.aktGrph.getRob().getConds();
                    DarstModEA[] darAlt;
                    darAlt = (DarstModEA[])
                        SonstMeth.seriaClone(this.aktGrph.getDarstellArt());

                    this.neuerGraph();
                    this.waehleGraph(this.graphZaehl - 1);
                    this.aktGrph.setzeAlleSeq(seq);
                    this.aktGrph.getRob().erzeugeAusSequenzen(seq,
                                                              conds,
                                                              null,
                                                              false);
                    this.aktGrph.setDarstellArt(darAlt);

                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.GraphSpeichern"))) {
                    this.aktGrph.speichereGraph(
                                    Messages.getString("Vis.All"));
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.GraphLaden"))) {
                    AllgemeinerDialog nachfrage;
                    ArrayList<String> buttons = new ArrayList<String>();
                    buttons.add(Messages.getString("SteuerFenster.OK"));
                    buttons.add(Messages.getString("SteuerFenster.Abbrechen"));

                    nachfrage = new AllgemeinerDialog(
                                    this,
                                    Messages.getString("SteuerFenster."
                                                    + "SollNeuLaden")
                                    + " <" + this.aktGrph
                                    + ">.",
                                    Messages.getString(
                                                  "SteuerFenster.GraphLaden"),
                                    buttons,
                                    null);
                    nachfrage.setVisible(true);

                    if (nachfrage.getResult().equals(Messages.getString(
                                    "SteuerFenster.OK"))) {
                        this.aktGrph.ladeRob();
                        this.loescheSelKnot();
                    }
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.SIM"))) {
                    this.simStarten(false);
                } else if (cmd.equals(Messages.getString(
                                "SteuerFenster.EVO"))) {
                    this.simStarten(true);
                } else if (cmd.equals(
                        Messages.getString("SteuerFenster.GraphUmbenennen"))) {
                    AllgemeinerDialog dia;
                    ArrayList<String> buttons = new ArrayList<String>();
                    buttons.add(Messages.getString("SteuerFenster.OK"));
                    buttons.add(Messages.getString("SteuerFenster.Abbrechen"));

                    dia = new AllgemeinerDialog(
                                    this,
                                    null,
                                    Messages.getString("SteuerFenster."
                                                     + "SollUmbenennen"),
                                    buttons,
                                    this.aktGrph.getGraphName(),
                                    1,
                                    50,
                                    true);
                    dia.setVisible(true);

                    if (dia.getResult().equals(
                                    Messages.getString("SteuerFenster.OK"))) {
                        String name = dia.getText();
                        boolean ok = true;
                        Iterator<Vis> it = this.graphen.iterator();

                        while (it.hasNext()) {
                            Vis aktG = (Vis) it.next();
                            if (aktG.getGraphName().equals(name)) {
                                ok = false;
                            }
                        }

                        if (ok) {
                            int index = this.grAuswahl.getSelectedIndex();
                            int max = this.grAuswahl.getItemCount();
                            ArrayList<String> strings = new ArrayList<String>();
                            for (int i = 0; i < max; i++) {
                                if (i == index) {
                                    strings.add(name);
                                } else {
                                    strings.add(this.grAuswahl.getItem(i));
                                }
                            }

                            this.grAuswahl.removeAll();
                            this.aktGrph.setGraphName(name);

                            for (int i = 0; i < max; i++) {
                                this.grAuswahl.add((String) strings.get(i));
                            }

                            this.grAuswahl.select(index);
                        }
                    }

                } else if (cmd.equals(
                           Messages.getString("SteuerFenster.Mutation"))) {
                    this.aktGrph.mutiere();
                } else if (cmd.equals(
                        Messages.getString("SteuerFenster.Rekombination"))) {
                    ArrayList<String> a = new ArrayList<String>();
                    Iterator<Vis> it = this.graphen.iterator();
                    while (it.hasNext()) {
                        Vis v = (Vis) it.next();
                        a.add(v.toString());
                    }
                   
                    AllgemeinerDialog dia = new AllgemeinerDialog(
                              this,
                              "Rekombination",
                              "Bitte die zu rekombinierenden\nGraphen w�hlen.",
                              a,
                              Messages.getString("SteuerFenster.Abbrechen"),
                              Messages.getString("SteuerFenster.OK"),
                              true,
                              -1);
                    dia.setVisible(true);
                    if (dia.getResult()
                            == Messages.getString("SteuerFenster.OK")) {
                       
                        String[] str = dia.getListe().getSelectedItems();
                        Roboter[] pop = new Roboter[str.length];
                        Vis v;
                       
                        for (int i = 0; i < str.length; i++) {
                            it = this.graphen.iterator();
                            while (it.hasNext()) {
                                v = (Vis) it.next();
                                if (v.toString().equals(str[i])) {
                                    pop[i] = v.getRob();
                                   
                                    for (int j = 0;
                                         j < v.getRob().vAuts().length;
                                         j++) {
                                        ArrayList<String> b
                                            = new ArrayList<String>(1);
                                        b.add(Messages.getString(
                                                "SteuerFenster.OK"));
                                        AllgemeinerDialog dia2
                                            = new AllgemeinerDialog(
                                                    this,
                                                    "",
                                                    "Fitness " + j
                                                      + " ("
                                                      + str[i]
                                                      + ")",
                                                    b,
                                                    "" + pop[i].getFitness()[0],
                                                    1,
                                                    50,
                                                    true);
   
                                        dia2.setVisible(true);
                                       
                                        pop[i].setFitness(j,
                                            Integer.parseInt(dia2.getText()));
                                        }
                                   
                                    break;
                                }
                            }
                        }

                        RobCode[] r = this.rekombArt.rekombEinz(pop);
                        for (int i = 0; i < r.length; i++) {
                            v = this.neuerGraph();
                            v.erzeugeAlleAusSeq(
                                    r[i].getVStdCodes(),
                                    null,
                                    false);
                            this.selGraph(v);
                        }
                    }
                   
                } else if (cmd.equals(
                           Messages.getString("SteuerFenster.ErzeugeHEX"))) {
                    FileDialog dia;

                    dia = new FileDialog(this,
                                         Messages.getString("SteuerFenster."
                                                        + "ErzeugeHEXTitel"),
                                         FileDialog.SAVE);
                    dia.setVisible(true);

                    if (!(dia.getDirectory() == null)
                        && !(dia.getFile() == null)) {
                        LinkedList<Integer> seq
                            = this.aktGrph.getRob().erzeugeSequenz(
                                    this.aktGrph.getAktAut());
                        FileWriter f = new FileWriter(dia.getDirectory()
                                                      + File.separatorChar
                                                      + dia.getFile());
                        Iterator<Integer> it = seq.iterator();

                        while (it.hasNext()) {
                            f.write(((Integer) it.next()).intValue());
                        }
                        f.close();
                    }
                } else if (cmd.equals(
                        Messages.getString("SteuerFenster.Vereinfache"))) {
                    this.aktGrph.getRob().vAuts()[
                                   this.aktGrph.getAktAut()].vereinfache();
                    Condition condSimp =
                        this.aktGrph.getRob().getConds()[
                                  this.aktGrph.getAktAut()].simplify();
                    this.aktGrph.getRob().setCond(this.aktGrph.getAktAut(),
                                                  condSimp);
                   
                } else if (cmd.equals(
                        Messages.getString("SteuerFenster.VereinfacheAlle"))) {
                    Iterator<Vis> it = this.graphen.iterator();
                    Condition condSimp;
                    Vis aktVis;
                    while (it.hasNext()) {
                        aktVis = (Vis) it.next();
                        for (int i = 0;
                             i < aktVis.getRob().vAuts().length;
View Full Code Here

        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);
                }
View Full Code Here

     */
    public static double condStrength(final Condition cond,
                               final long erstmalig,
                               final long spaeter) {
        long iterat;
        Condition c = cond.simplify();
        Random rand = new Random();
        HashSet<Integer> sensors = cond.aktSens();
        int[] sens;
        int max = 0;
        double value;
        boolean vorhanden = false;
        String cForm = c.formatted();
        double newVal;
       
        Iterator<Integer> it = sensors.iterator();
        while (it.hasNext()) {
            int zwisch = it.next();
           
            if (zwisch > max) {
                max = zwisch;
            }
        }
       
        sens = new int[max];
       
        if (SonstMeth.berConds == null) {
            berConds = new HashMap<String, Double>();
            berCondsIt = new HashMap<String, Long>();
        }
       
        if (berConds.containsKey(cForm)) {
            iterat = spaeter;
            vorhanden = true;
        } else {
            iterat = erstmalig;
        }
       
        value = 0;
        for (long i = 0; i < iterat; i++) {
            it = sensors.iterator();
            while (it.hasNext()) {
                sens[it.next() - 1] = rand.nextInt(256);
            }
           
            if (c.evaluiereSens(sens)) {
                value++;
            }
        }
       
        if (vorhanden) {
View Full Code Here

                while (it2.hasNext()) {
                    boolean gebogen = true;
                   
                    knot2 = g.holeKnoten((Integer) it2.next());
                    koord2 = (Vektor2D) this.gesetzteKn.get(knot2.holeName());
                    Condition cond
                        = knot1.getInfo().getTransZuZustand(
                                knot2.holeName()).get(0).getCond();
                    double staerke = SonstMeth.condStrength(cond,
                                                   Konstanten.STAERKE_ERST,
                                                   Konstanten.STAERKE_ZWEIT);
View Full Code Here

TOP

Related Classes of fmg.fmg8.endlAutomat.conditions.Condition

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.