Commit 10ae2ea7 authored by Arthur Bit-Monnot's avatar Arthur Bit-Monnot

Simple program for running benchmarks.

parent 5b4dd38a
......@@ -34,7 +34,7 @@ class ActionRewrite(options: Options) {
// regrouped.foreach(println)
// println("")
// regrouped.map(encode).foreach(x => println(x.mkString(" ------ ")))
println("")
// println("")
// println("GROUPED: ")
// regrouped
......@@ -81,9 +81,9 @@ class ActionRewrite(options: Options) {
}
timelines.groupBy(_.fluent).values.toSeq.map {
case Seq(tl) => tl
case Seq(tl) => tl
case Seq(tl1, tl2) =>
println(s"warning: merging two discontinuous timelines: $tl1 ----- $tl2")
// println(s"warning: merging two discontinuous timelines: $tl1 ----- $tl2")
tl1.order(tl2, ordering) match {
case After => merge(tl1, tl2)
case Before => merge(tl2, tl1)
......
package dahu.planning.pddl.planner
import java.io.File
import dahu.planning.model.core.ActionTemplate
import dahu.planning.pddl.parser.{Options, Parser, PddlPredef}
import dahu.planning.planner.{Plan, Planner, PlannerConfig}
import scala.concurrent.duration._
import scala.util.{Failure, Success}
object RCLL extends App {
val DISCRETIZATIOn = 1000
val TIMEOUT = 60.seconds
dahu.utils.debug.LOG_LEVEL = 2
for(game <- 1 to 30; c <- 0 to 1; r <- 1 to 3; spec <- Seq(true)) {
val pbName = f"$game%03d-R$r-C$c"
val domain = new File("out/rcll.dom.pddl")
val problem = new File(s"out/rcll.$pbName.pb.pddl")
val maxActions: Map[String, Int] = Map(
"bs-dispense" -> 1,
"cs-mount-cap" -> 1,
"cs-retrieve-cap" -> 1,
"enter-field" -> r,
"move-wp-get" -> (3 + c),
"move-wp-put-at-input" -> (3 + c),
"prepare-bs" -> 1,
"prepare-cs" -> 2, // mount and retrieve
"prepare-ds" -> 1,
"prepare-rs" -> c,
"rs-mount-ring1" -> (if(c >= 1) 1 else 0),
"wp-discard" -> 1,
"wp-get" -> (3 + c),
"wp-get-shelf" -> 1,
"wp-put-slide-cc" -> 0,
"wp-put-slide-empty-base" -> 0,
"wp-put" -> (3 + c),
"fulfill-order-c0" -> (if(c == 0) 1 else 0),
"fulfill-order-c1" -> (if(c == 1) 1 else 0),
)
val startTime = System.currentTimeMillis().millis
val result = solve(domain, problem, spec, a => maxActions(a.name))
val duration = (System.currentTimeMillis().millis - startTime).toMillis.toFloat / 1000
val status = result match {
case Some(plan) => "OK"
case None => "__"
}
println(pbName + (if(spec) " spec " else " gen ") + f" \t$status \t$duration%02.3f")
}
def solve(domain: File,
problem: File,
specialized: Boolean,
numAction: ActionTemplate => Int): Option[Plan] = {
val pddlOptions = Options(discretization = DISCRETIZATIOn)
val parser = new Parser(pddlOptions)
implicit val plannerConfig = PlannerConfig(0, 15)
implicit val predef: PddlPredef = parser.predef
parser.parse(domain, problem) match {
case Success(model) =>
if(specialized) {
Planner.solveWithGivenActionNumbers(model, numAction, Deadline.now + TIMEOUT)
} else {
Planner.solveIncremental(model, 15, Deadline.now + TIMEOUT)
}
case Failure(err) =>
err.printStackTrace()
sys.exit(1)
}
}
}
//0.001: (prepare-bs c-bs, input, base_red) [0.0]
//0.001: (enter-field r-1, cyan) [10.0]
//0.103: (bs-dispense c-bs, input, wp1, base_red) [0.0]
//10.004: (move-wp-get r-1, start, input, c-bs, input) [2.831]
//12.836: (wp-get r-1, wp1, c-bs, input) [5.0]
//17.838: (move-wp-put-at-input r-1, c-bs, input, c-rs1) [1.514]
//19.354: (prepare-rs r-1, c-rs1, ring_yellow, zero, zero, zero) [0.0]
//19.355: (wp-put r-1, wp1, c-rs1) [5.0]
//19.356: (move-wp-put-at-input r-1, c-rs1, input, c-cs1) [9.597]
//28.954: (wp-get-shelf r-1, cg1, c-cs1, left) [5.0]
//28.956: (prepare-cs r-1, c-cs1, cs_retrieve) [0.0]
//33.955: (wp-discard r-1, cg1) [0.0]
//33.956: (wp-get-shelf r-1, cg3, c-cs1, right) [5.0]
//38.957: (wp-put r-1, cg3, c-cs1) [5.0]
//43.958: (cs-retrieve-cap c-cs1, cg3, cap_grey) [0.1]
//44.059: (rs-mount-ring1 c-rs1, wp1, ring_yellow, zero, zero, zero) [0.1]
//44.059: (move-wp-get r-1, c-cs1, input, c-cs1, output) [2.809]
//46.869: (wp-get r-1, cg3, c-cs1, output) [5.0]
//51.87: (wp-discard r-1, cg3) [0.0]
//51.871: (move-wp-get r-1, c-cs1, output, c-rs1, output) [12.613]
//64.485: (wp-get r-1, wp1, c-rs1, output) [5.0]
//64.486: (move-wp-put-at-input r-1, c-rs1, output, c-cs1) [10.932]
//75.419: (prepare-cs r-1, c-cs1, cs_mount) [0.0]
//75.421: (wp-put r-1, wp1, c-cs1) [5.0]
//80.422: (wp-get-shelf r-1, cg2, c-cs1, middle) [5.0]
//85.423: (wp-discard r-1, cg2) [0.0]
//85.426: (cs-mount-cap c-cs1, wp1, cap_grey) [0.1]
//85.527: (move-wp-get r-1, c-cs1, input, c-cs1, output) [2.809]
//88.337: (wp-get r-1, wp1, c-cs1, output) [5.0]
//88.338: (move-wp-put-at-input r-1, c-cs1, output, c-ds) [9.077]
//97.416: (prepare-ds r-1, c-ds, gate-2) [0.0]
//98.342: (wp-put r-1, wp1, c-ds) [5.0]
//103.347: (fulfill-order-c1 o1, wp1, c-ds, gate-2, base_red, cap_grey, ring_yellow) [0.0]
......@@ -37,7 +37,7 @@ object Planner {
return None
info(s"Depth: $step")
solveIncrementalStep(model, step.toInt, deadline) match {
solveWithGivenActionNumbers(model, _ => step, deadline) match {
case Some(sol) =>
info(s" Solution found at depth $step")
return Some(sol)
......@@ -51,9 +51,10 @@ object Planner {
task.unsafeRunTimed(deadline.timeLeft).flatten
}
def solveIncrementalStep(model: core.CoreModel, step: Int, deadline: Deadline)(
implicit cfg: PlannerConfig,
predef: Predef): Option[Plan] = {
def solveWithGivenActionNumbers(
model: core.CoreModel,
num: ActionTemplate => Int,
deadline: Deadline)(implicit cfg: PlannerConfig, predef: Predef): Option[Plan] = {
if(deadline.isOverdue())
return None
......@@ -65,7 +66,7 @@ object Planner {
val actionInstances: Seq[Opt[Action[Tentative]]] =
if(cfg.symBreak) {
import dahu.model.input.dsl._
(0 until step).foldLeft(List[Opt[Action[Tentative]]]()) {
(0 until num(action)).foldLeft(List[Opt[Action[Tentative]]]()) {
case (Nil, _) => // first action
Opt.optional(Action.instance(action, ctx)) :: Nil
case (last :: rest, _) =>
......@@ -82,7 +83,7 @@ object Planner {
}
} else {
(0 until step).map { _ =>
(0 until num(action)).map { _ =>
Opt.optional(Action.instance(action, ctx))
}
}
......
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