Commit e95a69f4 authored by Simon Trapp's avatar Simon Trapp

Added relative path WEKA functionality

parent db709f4d
......@@ -76,6 +76,7 @@ import de.tud.cs.simqpn.kernel.monitor.SimulatorProgress;
public class SimQPN implements IApplication {
public static long runtime;
private static File qpeFile = null;
public static void main(String[] args) {
startSimQPNWithCommandLine(args);
......@@ -100,10 +101,14 @@ public class SimQPN implements IApplication {
}
}
public static File getQPEFile() {
return qpeFile;
}
private static void runSimulatorOnDocument(Document netDocument,
String configurationName, String outputFilename, String logConfigFilename, SimulatorProgress progress, Date date) throws SimQPNException {
Element net = netDocument.getRootElement();
SimQPNController sim = SimQPNController.createSimQPNController(net, configurationName, logConfigFilename, date);
SimQPNController sim = SimQPNController.createSimQPNController(net, configurationName, logConfigFilename, date);
long tic = System.currentTimeMillis();
sim.execute(configurationName, outputFilename, progress);
long toc = System.currentTimeMillis();
......@@ -129,6 +134,7 @@ public class SimQPN implements IApplication {
} catch(URISyntaxException ex) {
xmlFile = new File(path);
}
qpeFile = xmlFile;
SAXReader xmlReader = new SAXReader();
return xmlReader.read(xmlFile);
}
......
......@@ -44,18 +44,28 @@ package de.tud.cs.simqpn.kernel.loading.distributions;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.nio.file.Paths;
import de.tud.cs.simqpn.kernel.SimQPNException;
import de.tud.cs.simqpn.kernel.console.SimQPN;
import weka.classifiers.Classifier;
public class WEKACreator extends DistributionCreator {
String wekaFilename;
Classifier wekaModel;
private String wekaFilename;
private Classifier wekaModel;
@Override
protected void loadParams() throws SimQPNException {
wekaFilename = this.loadStringParam("wekaFile");
if (!Paths.get(wekaFilename).isAbsolute()) { // if not absolute filepath -> switch to DML environment mode
// switch from "DQL-Queries/results/" to "DML-Model/StatisticalModels/" folders
// treats wekaFile parameter as sole filename
wekaFilename = SimQPN.getQPEFile().getParentFile().getParentFile().getParent()
+ SimQPN.getQPEFile().separatorChar + "DML-Model"
+ SimQPN.getQPEFile().separatorChar + "StatisticalModels" + SimQPN.getQPEFile().separatorChar
+ wekaFilename;
}
try {
FileInputStream fis = new FileInputStream(wekaFilename);
ObjectInputStream ois = new ObjectInputStream(fis);
......@@ -63,7 +73,8 @@ public class WEKACreator extends DistributionCreator {
ois.close();
fis.close();
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
throw new IllegalStateException(
"WEKA model with file path " + wekaFilename + " not found or wrong format!");
}
}
......
Markdown is supported
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