To prevent spam users, you can only post on this forum after registration, which is by invitation. If you want to post on the forum, please send me a mail (h DOT m DOT w DOT verbeek AT tue DOT nl) and I'll send you an invitation in return for an account.

How to automatically generate the Petri net model using inductive miner?

Dear all,

I am using ProM 6.6 for my process analysis tasks (Petri net model and decision rules and trace variants generation). Now, I want to automate the generation of the Petri net model from the XES log using Java (the petri net model is generated using the inductive miner). So, using the rapidprom and the openXES jars, I wrote the code:

public class PetriNetGenerationAutomationClass {

public static void main(String[] args) throws FileNotFoundException, Exception {
//loading the xes file
String xesFilePath = "C:\\TraceVariantTest\\runningExample.xes";
File file = new File(xesFilePath);
String outputPNMLFilePath = "W:\\TraceVariantTest\\OutputPNML";
File outputPNMLFile = new File(xesFilePath);

XLog myXesLog = XUtils .loadLog(file);
System.out.println("myXESLog is succesfully read! \n");

//here, I want to load the default parameters ("variant=Inductive Miner (IM)" and "Event classifier=concept:name" as in proM 6.6)
XEventClassifier classifier = MiningParameters.getDefaultClassifier();
MiningParameters parameters = new org.processmining.plugins.InductiveMiner.mining.MiningParametersIMi();

Object[] object = IMPetriNet.minePetriNet(myXesLog, parameters); //I don't understand why am I having an object[] here, but I assume the petri net model is the first element
Petrinet petriNetModel = (Petrinet) object[0];
PetriNetFileFormat format = PetriNetFileFormat.PNML;

//Export the petri net model in pnml format
writeToFile(outputPNMLFile, petriNetModel, format); //of the ExportPetriNetOperator class
}

\\To avoid the error "The method writeToFile(File, Petrinet, PetriNetFileFormat) is undefined for the type PetriNetGenerationAutomationClass" I copied and pasted the function in my code

static void writeToFile(File file, Petrinet object, PetriNetFileFormat format) throws IOException {
switch (format) {
case EPNML:
PnmlExportNetToEPNML exporterEPNML = new PnmlExportNetToEPNML();
exporterEPNML.exportPetriNetToEPNMLFile(RapidProMGlobalContext.instance().getPluginContext(), object, file);
break;
case PNML:
default:
PnmlExportNetToPNML exporterPNML = new PnmlExportNetToPNML();
exporterPNML.exportPetriNetToPNMLFile(RapidProMGlobalContext.instance().getPluginContext(), object, file);
break;
}
}

}


The code above is generating a NullPointerException error, caused by the "writeToFile". Is there any other solutions allowing us to export the petri net model in pnml format? are the mining parameters specified correctly?

I appreciate your feedback,
Regards,
Widad

Widad Es-Soufi

PhD Student

“Decision-making support in the context of systems design and supervision”

Arts et Métiers ParisTech. France.






Comments

  • hverbeekhverbeek Posts: 383
    Dear Widad,

    Can you provide us with a stack trace showing the NullPointerException? That may give some clue to what went wrong.

    The problem may not be in the exporter.

    Kind regards,

    Eric.
  • WidadEs-SoufiWidadEs-Soufi Posts: 15
    edited November 2018
    Dear Eric,

    Please find below the stack trace:

    java.lang.NullPointerException
    at PetriNetGenerationAutomationClass.writeToFile(PetriNetGenerationAutomationClass.java:114)
    at PetriNetGenerationAutomationClass.main(PetriNetGenerationAutomationClass.java:92)


    This error is on:
    Line 92: writeToFile(outputPNMLFile, petriNetModel, format);
    Line 114: exporterPNML.exportPetriNetToPNMLFile(RapidProMGlobalContext.instance().getPluginContext(), object, file);
    break;

    Appreciate your feedback,
    Best,
    Widad

    Post edited by WidadEs-Soufi on

    Widad Es-Soufi

    PhD Student

    “Decision-making support in the context of systems design and supervision”

    Arts et Métiers ParisTech. France.






  • I think that the NullPointerException comes from the "RapidProMGlobalContext.instance().getPluginContext()" of the
    exportPetriNetToPNMLOrEPNMLFile(RapidProMGlobalContext.instance().getPluginContext(), petriNetModel, outputPNMLFile, type);

    Indeed, I tried to print the content of all the parameters, I successfully got the:
    - node list of the generated petri net, 
    - path of the output pnml file (that I specified in top of the code)
    - type name (pnml)

    But when it comes to printing the "RapidProMGlobalContext.instance().getPluginContext().getLabel()", I get the java.lang.NullPointerException

    This means that there is actually no plugin context.
    Do you have any idea how to get the right context?

    Thank you!
    Best,
    Widad

    Widad Es-Soufi

    PhD Student

    “Decision-making support in the context of systems design and supervision”

    Arts et Métiers ParisTech. France.






  • hverbeekhverbeek Posts: 383
    Dear Widad,

    Perhaps you can use the solution as mentioned on http://www.win.tue.nl/promforum/discussion/comment/657/#Comment_657? There, the poster creates a CLIPluginContext using two lines of code, and uses that context.

    Kind regards,

    Eric.

  • WidadEs-SoufiWidadEs-Soufi Posts: 15
    edited November 2018
    Dear Eric,
    Thank you for the link. I pasted these two lines in my code:

    CLIContext context = new CLIContext();
    CLIPluginContext pluginContext = new CLIPluginContext(context, "test");
    exporterPNML.exportPetriNetToPNMLFile(pluginContext, petriNetModel, outputPNMLFile);

    Where "petriNetModel" is the petri net model and the "outputPNMLFile" is the output file, but I still get the same error. 


    Thank you,
    Best,
    Widad

    Post edited by WidadEs-Soufi on

    Widad Es-Soufi

    PhD Student

    “Decision-making support in the context of systems design and supervision”

    Arts et Métiers ParisTech. France.






  • hverbeekhverbeek Posts: 383
    Dear Widad,

    This stack trace indicates that there is a problem with the exporter. What I do not understand is why the exporter throws a NPE at line 147 of PnmlInscription, as this line is inside of a try block that comes with a catch for any Exception. The NPE should have been caught and dealt with.

    Kind regards,

    Eric.
  • Is there another way to export the "Petrinet petriNetModel" ? or to transform it into a document so that I can export it using the PNML  framework in eclipse?

    Thank you,
    Best regards,
    Widad

    Widad Es-Soufi

    PhD Student

    “Decision-making support in the context of systems design and supervision”

    Arts et Métiers ParisTech. France.






  • hverbeekhverbeek Posts: 383
    Dear Wadid,

    Perhaps better to try to use the ProM Nightly Build (see http://www.promtools.org/doku.php?id=nightly) instead of ProM 6.6. This way, the sources we're working on match the ones you are using, and we can fix them more easily. There's no use for us to try to fix an older release which uses older source files.

    There is no other export available that I know of that may result in a PNML file, except perhaps for the BPMN export. But then you would need to convert the Petir net into a BPMNmodel first, export that one, and then convert the BPMN file into a PNML file by some means.

    Kind regards,

    Eric.

  • Dear Eric,

    I think I found a solution to get the Petri net model from an XES log using the command line based on the solution proposed here. The problem now is that I want to change the mining parameters (org.processmining.plugins.InductiveMiner.mining.MiningParametersIMi parameters = new org.processmining.plugins.InductiveMiner.mining.MiningParametersIMi();) in particular, the Variant (change it from "Inductive Miner - infrequent (IMF)" (Figure 1) to "inductive Miner (IM)" (Figure 2)), is this possible?

    Thanks,
    Best,
    Widad



    2.PNG 50.3K
    1.PNG 52.3K

    Widad Es-Soufi

    PhD Student

    “Decision-making support in the context of systems design and supervision”

    Arts et Métiers ParisTech. France.






  • hverbeekhverbeek Posts: 383
    Dear Wadid,

    Yes, that should be possible.

    Given that you want to call the "IM" variant, I would create the mining parameters differently:
    org.processmining.plugins.InductiveMiner.mining.MiningParameters parameters = new org.processmining.plugins.InductiveMiner.mining.MiningParametersIM(); 
    This creates the default parameters for the variant you want to use. You could then call:
    mine_petri_net_with_inductive_miner__with_parameters(log, parameters);
    (I'm not too sure about the double underscores between "miner" and "with", perhaps there need to be only one, please check.)

    As before, the result will be an array containing the following objects (in the given order):
    • the Petri net discovered,
    • the initial marking for this Petri net, and
    • the final marking for this Petri net.
    However, I'm not sure this will solve your problem. I still fail to understand why code that is in a proper try-catch block throws unhandled exceptions. But one never knows...

    Kind regards,

    Eric.




Sign In or Register to comment.