Commit e4169c17 authored by Arthur Bit-Monnot's avatar Arthur Bit-Monnot

Support actions with durations depending on parameters.

parent 040b09e8
......@@ -41,7 +41,15 @@ class ActionFactory(actionName: String, parent: Resolver, model: Model) extends
rec(
BooleanAssertion(BinaryExprTree(operators.Eq, duration, cst))
)
case x => unexpected(x.toString)
case Some(ast.Eq(ast.Duration(_), e @ ast.Fluent(f, args))) =>
rec(
TemporallyQualifiedAssertion(
Equals(ClosedInterval(start, start)),
TimedEqualAssertion(resolver.getTranslator(f).fluent(f, args, resolver), duration, Some(context), resolver.nextId())
)
)
case x =>
unexpected(x.toString)
}
recPrecondition(op.getPreconditions)
......
......@@ -14,6 +14,7 @@ abstract class FunctionCompat() {
def name: String
def model: FluentTemplate
def fluent(name: String, args: Seq[String], res: Resolver): Fluent
def condition(e: Exp, res: Resolver): TimedEqualAssertion // TODO: should probably take a context
def effect(e: Exp, res: Resolver): TimedAssignmentAssertion
}
......@@ -40,6 +41,9 @@ class DefaultPredicate(pddl: NamedTypedList, top: Resolver) extends FunctionComp
case ast.TypedSymbol(argName, argType) => common.Arg(top.id(argName), top.typeOf(argType))
})
override def fluent(name: String, args: Seq[String], res: Resolver): Fluent =
Fluent(model, args.map(res.variable))
override def condition(e: Exp, local: Resolver): TimedEqualAssertion = e match {
case ast.Fluent(fun, args) if fun == name =>
TimedEqualAssertion(
......@@ -54,14 +58,14 @@ class DefaultPredicate(pddl: NamedTypedList, top: Resolver) extends FunctionComp
override def effect(e: Exp, local: Resolver): TimedAssignmentAssertion = e match {
case ast.Fluent(fun, args) if fun == name =>
TimedAssignmentAssertion(
Fluent(model, args.map(local.variable)),
fluent(fun, args, local),
local.predef.True,
Some(local.ctx),
local.nextId()
)
case ast.Not(ast.Fluent(fun, args)) =>
TimedAssignmentAssertion(
Fluent(model, args.map(local.variable)),
fluent(fun, args, local),
predef.False,
Some(local.ctx),
local.nextId()
......@@ -83,10 +87,13 @@ class DefaultFunction(pddl: NamedTypedList, top: Resolver) extends FunctionCompa
case ast.TypedSymbol(argName, argType) => common.Arg(top.id(argName), top.typeOf(argType))
})
override def fluent(name: String, args: Seq[String], res: Resolver): Fluent =
Fluent(model, args.map(res.variable))
override def condition(e: Exp, local: Resolver): TimedEqualAssertion = e match {
case ast.Eq(ast.Fluent(funName, args), ast.Cst(rhs)) if funName == name =>
TimedEqualAssertion(
Fluent(model, args.map(local.variable)),
fluent(funName, args, local),
rhs,
Some(local.ctx),
local.nextId()
......@@ -97,7 +104,7 @@ class DefaultFunction(pddl: NamedTypedList, top: Resolver) extends FunctionCompa
override def effect(e: Exp, local: Resolver): TimedAssignmentAssertion = e match {
case ast.Eq(ast.Fluent(funName, args), ast.Cst(rhs)) if funName == name =>
TimedAssignmentAssertion(
Fluent(model, args.map(local.variable)),
fluent(funName, args, local),
rhs,
Some(local.ctx),
local.nextId()
......
......@@ -23,6 +23,11 @@ object Fluent {
case head :: tail => Some((head, tail))
case _ => None
}
} else if(exp.getConnective == Connective.F_EXP) {
exp.getChildren.asScala match {
case Seq(e) => Fluent.unapply(e)
case _ => unexpected
}
} else {
None
}
......
......@@ -20,7 +20,7 @@ case class Config(problemFile: File = null,
numThreads: Int = 1,
maxRuntime: FiniteDuration = 1800.seconds,
warmupTimeSec: Int = 0,
discretization: Int = 1)
discretization: Int = 1000)
object Main extends App {
val optionsParser = new scopt.OptionParser[Config]("dahu") {
......@@ -35,9 +35,12 @@ object Main extends App {
opt[Int]("timeout")
.action((t, c) => c.copy(maxRuntime = t.seconds))
arg[Seq[File]]("[XXX.dom.pddl] XXXX.YY.pb.pddl").action {
case (Seq(pb), cfg) => cfg.copy(problemFile = pb)
case (Seq(dom, pb), cfg) => cfg.copy(domainFile = Some(dom), problemFile = pb)
arg[File]("XXX.dom.pddl").optional().action {
case (f, c) => c.copy(domainFile = Some(f))
}
arg[File]("XXXX.YY.pb.pddl").action {
case (f, cfg) => cfg.copy(problemFile = f)
}
}
......
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