-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gidon Ernst
committed
May 11, 2021
1 parent
335221d
commit 9f5bdc3
Showing
16 changed files
with
437 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import mill._ | ||
import mill.scalalib._ | ||
|
||
object falstar extends ScalaModule { | ||
def scalaVersion = "2.12.13" | ||
def mainClass = Some("falstar.Main") | ||
|
||
def ivyDeps = Agg( | ||
ivy"org.apache.commons:commons-csv:1.8") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
#!/bin/sh | ||
|
||
HERE=`dirname "$0"` | ||
|
||
source ~/.falstar/matlab | ||
export LD_LIBRARY_PATH="$MATLABROOT/bin/glnxa64:$MATLABROOT/sys/os/glnxa64" | ||
|
||
CP="$MATLABROOT/java/jar/mvm.jar:$MATLABROOT/java/jar/javaenginecore.jar:$MATLABROOT/java/jar/matlab.jar:$MATLABROOT/java/jar/engine.jar:$MATLABROOT/java/jar/util.jar:$MATLABROOT/java/jar/capabilities.jar" | ||
|
||
./scala-2.12.13/bin/scala -cp "$CP:$HERE/falstar.jar" $@ | ||
source $HERE/falstar-config.sh | ||
scala -cp "$MATLABJARS:$HERE/falstar.jar" $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
#!/bin/sh | ||
|
||
HERE=`dirname "$0"` | ||
|
||
source ~/.falstar/matlab | ||
export LD_LIBRARY_PATH="$MATLABROOT/bin/glnxa64:$MATLABROOT/sys/os/glnxa64" | ||
|
||
CP="$MATLABROOT/java/jar/mvm.jar:$MATLABROOT/java/jar/javaenginecore.jar:$MATLABROOT/java/jar/matlab.jar:$MATLABROOT/java/jar/engine.jar:$MATLABROOT/java/jar/util.jar:$MATLABROOT/java/jar/capabilities.jar" | ||
|
||
./scala-2.12.13/bin/scala -cp "$CP:$HERE/falstar.jar" falstar.util.Matlab $@ | ||
source $HERE/falstar-config.sh | ||
java -cp "$MATLABJARS:$HERE/falstar.jar" falstar.util.Matlab $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
#!/bin/sh | ||
|
||
HERE=`dirname "$0"` | ||
|
||
source $HERE/falstar-config.sh | ||
|
||
export LD_LIBRARY_PATH="$MATLABROOT/bin/glnxa64:$MATLABROOT/sys/os/glnxa64" | ||
|
||
CP="$MATLABROOT/java/jar/mvm.jar:$MATLABROOT/java/jar/javaenginecore.jar:$MATLABROOT/java/jar/matlab.jar:$MATLABROOT/java/jar/engine.jar:$MATLABROOT/java/jar/util.jar:$MATLABROOT/java/jar/capabilities.jar" | ||
|
||
java -cp "$CP:$HERE/falstar.jar" falstar.Main $@ | ||
java -cp "$MATLABJARS:$HERE/falstar.jar" falstar.Main $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package falstar.falsification | ||
|
||
import scala.collection.mutable | ||
|
||
import falstar.util.Row | ||
import falstar.util.Table | ||
import falstar.hybrid.Config | ||
import falstar.mtl.Formula | ||
import falstar.mtl.Robustness | ||
import falstar.hybrid.System | ||
import falstar.parser.Parser | ||
import falstar.hybrid.Signal | ||
import falstar.linear.Vector | ||
|
||
object Validation { | ||
def check(ok: Boolean) = { | ||
if(ok) "yes" else "no" | ||
} | ||
|
||
def apply(table: Table, parser: Parser): Seq[Row] = { | ||
for(row <- table.rows) yield { | ||
val res = apply(row, parser) | ||
print(".") | ||
res | ||
} | ||
} | ||
|
||
def apply(row: Row, parser: Parser): Row = { | ||
val data = row.data.toMap.asInstanceOf[Map[String,String]] | ||
|
||
val system = data("system") | ||
val state = parser.state | ||
val (sys, cfg) = state.systems(system) | ||
|
||
val property = data("property") | ||
// need to unpack one layer because it reads a sequence of nodes | ||
val falstar.parser.Node(node) = falstar.parser.read(property) | ||
state.system = sys // such that ports and stuff work | ||
val phi = parser.formula(node) | ||
val T = phi.T | ||
|
||
val res = mutable.Buffer[(String, Any)]() | ||
|
||
res += "system" -> system | ||
res += "property" -> property | ||
res += "formula" -> phi | ||
|
||
if(data contains "input") { | ||
val ps = Vector.parse(data.getOrElse("parameters", "[]")) | ||
val us = Signal.parse(data("input")) | ||
// res += "input" -> input | ||
|
||
val pr = cfg.pn(sys.params) | ||
res += "parameters valid" -> check(pr contains ps) | ||
|
||
val ur = cfg.in(sys.inputs) | ||
res += "inputs valid" -> check(us forall { case (t, x) => ur contains x }) | ||
|
||
val tr = sys.sim(ps, us, T) | ||
val rs = Robustness(phi, tr.us, tr.ys) | ||
|
||
if(data contains "falsified") { | ||
val expected = data("falsified") | ||
res += "falsified correct" -> check(expected == check(rs.score < 0)) | ||
} | ||
|
||
if(data contains "robustness") { | ||
val expected = data("robustness").toDouble | ||
val computed = rs.score | ||
val error = Math.abs(expected - computed) | ||
res += "robustness correct" -> check((expected < 0) == (computed < 0)) | ||
res += "robustness error" -> error | ||
} | ||
|
||
if(data contains "output") { | ||
val ys = Signal.parse(data("output")) | ||
} | ||
} | ||
|
||
Row(res) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.