Commit 4484f64c authored by Anastasiia's avatar Anastasiia

make total amount of analysis runs a parameter + monitor time for remainder calculations

parent 559421dd
......@@ -51,6 +51,7 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
Set("affine", "interval", "smtreuse", "smtredo", "smtcomplete"), "interval"),
ParamOptionDef("divLimit", "Max amount of interval divisions", divLimit.toString),
ParamOptionDef("divRemainder", "Max amount of interval divisions for remainder term", divRemainder.toString),
ParamOptionDef("totalOpt", "Max total amount of analysis runs", totalOpt.toString),
ChoiceOptionDef("subdiv", "Method to subdivide intervals", Set("simple", "model"), "simple"),
ChoiceOptionDef("approach", "Approach for expressions", Set("taylor", "naive"), "taylor"),
// fixme change name to not overlap with RangeErrorPhase or put into Main
......@@ -74,6 +75,7 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
for (opt <- ctx.options) opt match {
case ParamOption("divLimit", value) => divLimit = value.toInt
case ParamOption("divRemainder", value) => divRemainder = value.toInt
case ParamOption("totalOpt", value) => totalOpt = value.toInt
case ChoiceOption("rel-rangeMethod", s) => s match {
case "interval" | "affine" | "smtreuse" | "smtredo" | "smtcomplete" =>
rangeMethod = s
......@@ -122,7 +124,7 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
for (delta <- deltas){
deltaIntervalMap = deltaIntervalMap + (delta.id -> delta.interval)
}
val eps = epsilonsOf(relErrorExpr); //reporter.warning("epsilons: " + eps)
val eps = epsilonsOf(relErrorExpr)
for (e <- eps){
deltaIntervalMap = deltaIntervalMap + (e.id -> e.interval)
}
......@@ -194,7 +196,7 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
// output subintervals without deltas
for (entry <- newSet){
reporter.debug("============================================")
for (mapEntry <- entry if (!(mapEntry._1.isDeltaId|| mapEntry._1.isEpsilonId)))
for (mapEntry <- entry if !(mapEntry._1.isDeltaId|| mapEntry._1.isEpsilonId))
reporter.debug(mapEntry._1 + " -> " + mapEntry._2)
}
reporter.debug(s"We need to evaluate expression on "+newSet.size+" intervals")
......@@ -204,11 +206,12 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
// taylorFirst.foreach(x=>{reporter.debug(s"term is $x")})
reporter.info("Computing the error ...")
// fixme for div-by-zero benchmarks subdivision parameter should be greater than 0
reporter.info(s"subdiv for remainder $divRemainder")
// separate timer for remainder
val remainderTime = System.currentTimeMillis
val remainderMap = getEqualSubintervals(inputValMap, divLimit, divRemainder)
val taylorRemainder = getTaylorRemainder(relErrorExpr, remainderMap)
reporter.info(s"The taylor remainder value is $taylorRemainder")
reporter.info(s"The taylor remainder value is $taylorRemainder, time: " + (System.currentTimeMillis - remainderTime))
if (taylorRemainder.isDefined) {
val errForSum = taylorFirst.map(x => {
val (expr, wrt) = x
......@@ -218,10 +221,10 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
// do not call evaluation function on all subintervals
// if simplified expression is delta or RealLiteral
val tmpForMax = tmpExpr match {
case x@Delta(id) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case x@Epsilon(id) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case x@Variable(id) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case x@RealLiteral(r) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case x @ Delta(id) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case x @ Epsilon(id) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case x @ Variable(id) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case x @ RealLiteral(r) => List(evaluateOpt(tmpExpr, inputValMap, rangeMethod))
case _ => newSet.map(interval => {
val tmp = evaluateOpt(tmpExpr, interval, rangeMethod)
reporter.debug("err on " + removeDeltasFromMap(interval) + s" is $tmp")
......@@ -504,7 +507,6 @@ object RelativeErrorPhase extends DaisyPhase with Subdivision with ErrorFunction
val (id, interval) = iterator.next()
if (!(id.isDeltaId|| id.isEpsilonId)) {
tmp = compareIntervals(interval, second(id))
}
}
tmp <= 0
......
......@@ -16,8 +16,7 @@ import scala.collection.immutable.Map
trait Subdivision extends Taylor{
//TODO make a parameter
implicit val subdivFirst: Int = 32
var totalOpt: Int = 32
def getSubintervals(inputValMap: Map[Identifier, Interval],
bodyReal: Expr,
......@@ -50,7 +49,7 @@ trait Subdivision extends Taylor{
reporter.debug(model)
model match {
case Some(tmp) =>
reporter.warning(s"true zeros detected at $model")
reporter.debug(s"true zeros detected at $model")
val exprs: Map[Identifier, Expr] = variablesOf(bodyReal).map(id => {(id -> model.get(id))}).toMap
reporter.debug(s"Model expressions are $exprs")
val values: Map[Identifier, Interval] = exprs.map(expr =>
......@@ -82,12 +81,12 @@ trait Subdivision extends Taylor{
var subdivided = 0
var left = removeDeltasFromMap(inputValMap).keys.size - 1
var counter = 0
reporter.warning(s"amount of vars is "+(left+1))
reporter.info(s"amount of vars is "+(left+1))
// set of vectors. each vector contains the maps for one var
for (inputVal <- inputSeq) {
counter = Math.pow(split, subdivided + 1).toInt + left
// reporter.warning(s"counter $counter")
if (inputVal._1.isDeltaId || inputVal._1.isEpsilonId || counter > subdivFirst) {
if (inputVal._1.isDeltaId || inputVal._1.isEpsilonId || counter > totalOpt) {
srcCartesian += (inputVal._1 -> Seq(inputVal._2))
left = left - 1
}
......
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