Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ag-sks
Tools
HYPEG
Commits
f7dddd35
Commit
f7dddd35
authored
Dec 01, 2022
by
Timo Leiding
Browse files
Fixed precision of simulation
parent
02310896
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/wwu/criticalsystems/libhpng/Main/ModelHandler.java
View file @
f7dddd35
...
...
@@ -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"
);
...
...
src/main/java/de/wwu/criticalsystems/libhpng/automatonmodel/automatonmodel.java
View file @
f7dddd35
...
...
@@ -44,7 +44,7 @@ public class automatonmodel {
long
t
=
0
;
float
[]
deriv
=
loc
[
currLoc
].
getVar
();
while
(
t
<
maxTime
*
100
)
{
while
(
t
<
maxTime
*
100
0
)
{
// 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
]/
100
0
;
}
}
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
;
}
...
...
src/main/java/de/wwu/criticalsystems/libhpng/simulation/SimulationHandler.java
View file @
f7dddd35
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment