Skip to content

Commit

Permalink
feat(planning): detect fixed fluents as numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
Shi-Raida committed Dec 9, 2024
1 parent 6612433 commit da8ce5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions planning/planners/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,15 @@ pub fn encode(pb: &FiniteProblem, metric: Option<Metric>) -> std::result::Result
let EffectOp::Assign(val) = ass.operation else {
unreachable!()
};
let Atom::Int(val) = val else { unreachable!() };
solver.enforce(geq(val, lb), [prez]);
solver.enforce(leq(val, ub), [prez]);
if let Atom::Int(val) = val {
solver.enforce(geq(val, lb), [prez]);
solver.enforce(leq(val, ub), [prez]);
} else if let Atom::Fixed(val) = val {
solver.enforce(f_geq(val, FAtom::new((lb * val.denom).into(), val.denom)), [prez]);
solver.enforce(f_leq(val, FAtom::new((ub * val.denom).into(), val.denom)), [prez]);
} else {
unreachable!();
}
num_numeric_assignment_coherence_constraints += 1;
}

Expand Down Expand Up @@ -805,8 +811,10 @@ pub fn encode(pb: &FiniteProblem, metric: Option<Metric>) -> std::result::Result
if solver.model.entails(!*cond_prez) {
continue;
}
let Atom::Int(cond_val) = cond.value else {
unreachable!()
let cond_val = match cond.value {
Atom::Int(val) => FAtom::new(val, 1),
Atom::Fixed(val) => val,
_ => unreachable!(),
};
let mut supported: Vec<Lit> = Vec::with_capacity(128);
let mut inc_support: HashMap<EffID, Vec<Lit>> = HashMap::new();
Expand Down
2 changes: 1 addition & 1 deletion planning/planners/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn conditions(pb: &FiniteProblem) -> impl Iterator<Item = (CondID, Lit, &Con

/// Returns true if the state variable is numeric.
pub fn is_numeric(sv: &StateVar) -> bool {
matches!(sv.fluent.return_type().into(), Kind::Int)
matches!(sv.fluent.return_type().into(), Kind::Int) || matches!(sv.fluent.return_type().into(), Kind::Fixed(_))
}

pub struct TaskRef<'a> {
Expand Down

0 comments on commit da8ce5b

Please sign in to comment.