pub struct Plan {
pub steps: Vec<PlanStep>,
pub cost: f64,
}Expand description
The output produced by a planner when search succeeds.
This is the structure wrapped by SearchOutcome::Plan.
§Invariants
stepsis ordered:steps[0]is applied first.costequals the sum of the applied operators’ cost values; it is not necessarilysteps.len()because operator costs need not be unit.- An empty plan (
stepsis empty,cost == 0.0) is a valid result when the initial state already satisfies the goal.
§Examples
use miniplan::plan::{Plan, PlanStep};
use miniplan::task::OpId;
let plan = Plan::new();
assert!(plan.is_empty());
assert_eq!(plan.len(), 0);
assert_eq!(plan.cost, 0.0);
let mut plan = Plan::new();
plan.steps.push(PlanStep { op_id: OpId(0), op_name: "pick".into() });
plan.cost = 1.0;
assert!(!plan.is_empty());
assert_eq!(plan.len(), 1);
assert_eq!(
plan.to_string(),
"; cost = 1\n; length = 1\n(pick)\n"
);Fields§
§steps: Vec<PlanStep>Ordered list of PlanSteps; execute left-to-right.
cost: f64Accumulated cost of the steps.
Must stay in sync with steps — callers mutate both together.
Implementations§
Source§impl Plan
impl Plan
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty plan.
The returned value satisfies steps.is_empty() and cost == 0.0.
This is equivalent to Plan::default().
§Examples
use miniplan::plan::Plan;
let plan = Plan::new();
assert!(plan.is_empty());
assert_eq!(plan.cost, 0.0);Trait Implementations§
Source§impl Display for Plan
Human-readable display format for a Plan.
impl Display for Plan
Human-readable display format for a Plan.
Emits a PDDL-style plan file:
- Line 1:
; cost = <cost>(semicolons are PDDL plan comments). - Line 2:
; length = <len>. - Lines 3..: one
(<op_name>)per step, each terminated by\n.
The trailing newline after the last step matches the writeln! macro.
§Examples
use miniplan::plan::{Plan, PlanStep};
use miniplan::task::OpId;
let mut plan = Plan::new();
plan.steps.push(PlanStep { op_id: OpId(0), op_name: "pick".into() });
plan.steps.push(PlanStep { op_id: OpId(1), op_name: "place".into() });
plan.cost = 2.0;
assert_eq!(
plan.to_string(),
"; cost = 2\n; length = 2\n(pick)\n(place)\n"
);impl StructuralPartialEq for Plan
Auto Trait Implementations§
impl Freeze 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<V, T, O> AcceptMut<V, T, O> for Twhere
V: VisitorMut<T, O>,
impl<V, T, O> AcceptMut<V, T, O> for Twhere
V: VisitorMut<T, O>,
fn accept_mut(&self, v: &mut V) -> O
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