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

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


     * @param ea  Der zu mutierende Automat.
     * @return  Ob eine Bedingung mutiert wurde.
     */
    public final boolean mutationBedBeinfacher(final EndlicherAutomat ea) {
        ArrayList<Transition> bedingungen = ea.getBedListe();
        Transition aktBed;
        String aktString;
        String neuString;
        int posLKlammer;
        int posRKlammer;
        int pos;
        int zufallsindex;
       
        while (bedingungen.size() > 0) {
            zufallsindex = rand.nextInt(bedingungen.size());
            aktBed = bedingungen.get(zufallsindex);
            aktString = aktBed.getCond().formatted();
           
            pos = this.indexZeichenfolge(aktString,
                                         eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND,
                                         eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE);
           
            if (pos < 0) {
                pos = this.indexZeichenfolge(
                        aktString,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE);
            }
           
            if (pos >= 0) {
                posLKlammer = this.findeKlLinks(aktString, pos);
                posRKlammer = pos + 3;
                neuString = aktString.substring(0, posLKlammer - 1)
                            + aktString.substring(posLKlammer + 2,
                                                  pos - 4)
                            + aktString.substring(posRKlammer + 2);
                aktBed.setBedingung(neuString);
                return true;
            }
           
            pos = this.indexZeichenfolge(
                    aktString,
                    eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE,
                    eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND);

            if (pos < 0) {
                pos = this.indexZeichenfolge(
                        aktString,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER);
            }

            if (pos >= 0) {
                posLKlammer = pos - 3;
                posRKlammer = this.findeKlRechts(aktString, pos);
                neuString = aktString.substring(0, pos - 7)
                            + aktString.substring(pos + 2,
                                                  posRKlammer - 1)
                            + aktString.substring(posRKlammer + 2);
                aktBed.setBedingung(neuString);
                return true;
            }
           
            pos = this.indexZeichenfolge(aktString,
                                         eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER,
                                         eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE);
            if (pos < 0) {
                pos = this.indexZeichenfolge(aktString,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE);
            }
           
            if (pos >= 0) {
                posLKlammer = this.findeKlLinks(aktString, pos);
                posRKlammer = pos + 3;
                neuString = aktString.substring(0, posLKlammer - 1)
                            + aktString.substring(pos - 1, pos + 2)
                            + aktString.substring(posRKlammer + 2);
                aktBed.setBedingung(neuString);
                return true;
            }

            pos = this.indexZeichenfolge(aktString,
                                         eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE,
                                         eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER);
            if (pos < 0) {
                pos = this.indexZeichenfolge(aktString,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE,
                        eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND);
            }

            if (pos >= 0) {
                posLKlammer = pos - 6;
                posRKlammer = this.findeKlRechts(aktString, pos);
                neuString = aktString.substring(0, posLKlammer - 1)
                            + aktString.substring(pos - 4, pos - 1)
                            + aktString.substring(posRKlammer + 2);
                aktBed.setBedingung(neuString);
                return true;
            }
           
            bedingungen.remove(zufallsindex);
        }
View Full Code Here


        // 1. Suche pos mit BED[pos] = UND oder BED[pos] = ODER.
        // 2. Falls so ein pos ex.: zufällig Fall 2 oder Fall 3.
        //    Sonst: Fall 1.
       
        ArrayList<Transition> bedingungen = ea.getBedListe();
        Transition aktBed;
        String aktString;
        String neuString = "";
        int posLKlammer;
        int posRKlammer;
        int pos;
        int zufallsindex;
        ArrayList<Character> zeichen = new ArrayList<Character>(2);
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER));
        boolean und = this.rand.nextBoolean();
        boolean fallZwei = this.rand.nextBoolean();
        boolean erzwingeFall1 = this.rand.nextInt(5) == 0;
       
        if (bedingungen.size() > 0) {
            zufallsindex = this.rand.nextInt(bedingungen.size());
           
            aktBed = bedingungen.get(zufallsindex);
            aktString = aktBed.getCond().formatted();

            pos = this.indexZeichen(aktString,
                                    zeichen);
            if (pos < 0 || erzwingeFall1) {
                // Fall 1
                if (und) {
                    neuString = " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KA + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND + " "
                        + aktString
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KZ + " ";
                } else {
                    neuString =
                        " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KA + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER + " "
                        + aktString
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KZ + " ";
                }
               
            } else {
                // Fall 2 oder 3
                posLKlammer = this.findeKlLinks(aktString, pos);
                posRKlammer = this.findeKlRechts(aktString, pos);
                if (fallZwei && und) {
                    neuString = aktString.substring(0, posLKlammer + 2)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KA + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND + " "
                        + aktString.substring(
                                posLKlammer + 2,
                                pos - 1)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KZ + " "
                        + aktString.substring(pos - 1);
                }

                if (fallZwei && !und) {
                    neuString = aktString.substring(0, posLKlammer + 2)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KA + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER + " "
                        + aktString.substring(
                                posLKlammer + 2,
                                pos - 1)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KZ + " "
                        + aktString.substring(pos - 1);
                }
               
                if (!fallZwei && und) {
                    neuString =
                        aktString.substring(0, pos + 2)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KA + " "
                        + aktString.substring(
                                pos + 2,
                                posRKlammer - 1)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UND + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE + " "
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KZ + " "
                        + aktString.substring(posRKlammer - 1);
                }

                if (!fallZwei && !und) {
                    neuString = aktString.substring(0, pos + 2)
                    + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KA + " "
                    + aktString.substring(
                            pos + 2,
                            posRKlammer - 1)
                    + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.ODER + " "
                    + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE + " "
                    + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KZ + " "
                    + aktString.substring(posRKlammer - 1);
                }
            }

            aktBed.setBedingung(neuString);
           
            return true;
        }
       
        return false;
View Full Code Here

     * @return  Ob eine Bedingung mutiert wurde.
     */
    public final boolean mutationBedZahl(final EndlicherAutomat ea) {
        ArrayList<Transition> bedingungen = ea.getBedListe();
        int zufallsIndex;
        Transition zufallsBed;
        String bedString;
        int alt;
        int neu;
        String neuS;
        int pos;
       
        while (bedingungen.size() > 0) {
            zufallsIndex = this.rand.nextInt(bedingungen.size());
            zufallsBed = bedingungen.get(zufallsIndex);
            bedString = zufallsBed.getCond().formatted();
            pos = this.indexZahl(bedString);
           
            if (pos >= 0) {
                alt = Integer.parseInt(bedString.substring(pos - 1, pos + 2));
                neu = alt + (this.rand.nextInt(2 * this.k)) - this.k;
                if (neu < 1) {
                    neu = 1;
                }
                if (neu > 255) {
                    neu = 255;
                }

                neuS = bedString.substring(0, pos - 1)
                       + StaticMethods.normZahl(neu)
                       + bedString.substring(pos + 2);

                zufallsBed.setBedingung(neuS);
               
                return true;
            }
            bedingungen.remove(zufallsIndex);
        }
View Full Code Here

     * @return  Ob eine Bedingung mutiert wurde.
     */
    public final boolean mutationBedSensVar(final EndlicherAutomat ea) {
        ArrayList<Transition> bedingungen = ea.getBedListe();
        int zufallsIndex;
        Transition zufallsBed;
        String bedString;
        int neu;
        String neuS;
        int pos;
       
        while (bedingungen.size() > 0) {
            zufallsIndex = this.rand.nextInt(bedingungen.size());
            zufallsBed = bedingungen.get(zufallsIndex);
            bedString = zufallsBed.getCond().formatted();
            pos = this.indexSensVar(bedString);
           
            if (pos >= 0) {
                neu = StaticMethods.glVertZwischen(
                        StaticMethods.minVar(this.modus),
                        StaticMethods.maxVar(this.modus),
                        this.rand);

                neuS = bedString.substring(0, pos - 1)
                       + StaticMethods.normZahl(neu)
                       + bedString.substring(pos + 2);

                zufallsBed.setBedingung(neuS);
               
                return true;
            }
            bedingungen.remove(zufallsIndex);
        }
View Full Code Here

TOP

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

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.