Package eas.startSetup.marbBuilder.graph

Examples of eas.startSetup.marbBuilder.graph.Knoten


       
        gv.addln("node [shape = ellipse];");
       
        for (int kname1 : aut.getKnList()) {
            // Knoten.
            Knoten k1 = aut.holeKnoten(kname1);
           
            if (aut.holeStartzustand() == null || aut.holeStartzustand().holeName() != kname1) {
                gv.addln("node"
                        + kname1
                        + " [label=\""
                        + k1.getKnotenBeschriftungForGraphviz(params)
                        + "\"];");
            }
           
            // Kanten.
            int i = 0;
            for (Transition t : k1.getInfo().getBedingungen()) {
                i++;
                Knoten k2 = aut.holeKnoten(t.getFolgezustand());
                gv.addln("\"node" + k1.holeName() + "\" -> \"node" + k2.holeName() + "\" [label=\"(" + i + ") " + t.getCond() + "\"];");
            }
        }
       
        gv.addln(gv.endGraph());
        return gv;
View Full Code Here


        DargestellterGraph darstellung = new DargestellterGraph(null);
        Iterator<Knoten> it;
        Iterator<Knoten> it1;
        Iterator<Integer> it2;
        Iterator<Transition> it3;
        Knoten knot;
        Knoten knot1;
        Knoten knot2;
        Vector2D koord1;
        Vector2D koord2;

        if (!g.istLeer()) {
            final ArrayList<Knoten> knotenListe
                = new ArrayList<Knoten>(g.holAdj().values());
            int knAnzahl = knotenListe.size();
           
            if (knAnzahl < 2) {
                knAnzahl = 2;
            }
           
            int gitterX = Math.abs(this.rechts - this.links)
                          / (int) ((Math.ceil(Math.sqrt(knAnzahl))) - 1);
            int gitterY = Math.abs(this.unten - this.oben)
                          / (int) ((Math.ceil(Math.sqrt(knAnzahl))) - 1);

            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 Vector2D(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 = it1.next();
                koord1 = this.gesetzteKn.get(knot1.holeName());

                it2 = (new ArrayList<Integer>(
                                knot1.holeNachfolger().keySet())).iterator();
                while (it2.hasNext()) {
                    boolean gebogen = true;
                   
                    knot2 = g.holeKnoten(it2.next());
                    koord2 = this.gesetzteKn.get(knot2.holeName());
                    Condition cond
                        = knot1.getInfo().getTransZuZustand(
                                knot2.holeName()).get(0).getCond();
                    double staerke = StaticMethods.condStrength(cond,
                                                   ConstantsDarstellung.STAERKE_ERST,
                                                   ConstantsDarstellung.STAERKE_ZWEIT);
                   
                    if (koord1.distance(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 = it1.next();
                koord1 = this.gesetzteKn.get(knot1.holeName());

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

                    if (koord1.equals(koord2)) {
View Full Code Here

                                        final double radius) {
        final ArrayList<Knoten> knotenListe = new ArrayList<Knoten>();
        final ArrayList<Point> koordListe = new ArrayList<Point>();
        final ArrayList<Knoten> endListe = new ArrayList<Knoten>();
        Point             aktPunkt;
        Knoten            aktObj;
        Iterator<Point>   itKoord;
        Iterator<Knoten>  itObj;
        double            minAbs = Double.MAX_VALUE;
        double            aktAbs;
        final double      dX = x;
View Full Code Here

                                           final int x2,
                                           final int y2) {

        final ArrayList<Knoten>  knotenListe = new ArrayList<Knoten>();
        Point                    aktPunkt;
        Knoten                   aktObj;
        final Iterator<Point>    itKoord;
        final Iterator<Knoten>   itObj;

        itKoord = this.knotenpunktKoord.iterator();
        itObj   = this.knotenpunktObjekte.iterator();
View Full Code Here

     * @param ea  Der zu mutierende Automat.
     * @return  Ob ein Zustand gelöscht wurde.
     */
    public final boolean mutationZustandRem1(final EndlicherAutomat ea) {
        ArrayList<Integer> knListe = ea.getKnList();
        Knoten zufallsKnoten1;
        int zufallsIndex;

        while (knListe.size() > 0) {
            zufallsIndex = this.rand.nextInt(knListe.size());
            zufallsKnoten1 = ea.holeKnoten(knListe.get(zufallsIndex));
            if (!ea.istStartZ(zufallsKnoten1)
                && zufallsKnoten1.holeVorgaenger().size() == 0) {
               
                ea.entferneKnoten(knListe.get(zufallsIndex));
                return true;
            }
            knListe.remove(zufallsIndex);
View Full Code Here

     * @param ea  Der zu mutierende Automat.
     * @return  Ob ein Zustand mutiert wurde.
     */
    public final boolean mutationZustand(final EndlicherAutomat ea) {
        ArrayList<Integer> knListe = ea.getKnList();
        Knoten zufallsKnoten1;
        int veraenderung;
        int neuParam;
        int altParam;
        int neuBefehl;
        int zufallsIndex;
       
        if (knListe.size() == 0) {
            return false;
        } else {
            zufallsIndex = this.rand.nextInt(knListe.size());
            zufallsKnoten1 = ea.holeKnoten(knListe.get(zufallsIndex));
            veraenderung = this.rand.nextInt(2 * this.k) - this.k;
            altParam = zufallsKnoten1.getInfo().getParam();
            if (veraenderung + altParam > 0) {
                neuParam = altParam + veraenderung;
                neuBefehl = zufallsKnoten1.getInfo().getAktion();
            } else if (veraenderung + altParam < 0) {
                neuParam = (veraenderung + altParam) * -1;
                neuBefehl = StaticMethods.glVertZwischen(
                        1,
                        this.numAgentActuators,
                        this.rand);
               
            } else { // veraenderung + altparam == 0
                neuParam = 1;
                neuBefehl = zufallsKnoten1.getInfo().getAktion();
            }
               
           
            zufallsKnoten1.getInfo().setAkt(neuBefehl);
            zufallsKnoten1.getInfo().setPar(neuParam);
           
            return true;
        }
    }
View Full Code Here

       
        final EndlicherAutomat anderer = (EndlicherAutomat) obj;
       
        HashSet<Integer> s1 = new HashSet<Integer>();
        HashSet<Integer> s2 = new HashSet<Integer>();
        Knoten k2;
       
        s1.addAll(this.getAdjazenzliste().keySet());
        s2.addAll(anderer.getAdjazenzliste().keySet());
       
        // überprüfe vorhandene Knotennamen in Automaten.
        if (!s1.equals(s2)) {
            return false;
        }
       
        // überprüfe für jeden Knoten: Info und Nachfolger der Knoten.
        for (Knoten k : this.getAdjazenzliste().values()) {
            k2 = anderer.holeKnoten(k.holeName());
            s1.clear();
            s2.clear();
            s1.addAll(k.holeNachfolger().keySet());
            s2.addAll(k2.holeNachfolger().keySet());
           
            if (!s1.equals(s2)
                    || !k.getInfo().equals(k2.getInfo())) {
                return false;
            }
        }
       
        return true;
View Full Code Here

     *
     * @param alt  Der alte Name des Knotens.
     * @param neu  Der neue Name des Knotens.
     */
    public void knUmbenennen(final int alt, final int neu) {
        Knoten altK = this.holeKnoten(alt);
        LinkedList<Transition>outgoingTrans = altK.getInfo().getBedingungen();
        HashMap<Integer, Knoten> vorgaenger;
        boolean isStart;
       
//        if (altK == null) {
//            throw new RuntimeException("Knoten " + alt + " nicht vorhanden."
//                    + " Umbennenen nicht möglich.");
//        }

        if (this.holeKnoten(neu) != null) {
            throw new RuntimeException("Knoten " + neu + " existiert bereits."
                    + " Umbennenen nicht möglich.");
        }       
        vorgaenger = altK.holeVorgaenger();
        isStart = this.istStartZ(altK);
        altK.setName(neu);
        HashMap<Integer, Knoten> adj = this.getAdjazenzliste();
        adj.remove(alt);
        adj.put(neu, altK);

        for (Knoten vorg : vorgaenger.values()) {
View Full Code Here

     *
     * @return  The OLD state of the automaton, i.e., BEFORE the state change.
     */
    public Knoten step(final AbstractAgent<?> agent, int[] sens) {
        ZInfo nodeInformation;
        Knoten oldState = this.getCurrentState();
        LinkedList<Transition> transitions;
        Iterator<Transition> itTrans;
        int folgeZ = 0;
        Transition currentTrans;

View Full Code Here

     * @param ea  Der zu mutierende Automat.
     * @return  Ob ein Zustand gelöscht wurde.
     */
    public final boolean ageSynMutZustandRem1(final EndlicherAutomat ea) {
        ArrayList<Integer> knListe = ea.getKnList();
        Knoten zufallsKnoten1;
        int zufallsIndex;

        while (knListe.size() > 0) {
            zufallsIndex = this.rand.nextInt(knListe.size());
            zufallsKnoten1 = ea.holeKnoten(knListe.get(zufallsIndex));
            if (!ea.istStartZ(zufallsKnoten1)
                    && zufallsKnoten1.holeVorgaenger().size() == 0) {
                Integer index = knListe.get(zufallsIndex);
                ea.entferneKnoten(index);
                return true;
            }
            knListe.remove(zufallsIndex);
View Full Code Here

TOP

Related Classes of eas.startSetup.marbBuilder.graph.Knoten

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.