fn publish_plan<PS: planner::ProblemSpace>(
    ps: &PS,
    start: PS::State,
    goal: PS::State,
    data: collections::HashMap<PS::State, util::StateData>,
    callback: fn(Vec<PS::State>),
) {
    let mut plan = Vec::new();
    let mut done = false;
    let mut curr = start;
    while !done {
        let mut min_cost = f64::INFINITY;
        let mut next_state = curr;
        for successor in ps.succ(&curr) {
            if data.contains_key(&successor.0) && data[&successor.0].g + successor.1 <= min_cost {
                min_cost = data[&successor.0].g + successor.1;
                next_state = successor.0;
            }
        }
        curr = next_state;
        plan.push(curr);
        // By checking second part - we would also publish incomplete plans...
        if curr == goal || data[&curr].rhs == f64::INFINITY {
            done = true;
        }
    }

    callback(plan);
}
/// Uses callback to publish the current solution.
Uses callback to publish the current solution.
Uses callback to publish the current solution .
fn publish_plan<PS: planner::ProblemSpace>(
    ps: &PS,
    start: PS::State,
    goal: PS::State,
    data: collections::HashMap<PS::State, util::StateData>,
    callback: fn(Vec<PS::State>),
) {
    let mut plan = Vec::new();
    let mut done = false;
    let mut curr = start;
    while !done {
        let mut min_cost = f64::INFINITY;
        let mut next_state = curr;
        for successor in ps.succ(&curr) {
            if data.contains_key(&successor.0) && data[&successor.0].g + successor.1 <= min_cost {
                min_cost = data[&successor.0].g + successor.1;
                next_state = successor.0;
            }
        }
        curr = next_state;
        plan.push(curr);
        // By checking second part - we would also publish incomplete plans...
        if curr == goal || data[&curr].rhs == f64::INFINITY {
            done = true;
        }
    }
    callback(plan);
}
fn publish_plan < PS : planner :: ProblemSpace > ( ps : & PS , start : PS :: State , goal : PS :: State , data : collections :: HashMap < PS :: State , util :: StateData > , callback : fn ( Vec < PS :: State > ) , ) { let mut plan = Vec :: new ( ) ; let mut done = false ; let mut curr = start ; while ! done { let mut min_cost = f64 :: INFINITY ; let mut next_state = curr ; for successor in ps . succ ( & curr ) { if data . contains_key ( & successor . 0 ) && data [ & successor . 0 ] . g + successor . 1 <= min_cost { min_cost = data [ & successor . 0 ] . g + successor . 1 ; next_state = successor . 0 ; } } curr = next_state ; plan . push ( curr ) ; // By checking second part - we would also publish incomplete plans... if curr == goal || data [ & curr ] . rhs == f64 :: INFINITY { done = true ; } } callback ( plan ) ; }
Uses callback to publish the current solution.
Uses callback to publish the current solution .
ps
&PS
start
PS::State
goal
PS::State
data
collections::HashMap<PS::State, util::StateData>
callback
fn(Vec<PS::State>)
ps
&PS
start
PS::State
goal
PS::State
data
collections::HashMap<PS::State, util::StateData>
callback
fn(Vec<PS::State>)