Commit f7dddd35 authored by Timo Leiding's avatar Timo Leiding
Browse files

Fixed precision of simulation

parent 02310896
......@@ -254,16 +254,16 @@ public class ModelHandler {
String[] resultTxt = new String[numruns * amodel.var.length + numruns + 1];
int testsuccess = 0;
int resultC = 0;
long timeStart = System.currentTimeMillis();
for(int n = 0; n < numruns; n++) {
amodel.simulate(maxTime, numruns, output);
System.out.println("After simulation stats:");
System.out.println("Current Location: " + amodel.currLoc);
//System.out.println("After simulation stats:");
//System.out.println("Current Location: " + amodel.currLoc);
resultTxt[resultC] = ("Run " + n + " Stats");
resultC++;
for(int i = 0; i < amodel.var.length; i ++) {
System.out.println(amodel.varnames[i] + ": Variable has value: " + amodel.var[i]);
//System.out.println(amodel.varnames[i] + ": Variable has value: " + amodel.var[i]);
resultTxt[resultC] = (amodel.varnames[i] + ": Variable has value: " + amodel.var[i]);
resultC++;
......@@ -274,6 +274,8 @@ public class ModelHandler {
}
amodel.reset();
}
long timeEnd = System.currentTimeMillis() - timeStart;
System.out.println("The system took: " + timeEnd + " ms to perfom the Simulation");
if(comparetor!=null) {
System.out.println("Out of " + numruns + " Runs " + testsuccess + " Runs fullfilled the test criterium");
resultTxt[resultC] = ("Out of " + numruns + " Runs " + testsuccess + " Runs fullfilled the test criterium");
......
......@@ -44,7 +44,7 @@ public class automatonmodel {
long t = 0;
float[] deriv = loc[currLoc].getVar();
while(t < maxTime*100) {
while(t < maxTime*1000) {
// Check if invariant is hurt and choose a random invariant if there is more than one
int test = loc[currLoc].checkStatements(var);
......@@ -86,11 +86,12 @@ public class automatonmodel {
deriv = loc[currLoc].getVar();
if(output) {
System.out.println("Proceeding to location: L" + currLoc);
System.out.println(Arrays.toString(deriv));
}
}
else {
for(int j = 0; j < var.length; j++) {
var[j] += deriv[j]/100;
var[j] += deriv[j]/1000;
}
}
t++;
......@@ -121,8 +122,9 @@ public class automatonmodel {
float normal = (float)(rand.nextGaussian()*sigma + mean);
return normal;
}
if(upd[v][0] == 4) { // Uniform Distribution
return (float) Math.floor(Math.random() * (upd[v][2] - upd[v][1] + 1) + upd[v][1]);
if(upd[v][0] == 4) { // Uniform Distribution#
float rand = (float) Math.floor(Math.random() * (upd[v][2] - upd[v][1] + 1) + upd[v][1]);
return (float) rand;
}
return 1;
}
......
......@@ -425,7 +425,6 @@ public class SimulationHandler {
public void simulateAndCheckProperty(HPnGModel model, SimpleNode root, Double time, ProbabilityOperator operator, Double boundary, PrintWriter results, TrainingQLearning qClass) throws InvalidPropertyException, ModelNotReadableException, InvalidRandomVariateGeneratorException, FileNotFoundException, IOException {
final long timeStart = System.currentTimeMillis();
this.model = model;
this.root = root;
this.maxTime = PropertyChecker.getMaxTimeForSimulation(root, time);
......
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