Commit 20835c20 authored by Christoph Drodt's avatar Christoph Drodt
Browse files

added process valid check

parent 98abfb7b
# Random Log Batch Generator
This simple project uses the fantastic [PLG2](https://github.com/delas/plg) to generate completely randomized logs in batches and exports the process, the settings and the event log to a defined folder.
Using this project, you can easily generate multiple event log files.
Using this project, you can easily generate multiple event log files. You can also run/compile this program with Java 8 (Mvn -> Plugins -> exec -> exec:java), instead of simply running it.
## Setup
1. Download the PLG2 repository and compile it with maven (or put it your classpath somehow, so maven dependencies can access it).
......@@ -8,7 +8,7 @@ Using this project, you can easily generate multiple event log files.
3. Adjust the class variables according to your needs.
4. Simply run main class.
---
## FAQ
F: Everything works, until the .xes file is beeing exported:
```
......@@ -33,4 +33,8 @@ A: Make sure ``javax.xml.bind`` is in your classpath and dependencies.
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
```
\ No newline at end of file
```
---
F: Some Traces do not have events.
A: Use Java 8: https://github.com/delas/plg/issues/11
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.uniko.fgbks.randomloggenerator</groupId>
<artifactId>RandomLogs</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<groupId>de.uniko.fgbks.randomloggenerator</groupId>
<artifactId>RandomLogs</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>RandomLogs</name>
<url>http://maven.apache.org</url>
<name>RandomLogs</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>plg</groupId>
<artifactId>libPlg</artifactId>
<version>0.0.9</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>de.uniko.fgbks.randomloggenerator.GenerateRandomBatchLog</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>plg</groupId>
<artifactId>libPlg</artifactId>
<version>0.0.9</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
</project>
......@@ -3,6 +3,8 @@ package de.uniko.fgbks.randomloggenerator;
import org.deckfour.xes.model.XLog;
import org.deckfour.xes.out.XSerializer;
import org.deckfour.xes.out.XesXmlGZIPSerializer;
import org.deckfour.xes.out.XesXmlSerializer;
import plg.exceptions.InvalidProcessException;
import plg.generator.ProgressAdapter;
import plg.generator.log.SimulationConfiguration;
import plg.generator.log.noise.NoiseConfiguration;
......@@ -13,11 +15,13 @@ import plg.model.Process;
import plg.io.exporter.BPMNExporter;
import java.io.*;
import java.nio.file.Files;
import java.util.zip.GZIPOutputStream;
public class GenerateRandomBatchLog {
private static final String exportPath = "/Path/to/your/folder/"; // Define the folder where the files should be stored ("/" at the end is mandatory)
private static final String exportPath = "/Users/chris/Documents/PLGTest/"; // Define the folder where the files should be stored ("/" at the end is mandatory)
private static final int numberOfEventlogs = 150; // Define how many event logs and processes you want to generate
// PROCESS DEFINITION
......@@ -31,6 +35,7 @@ public class GenerateRandomBatchLog {
private static final double[] AndWeightRange = {0.0, 1.0};
private static final double[] XorWeightRange = {0.0, 1.0};
private static final double[] LoopWeightRange = {0.0, 1.0};
private static final double[] NoiseRange = {0.0, 0.1};
// Defines the Range of the tasks, the process should have
private static final int[] taskRange = {5, 50};
......@@ -47,7 +52,7 @@ public class GenerateRandomBatchLog {
System.out.println("========================================");
Process p;
RandomizationConfiguration config = RandomizationConfiguration.BASIC_VALUES;
boolean processIsValid;
/**
* GENERATING PROCESS
*/
......@@ -72,7 +77,17 @@ public class GenerateRandomBatchLog {
System.out.println("Failed to generate process.");
}
System.out.println("Activities: "+p.getTasks().size());
} while(p.getTasks().size() < GenerateRandomBatchLog.taskRange[0] || p.getTasks().size() > GenerateRandomBatchLog.taskRange[1]);
try {
processIsValid = p.check();
} catch (InvalidProcessException e) {
processIsValid = false;
}
if (processIsValid) {
System.out.println("Process is valid.");
} else {
System.out.println("!!!Process is invalid!!!");
}
} while(!processIsValid || (p.getTasks().size() < GenerateRandomBatchLog.taskRange[0] || p.getTasks().size() > GenerateRandomBatchLog.taskRange[1]));
String processConfig = config.toString();
int processActivities = p.getTasks().size();
......@@ -83,16 +98,17 @@ public class GenerateRandomBatchLog {
* GENERATING LOG
*/
// Noise
NoiseConfiguration nc = NoiseConfiguration.COMPLETE_NOISE;
nc.setActivityNameNoise((float)(Math.random()*(1.0-0.1+1)+0.1));
nc.setAlienEventNoise((float)(Math.random()*(1.0-0.1+1)+0.1));
nc.setDoubleEventNoise((float)(Math.random()*(1.0-0.1+1)+0.1));
nc.setIntegerDataNoise((float)(Math.random()*(1.0-0.1+1)+0.1), 1);
nc.setStringDataNoise((float)(Math.random()*(1.0-0.1+1)+0.1));
nc.setPerturbedOrderNoise((float)(Math.random()*(1.0-0.1+1)+0.1));
nc.setTraceMissingEpisodeNoise((float)(Math.random()*(1.0-0.1+1)+0.1), 1);
nc.setTraceMissingHeadNoise((float)(Math.random()*(1.0-0.1+1)+0.1), 1);
nc.setTraceMissingTailNoise((float)(Math.random()*(1.0-0.1+1)+0.1), 1);
//NoiseConfiguration nc = NoiseConfiguration.COMPLETE_NOISE;
NoiseConfiguration nc = NoiseConfiguration.ONLY_CONTROL_FLOW_NOISE;
nc.setActivityNameNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]));
nc.setAlienEventNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]));
nc.setDoubleEventNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]));
nc.setStringDataNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]));
nc.setIntegerDataNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]), 1);
nc.setPerturbedOrderNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]));
nc.setTraceMissingEpisodeNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]), 1);
nc.setTraceMissingHeadNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]), 1);
nc.setTraceMissingTailNoise((float)(Math.random()*(GenerateRandomBatchLog.NoiseRange[1]- GenerateRandomBatchLog.NoiseRange[0]+1)+ GenerateRandomBatchLog.NoiseRange[0]), 1);
String noiseConfig = nc.toString();
SimulationConfiguration sc = new SimulationConfiguration((int)(Math.random()*(GenerateRandomBatchLog.traceRange[1]- GenerateRandomBatchLog.traceRange[0]+1)+ GenerateRandomBatchLog.traceRange[0]), nc);
......@@ -131,8 +147,8 @@ public class GenerateRandomBatchLog {
FileExporter exporter = new BPMNExporter();
exporter.exportModel(p, GenerateRandomBatchLog.exportPath+processName+"-A"+processActivities+".bpmn");
System.out.println("Writing XES file: "+ GenerateRandomBatchLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz");
/*try (OutputStream out = new GZIPOutputStream(new BufferedOutputStream(Files.newOutputStream(new File(GenerateRandomLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz").toPath())))) {
/*System.out.println("Writing XES file: "+ GenerateRandomBatchLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz");
try (OutputStream out = new GZIPOutputStream(new BufferedOutputStream(Files.newOutputStream(new File(GenerateRandomBatchLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz").toPath())))) {
new XesXmlSerializer().serialize(log, out);
} catch (IOException error) {
System.out.println("Error while writing the xes log file: " + error.getMessage());
......@@ -140,10 +156,13 @@ public class GenerateRandomBatchLog {
}*/
XSerializer serializer = new XesXmlGZIPSerializer();
//XSerializer serializer = new XesXmlSerializer();
//generator.generateAndSerializeLog(serializer, new File(GenerateRandomLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz"));
serializer.serialize(log, new FileOutputStream(GenerateRandomBatchLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz"));
generator.generateAndSerializeLog(serializer, new File(GenerateRandomBatchLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz"));
//serializer.serialize(log, new FileOutputStream(GenerateRandomBatchLog.exportPath+processName+"-A"+processActivities+"-T"+logTraces+".xes.gz"));
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment