Skip to content

Commit

Permalink
feat(planning): Support task network constraints in HDDL.
Browse files Browse the repository at this point in the history
  • Loading branch information
arbimo committed May 17, 2023
1 parent f98e93b commit 6d332cc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
19 changes: 19 additions & 0 deletions planning/planning/src/parsing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,25 @@ fn read_task_network(
.0;
chronicle.constraints.push(Constraint::lt(first_end, second_start));
}
for c in &tn.constraints {
// treat constraints exactly as we treat preconditions
let as_chronicle_atom = |x: &sexpr::SAtom| as_chronicle_atom(x, context);
let conditions = read_conjunction(c, as_chronicle_atom)?;
for TermLoc(term, _) in conditions {
match term {
Term::Binding(sv, val) => {
chronicle.conditions.push(Condition {
start: chronicle.start,
end: chronicle.start,
state_var: sv,
value: val,
});
}
Term::Eq(a, b) => chronicle.constraints.push(Constraint::eq(a, b)),
Term::Neq(a, b) => chronicle.constraints.push(Constraint::neq(a, b)),
}
}
}

Ok(())
}
Expand Down
7 changes: 3 additions & 4 deletions planning/planning/src/parsing/pddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ pub struct TaskNetwork {
pub ordered_tasks: Vec<Task>,
pub unordered_tasks: Vec<Task>,
pub orderings: Vec<Ordering>,
pub constraints: Vec<SExpr>,
}

/// Constraint specifying that the task identified by `first_task_id` should end
Expand Down Expand Up @@ -605,10 +606,8 @@ fn parse_task_network(mut key_values: ListIter) -> R<TaskNetwork> {
}
}
":constraints" => {
let value = key_values.pop_list()?;
if !value.iter().is_empty() {
return Err(value.invalid("No support yet for non-empty constraint lists in task networks."));
}
let value = key_values.pop()?;
tn.constraints.push(value.clone());
}
_ => return Err(key_loc.invalid("Unsupported keyword in task network")),
}
Expand Down

0 comments on commit 6d332cc

Please sign in to comment.