src/main/java/Parser.java
public static void saveModel(List<FptaNode> red, ModelType modelType, String saveLocation) {
        FileWriter fw;
        try {
            fw = new FileWriter(saveLocation + ".dot");
            fw.write("digraph g {\n");
            for (FptaNode r: red) {
                if(modelType != ModelType.SMM)
                    fw.write(r.stateId + " [shape=\"circle\",label=\"" + r.output + "\"];\n");
                else
                    fw.write(r.stateId + " [shape=\"circle\",label=\"" + r.stateId + "\"];\n");
            }
            for (FptaNode r: red)
                for (String io : r.children.keySet()) {
                    if(modelType == ModelType.MC){
                        fw.write(r.stateId + "->" + r.children.get(io).stateId + " [label=\"" +
                                r.childrenProbability.get(io) + "\"];\n");
                    }
                    if(modelType == ModelType.MDP){
                        List<String> inputAndOutput = Arrays.asList(io.split("/"));
                        fw.write(r.stateId + "->" + r.children.get(io).stateId + " [label=\"" +
                                inputAndOutput.get(0) + ":" + r.childrenProbability.get(io) + "\"];\n");
                    }
                    if(modelType == ModelType.SMM){
                        fw.write(r.stateId + "->" + r.children.get(io).stateId + " [label=\"" +
                                io + ":" + r.childrenProbability.get(io) + "\"];\n");
                    }
                }
            fw.write("__start0 [label=\"\" shape=\"none\"];\n");
            fw.write("__start0 -> q0  [label=\"\"];\n");
            fw.write("}\n");
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
/**
     * Saves learned model in .dot format. Learned models can be visualized with graphviz and used with AALpy.
     * @param red Model states
     * @param modelType either mdp, smm, or mc
     * @param saveLocation file name
     */
Saves learned model in .dot format. Learned models can be visualized with graphviz and used with AALpy.
@param red Model states
@param modelType either mdp, smm, or mc
@param saveLocation file name
Saves learned model in . dot format . Learned models can be visualized with graphviz and used with AALpy . @param red Model states @param modelType either mdp smm or mc @param saveLocation file name
public static void saveModel(List<FptaNode> red, ModelType modelType, String saveLocation) {
        FileWriter fw;
        try {
            fw = new FileWriter(saveLocation + ".dot");
            fw.write("digraph g {\n");
            for (FptaNode r: red) {
                if(modelType != ModelType.SMM)
                    fw.write(r.stateId + " [shape=\"circle\",label=\"" + r.output + "\"];\n");
                else
                    fw.write(r.stateId + " [shape=\"circle\",label=\"" + r.stateId + "\"];\n");
            }
            for (FptaNode r: red)
                for (String io : r.children.keySet()) {
                    if(modelType == ModelType.MC){
                        fw.write(r.stateId + "->" + r.children.get(io).stateId + " [label=\"" +
                                r.childrenProbability.get(io) + "\"];\n");
                    }
                    if(modelType == ModelType.MDP){
                        List<String> inputAndOutput = Arrays.asList(io.split("/"));
                        fw.write(r.stateId + "->" + r.children.get(io).stateId + " [label=\"" +
                                inputAndOutput.get(0) + ":" + r.childrenProbability.get(io) + "\"];\n");
                    }
                    if(modelType == ModelType.SMM){
                        fw.write(r.stateId + "->" + r.children.get(io).stateId + " [label=\"" +
                                io + ":" + r.childrenProbability.get(io) + "\"];\n");
                    }
                }
            fw.write("__start0 [label=\"\" shape=\"none\"];\n");
            fw.write("__start0 -> q0  [label=\"\"];\n");
            fw.write("}\n");
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public static void saveModel ( List < FptaNode > red , ModelType modelType , String saveLocation ) { FileWriter fw ; try { fw = new FileWriter ( saveLocation + ".dot" ) ; fw . write ( "digraph g {\n" ) ; for ( FptaNode r : red ) { if ( modelType != ModelType . SMM ) fw . write ( r . stateId + " [shape=\"circle\",label=\"" + r . output + "\"];\n" ) ; else fw . write ( r . stateId + " [shape=\"circle\",label=\"" + r . stateId + "\"];\n" ) ; } for ( FptaNode r : red ) for ( String io : r . children . keySet ( ) ) { if ( modelType == ModelType . MC ) { fw . write ( r . stateId + "->" + r . children . get ( io ) . stateId + " [label=\"" + r . childrenProbability . get ( io ) + "\"];\n" ) ; } if ( modelType == ModelType . MDP ) { List < String > inputAndOutput = Arrays . asList ( io . split ( "/" ) ) ; fw . write ( r . stateId + "->" + r . children . get ( io ) . stateId + " [label=\"" + inputAndOutput . get ( 0 ) + ":" + r . childrenProbability . get ( io ) + "\"];\n" ) ; } if ( modelType == ModelType . SMM ) { fw . write ( r . stateId + "->" + r . children . get ( io ) . stateId + " [label=\"" + io + ":" + r . childrenProbability . get ( io ) + "\"];\n" ) ; } } fw . write ( "__start0 [label=\"\" shape=\"none\"];\n" ) ; fw . write ( "__start0 -> q0  [label=\"\"];\n" ) ; fw . write ( "}\n" ) ; fw . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Saves learned model in .dot format.
Saves learned model in . dot format .