pub fn solve<PS: Problem>(ps: &mut PS, steps: i32) -> (bool, i32) {
    let mut found: bool = false;
    let mut iterations: i32 = 0;
    for i in 0..steps {
        iterations = i;
        // TODO: find nicer way to push items on max-heap.
        let mut heap: collections::BinaryHeap<util::HeapEntry<PS::Conflict>> =
            collections::BinaryHeap::new();
        for item in ps.find_conflicts() {
            heap.push(util::HeapEntry {
                state: item.0,
                keys: (item.1, 0.0),
            });
        }
        if !heap.is_empty() {
            let conflict: PS::Conflict = heap.pop().unwrap().state;
            ps.fix_conflict(&conflict);
        // TODO: trace conflicts solved - and if we find repetition of fixes -> break.
        } else {
            found = true;
            break;
        }
    }
    (found, iterations)
}
///
/// Solve a problem using iterative repair algorithm. Conflicts can be ranked.
///
/// # Example
/// ```
/// use std::vec;
///
/// use rusty_planner::iterative_repair;
///
/// struct Problem {}
///
/// impl iterative_repair::Problem for Problem {
///     type Conflict = (i32, i32);
///     type Iter = vec::IntoIter<(Self::Conflict, f64)>;
///     fn find_conflicts(&self) -> Self::Iter {
///         // TODO: Add code that finds conflicts...
///         vec![].into_iter()
///     }
///     fn fix_conflict(&mut self, conflict: &Self::Conflict) {
///         // TODO: Add code that solves a conflict...
///     }
/// }
///
/// let mut ps = Problem {};
/// iterative_repair::solve(&mut ps, 10);
/// ```
///
Solve a problem using iterative repair algorithm. Conflicts can be ranked.
Solve a problem using iterative repair algorithm . Conflicts can be ranked .
pub fn solve<PS: Problem>(ps: &mut PS, steps: i32) -> (bool, i32) {
    let mut found: bool = false;
    let mut iterations: i32 = 0;
    for i in 0..steps {
        iterations = i;
        // TODO: find nicer way to push items on max-heap.
        let mut heap: collections::BinaryHeap<util::HeapEntry<PS::Conflict>> =
            collections::BinaryHeap::new();
        for item in ps.find_conflicts() {
            heap.push(util::HeapEntry {
                state: item.0,
                keys: (item.1, 0.0),
            });
        }
        if !heap.is_empty() {
            let conflict: PS::Conflict = heap.pop().unwrap().state;
            ps.fix_conflict(&conflict);
        // TODO: trace conflicts solved - and if we find repetition of fixes -> break.
        } else {
            found = true;
            break;
        }
    }
    (found, iterations)
}
pub fn solve < PS : Problem > ( ps : & mut PS , steps : i32 ) -> ( bool , i32 ) { let mut found : bool = false ; let mut iterations : i32 = 0 ; for i in 0 .. steps { iterations = i ; // TODO: find nicer way to push items on max-heap. let mut heap : collections :: BinaryHeap < util :: HeapEntry < PS :: Conflict > > = collections :: BinaryHeap :: new ( ) ; for item in ps . find_conflicts ( ) { heap . push ( util :: HeapEntry { state : item . 0 , keys : ( item . 1 , 0.0 ) , } ) ; } if ! heap . is_empty ( ) { let conflict : PS :: Conflict = heap . pop ( ) . unwrap ( ) . state ; ps . fix_conflict ( & conflict ) ; // TODO: trace conflicts solved - and if we find repetition of fixes -> break. } else { found = true ; break ; } } ( found , iterations ) }
Solve a problem using iterative repair algorithm.
Solve a problem using iterative repair algorithm .
ps
&mut PS
steps
i32
ps
&mut PS
steps
i32
example


use rusty_planner::iterative_repair.

struct Problem {}

impl iterative_repair::Problem for Problem {
type Conflict = (i32, i32);
type Iter = vec::IntoIter<(Self::Conflict, f64)>;
fn find_conflicts(&self) -> Self::Iter {
TODO: Add code that finds conflicts
vec![].into_iter()
}
fn fix_conflict(&mut self, conflict: &Self::Conflict) {
TODO: Add code that solves a conflict
}
}

let mut ps = Problem {};
iterative_repair::solve(&mut ps, 10);
```
use rusty_planner :: iterative_repair . struct Problem {} impl iterative_repair :: Problem for Problem { type Conflict = ( i32 i32 ) ; type Iter = vec :: IntoIter< ( Self :: Conflict f64 ) > ; fn find_conflicts ( &self ) - > Self :: Iter { TODO : Add code that finds conflicts vec! [] . into_iter () } fn fix_conflict ( &mut self conflict : &Self :: Conflict ) { TODO : Add code that solves a conflict } } let mut ps = Problem {} ; iterative_repair :: solve ( &mut ps 10 ) ; ` ` `