pub struct Plan {
pub ops: Vec<OpId>,
pub cost: u64,
}Expand description
A sequential plan for the original task.
Fields§
§ops: Vec<OpId>Operators in execution order, applicable from the initial state.
cost: u64Sum of the operator costs.
Implementations§
Source§impl Plan
impl Plan
Sourcepub fn validate(&self, task: &Task) -> Result<(), PlanError>
pub fn validate(&self, task: &Task) -> Result<(), PlanError>
Checks the plan against task with explicit-state semantics,
independent of decoupled search: starting from the initial state
with derived variables evaluated, every operator must be applicable,
conditional effects fire on the state before the operator, derived
variables are re-evaluated after it, the goal must hold at the end,
and Plan::cost must be the sum of the operator costs.
§Errors
PlanError::InvalidTaskiftaskfailsTask::validate.PlanError::UnknownOperatorfor the first step naming an operator the task lacks.PlanError::NotApplicablefor the first step whose operator is not applicable.PlanError::GoalNotReachedif the final state misses the goal.PlanError::CostMismatchif the plan is valid butPlan::costis wrong.
§Examples
use decoupled_search::{Plan, PlanError};
use sas_plus::{Effect, Fact, Operator, State, Task, Variable};
let task = Task {
variables: vec![Variable::new("x", 2)],
operators: vec![Operator {
name: "set".into(),
pre: vec![Fact::new(0, 0)],
eff: vec![Effect::new(Fact::new(0, 1))],
cost: 3,
}],
initial: State(vec![0]),
goal: vec![Fact::new(0, 1)],
axioms: vec![],
};
assert_eq!(Plan { ops: vec![0], cost: 3 }.validate(&task), Ok(()));
assert_eq!(
Plan { ops: vec![0, 0], cost: 6 }.validate(&task),
Err(PlanError::NotApplicable { step: 1, op: 0 })
);
assert_eq!(
Plan { ops: vec![], cost: 0 }.validate(&task),
Err(PlanError::GoalNotReached)
);Trait Implementations§
impl Eq for Plan
impl StructuralPartialEq for Plan
Auto Trait Implementations§
impl Forget for Plan
impl Freeze for Plan
impl Move for Plan
impl RefUnwindSafe for Plan
impl Send for Plan
impl Sync for Plan
impl Unpin for Plan
impl UnsafeUnpin for Plan
impl UnwindSafe for Plan
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more