Package fmg.fmg8.endlAutomat.conditions

Examples of fmg.fmg8.endlAutomat.conditions.InnerNode


            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

     *            Der Zusatzparameter.
     */
    public void update(final Observable o, final Object arg) {
        Knoten k;
        AutomatenNummer aN;
        ConditionNummer cN;
        int autNum;

        if (arg == null) {
            return;
        }

        if (arg.getClass().equals(Integer.class)) {
            // Neuer Automat wurde ausgew�hlt.
            autNum = ((Integer) arg).intValue();
            this.benutztAut = autNum;
            this.selectAktAut(false, autNum);
        } else if (arg.getClass().equals(Knoten.class)) {
            // Neuer Knoten wurde ausgew�hlt.
            k = (Knoten) arg;
            this.selKnoten(k, this.benutztAut);
        } else if (arg.getClass().equals(AutomatenNummer.class)) {
            // Sequenz wurde ver�ndert.
            aN = (AutomatenNummer) arg;
            this.erzeugeAusSequenz(aN.getAutNum(),
                                   aN.getSequenz(),
                                   null,
                                   false);
        } else if (arg.getClass().equals(ConditionNummer.class)) {
            // Bedingungen wurden ver�ndert.
            cN = (ConditionNummer) arg;
            this.setzeCond(cN.getAutNum(), cN.getSequenz());
           
            for (VisTrans v : this.aktVisTrans) {
                v.neuZeichnen();
            }
        }
View Full Code Here

        for (int i = 0; i < this.conds.length; i++) {
            this.conds[i] = this.mut.mutiere(this.conds[i]);
            if (this.isSelektiert()) {
                this.vAut[i].setzeChanged();
                this.vAut[i].notifyObservers(
                        new ConditionNummer(this.conds[i].toString(),
                                            i));
            }
        }
    }
View Full Code Here

            this.conds[autNum] = cond;
           
            if (this.isSelektiert()) {
                this.vAut[autNum].setzeChanged();
                this.vAut[autNum].notifyObservers(
                        new ConditionNummer(this.conds[autNum].toString(),
                                            autNum));
            }
        }
       
        if (this.isSelektiert()) {
View Full Code Here

                i++;
            }
           
            c = cZwisch[0];
            for (int j = 1; j < cZwisch.length; j++) {
                c = new InnerNode(
                        c,
                        cZwisch[j],
                        fmg.fmg8.endlAutomat.Konstanten.UND);
            }
        }
View Full Code Here

            } else if (bedingung.charAt(i)
                    == fmg.fmg8.endlAutomat.Konstanten.KZ) {
                klammerAuf--;
            } else if (klammerAuf == 1
                       && istBoolOperator(bedingung.charAt(i))) {
                return new InnerNode(ausFormatBed(bedingung.substring(3,
                                                                i - 1)),
                                     ausFormatBed(bedingung.substring(i + 2,
                                                     bedingung.length() - 3)),
                                     bedingung.charAt(i));
            }
View Full Code Here

                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

TOP

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

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.