-
Etienne Kneuss authored
Solvers are no longer distinguished in 20 traits depending on what they implement. It turns out that most leon solvers already implemented everything: 1) Being interrupted 2) Push / Pop 3) checkAssertions/getUnsatCore (a naive implementation of these can be added by mixing NaiveAssumptionSolver in)
Etienne Kneuss authoredSolvers are no longer distinguished in 20 traits depending on what they implement. It turns out that most leon solvers already implemented everything: 1) Being interrupted 2) Push / Pop 3) checkAssertions/getUnsatCore (a naive implementation of these can be added by mixing NaiveAssumptionSolver in)
TimeoutSolver.scala 972 B
/* Copyright 2009-2015 EPFL, Lausanne */
package leon
package solvers
import utils._
import purescala.Expressions.Expr
import scala.concurrent.duration._
trait TimeoutSolver extends Solver {
val ti = new TimeoutFor(this)
var optTimeout: Option[Long] = None
def setTimeout(timeout: Long): this.type = {
optTimeout = Some(timeout)
this
}
def setTimeout(timeout: Duration): this.type = {
optTimeout = Some(timeout.toMillis)
this
}
abstract override def check: Option[Boolean] = {
optTimeout match {
case Some(to) =>
ti.interruptAfter(to) {
super.check
}
case None =>
super.check
}
}
abstract override def checkAssumptions(assumptions: Set[Expr]): Option[Boolean] = {
optTimeout match {
case Some(to) =>
ti.interruptAfter(to) {
super.checkAssumptions(assumptions)
}
case None =>
super.checkAssumptions(assumptions)
}
}
}