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 mutationBedA(final EndlicherAutomat ea) {
        ArrayList<Transition> bedingungen = ea.getBedListe();
        Transition aktBed;
        String aktString;
        String neuString = "";
        int pos;
        int zufallsindex;
        ArrayList<Character> zeichen = new ArrayList<Character>(2);
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE));
        boolean links = this.rand.nextBoolean();
        boolean oben = this.rand.nextBoolean();
        boolean var1 = this.rand.nextBoolean();
        boolean var2 = !var1 || this.rand.nextBoolean();
        String string1;
        String string2;

        if (bedingungen.size() > 0) {
            zufallsindex = this.rand.nextInt(bedingungen.size());
            aktBed = bedingungen.get(zufallsindex);
            aktString = aktBed.getCond().formatted();

            pos = this.indexZeichen(aktString,
                                    zeichen);
            if (aktString.charAt(pos)
                    == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE) {
                if (var1) {
                    int variable1 = StaticMethods.glVertZwischen(
                            1,
                            this.numAgentSensors,
                            this.rand);
                   
                    string1 = " " 
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable1);
                } else {
                    int nummer1 = this.rand.nextInt(255) + 1;
                    string1 = eas.miscellaneous.StaticMethods.normZahl(nummer1);
                }

                if (var2) {
                    int variable2 = StaticMethods.glVertZwischen(
                            1,
                            this.numAgentSensors,
                            this.rand);
                   
                    string2 = " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable2);
                } else {
                    int nummer2 = this.rand.nextInt(255) + 1;
                    string2 = eas.miscellaneous.StaticMethods.normZahl(nummer2);
                }

                neuString = aktString.substring(0, pos - 1)
                            + string1
                            + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL + " "
                            + string2
                            + aktString.substring(pos + 2);
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL) {
                if (links) {
                    int lGrenze;
                    int rGrenze;
                    if (pos >= 6 && aktString.charAt(pos - 6)
                        == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                        lGrenze = pos - 7;
                    } else {
                        lGrenze = pos - 4;
                    }
                    if (aktString.charAt(pos + 3)
                            == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                            rGrenze = pos + 8;
                        } else {
                            rGrenze = pos + 5;
                    }
                    neuString = aktString.substring(0, lGrenze)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE + " "
                        + aktString.substring(rGrenze);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL
                                + aktString.substring(pos + 1);
                } else {
                    if (oben) {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL
                                    + aktString.substring(pos + 1);
                    } else {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL
                                    + aktString.substring(pos + 1);
                    }
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos)
                    == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF) {
                if (links) {
                    if (oben) {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL
                                    + aktString.substring(pos + 1);
                    } else {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR
                                    + aktString.substring(pos + 1);
                    }
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF
                                + aktString.substring(pos + 1);
                } else {
                    int lGrenze;
                    int rGrenze;
                    if (pos >= 6 && aktString.charAt(pos - 6)
                        == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                        lGrenze = pos - 7;
                    } else {
                        lGrenze = pos - 4;
                    }
                    if (aktString.charAt(pos + 3)
                            == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                            rGrenze = pos + 8;
                        } else {
                            rGrenze = pos + 5;
                    }
                    neuString = aktString.substring(0, lGrenze)
                        + " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE
                        + " "
                        + aktString.substring(rGrenze);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE) {
                if (var1) {
                    int variable1 = StaticMethods.glVertZwischen(
                            1,
                            this.numAgentSensors,
                            this.rand);
                   
                    string1 = " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING
                        + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable1);
                } else {
                    int nummer1 = this.rand.nextInt(255) + 1;
                    string1 = eas.miscellaneous.StaticMethods.normZahl(nummer1);
                }

                if (var2) {
                    int variable2 = StaticMethods.glVertZwischen(
                            1,
                            this.numAgentSensors,
                            this.rand);
                   
                    string2 = " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING
                        + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable2);
                } else {
                    int nummer2 = this.rand.nextInt(255) + 1;
                    string2 = eas.miscellaneous.StaticMethods.normZahl(nummer2);
                }

                neuString = aktString.substring(0, pos - 1)
                            + string1
                            + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL + " "
                            + string2
                            + aktString.substring(pos + 2);
            }

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


     * @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(
                        1,
                        this.numAgentSensors ,
                        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

        // 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 ageSemMutBedZahl(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);
            if (pars.getParValueBoolean("ageDecrement")) {
                zufallsBed.setAlter(Math.max(1, zufallsBed.getAlter() - 1));
            }
            else {
                zufallsBed.setAlter(1);
            }
            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);

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

     * @return  Ob eine Bedingung mutiert wurde.
     */
    public final boolean ageSemMutBedSensVar(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);
            if (pars.getParValueBoolean("ageDecrement")) {
                zufallsBed.setAlter(Math.max(1, zufallsBed.getAlter() - 1));
            }
            else {
                zufallsBed.setAlter(1);  
            }

            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);

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

            = new ArrayList<Integer>(alleBeds.keySet());
        LinkedList<Transition> aktBeds;
        Integer aktKnoten;
        Iterator<Transition> it;
        String aktBed;
        Transition vollstBed;
        Integer fZustand;
        int pruefIndex;
       
        while (alleKnoten.size() > 0) {
            pruefIndex = this.rand.nextInt(alleKnoten.size());
            aktKnoten = alleKnoten.get(pruefIndex);
            aktBeds = alleBeds.get(aktKnoten);
           
            it = aktBeds.iterator();
            while (it.hasNext()) {
                vollstBed = it.next();
                aktBed = vollstBed.getCond().formatted();
                if (aktBed.charAt(1) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE) {
                    fZustand = new Integer(vollstBed.getFolgezustand());
                    ea.entferneKante(aktKnoten, fZustand, vollstBed);
                    return true;
                }
            }
           
View Full Code Here

     * @param ea  Der zu mutierende Automat.
     * @return  Ob eine Bedingung mutiert wurde.
     */
    public final boolean mutationBedA(final EndlicherAutomat ea) {
        ArrayList<Transition> bedingungen = ea.getBedListe();
        Transition aktBed;
        String aktString;
        String neuString = "";
        int pos;
        int zufallsindex;
        ArrayList<Character> zeichen = new ArrayList<Character>(2);
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL));
        zeichen.add(new Character(eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE));
        boolean links = this.rand.nextBoolean();
        boolean oben = this.rand.nextBoolean();
        boolean var1 = this.rand.nextBoolean();
        boolean var2 = !var1 || this.rand.nextBoolean();
        String string1;
        String string2;

        if (bedingungen.size() > 0) {
            zufallsindex = this.rand.nextInt(bedingungen.size());
            aktBed = bedingungen.get(zufallsindex);
            aktString = aktBed.getCond().formatted();

            pos = this.indexZeichen(aktString,
                                    zeichen);
            if (aktString.charAt(pos)
                    == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE) {
                if (var1) {
                    int variable1 = StaticMethods.glVertZwischen(
                            StaticMethods.minVar(this.modus),
                            StaticMethods.maxVar(this.modus),
                            this.rand);
                   
                    string1 = " " 
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable1);
                } else {
                    int nummer1 = this.rand.nextInt(255) + 1;
                    string1 = eas.miscellaneous.StaticMethods.normZahl(nummer1);
                }

                if (var2) {
                    int variable2 = StaticMethods.glVertZwischen(
                            StaticMethods.minVar(this.modus),
                            StaticMethods.maxVar(this.modus),
                            this.rand);
                   
                    string2 = " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable2);
                } else {
                    int nummer2 = this.rand.nextInt(255) + 1;
                    string2 = eas.miscellaneous.StaticMethods.normZahl(nummer2);
                }

                neuString = aktString.substring(0, pos - 1)
                            + string1
                            + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL + " "
                            + string2
                            + aktString.substring(pos + 2);
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL) {
                if (links) {
                    int lGrenze;
                    int rGrenze;
                    if (pos >= 6 && aktString.charAt(pos - 6)
                        == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                        lGrenze = pos - 7;
                    } else {
                        lGrenze = pos - 4;
                    }
                    if (aktString.charAt(pos + 3)
                            == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                            rGrenze = pos + 8;
                        } else {
                            rGrenze = pos + 5;
                    }
                    neuString = aktString.substring(0, lGrenze)
                        + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.FALSE + " "
                        + aktString.substring(rGrenze);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GL
                                + aktString.substring(pos + 1);
                } else {
                    if (oben) {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL
                                    + aktString.substring(pos + 1);
                    } else {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL
                                    + aktString.substring(pos + 1);
                    }
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UNGF
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KLGL
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GRGL
                                + aktString.substring(pos + 1);
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos)
                    == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF) {
                if (links) {
                    if (oben) {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.KL
                                    + aktString.substring(pos + 1);
                    } else {
                        neuString = aktString.substring(0, pos)
                                    + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.GR
                                    + aktString.substring(pos + 1);
                    }
                } else {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL
                                + aktString.substring(pos + 1);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL) {
                if (links) {
                    neuString = aktString.substring(0, pos)
                                + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.NUNGF
                                + aktString.substring(pos + 1);
                } else {
                    int lGrenze;
                    int rGrenze;
                    if (pos >= 6 && aktString.charAt(pos - 6)
                        == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                        lGrenze = pos - 7;
                    } else {
                        lGrenze = pos - 4;
                    }
                    if (aktString.charAt(pos + 3)
                            == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING) {
                            rGrenze = pos + 8;
                        } else {
                            rGrenze = pos + 5;
                    }
                    neuString = aktString.substring(0, lGrenze)
                        + " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE
                        + " "
                        + aktString.substring(rGrenze);
                }
            }

            if (aktString.charAt(pos) == eas.simulation.spatial.sim2D.marbSimulation.Konstanten.TRUE) {
                if (var1) {
                    int variable1 = StaticMethods.glVertZwischen(
                            StaticMethods.minVar(this.modus),
                            StaticMethods.maxVar(this.modus),
                            this.rand);
                   
                    string1 = " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING
                        + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable1);
                } else {
                    int nummer1 = this.rand.nextInt(255) + 1;
                    string1 = eas.miscellaneous.StaticMethods.normZahl(nummer1);
                }

                if (var2) {
                    int variable2 = StaticMethods.glVertZwischen(
                            StaticMethods.minVar(this.modus),
                            StaticMethods.maxVar(this.modus),
                            this.rand);
                   
                    string2 = " "
                        + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.EING
                        + " "
                        + eas.miscellaneous.StaticMethods.normZahl(variable2);
                } else {
                    int nummer2 = this.rand.nextInt(255) + 1;
                    string2 = eas.miscellaneous.StaticMethods.normZahl(nummer2);
                }

                neuString = aktString.substring(0, pos - 1)
                            + string1
                            + " " + eas.simulation.spatial.sim2D.marbSimulation.Konstanten.UGL + " "
                            + string2
                            + aktString.substring(pos + 2);
            }

            aktBed.setBedingung(neuString);
            return true;
        }
       
        return false;
    }
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.