fn check_goals_exact(
    s: &SPState, goals: &[&Predicate], plan: &[Transition], ts_model: &TransitionSystemModel,
) -> bool {
    if goals.iter().all(|g| g.eval(s)) {
        return true;
    }

    let mut state = s.clone();
    for t in plan {
        if !t.guard.eval(&state) {
            return false;
        }

        // take all actions
        t.actions.iter().for_each(|a| {
            let _res = a.next(&mut state);
        });

        // update state predicates
        ts_model.state_predicates.iter().for_each(|sp| {
            if let VariableType::Predicate(p) = sp.variable_type() {
                let value = p.eval(&state).to_spvalue();
                if let Err(e) = state.force_from_path(sp.path(), &value) {
                    eprintln!(
                        "The predicate {:?} could not be updated in the check_goals_exact. Got error: {}",
                        sp.path(), e
                    );
                }
            }
        });

        // next -> cur
        let _changed = state.take_transition();

        if ts_model.bad_state(&state) {
            return false;
        }

        if goals.iter().all(|g| g.eval(&state)) {
            return true;
        }
    }

    return false;
}
/// Checks wheter we can reach a goal exactly applying
/// a list of transitions in their given order
Checks wheter we can reach a goal exactly applying
a list of transitions in their given order
Checks wheter we can reach a goal exactly applying a list of transitions in their given order
fn check_goals_exact(
    s: &SPState, goals: &[&Predicate], plan: &[Transition], ts_model: &TransitionSystemModel,
) -> bool {
    if goals.iter().all(|g| g.eval(s)) {
        return true;
    }
    let mut state = s.clone();
    for t in plan {
        if !t.guard.eval(&state) {
            return false;
        }
        // take all actions
        t.actions.iter().for_each(|a| {
            let _res = a.next(&mut state);
        });
        // update state predicates
        ts_model.state_predicates.iter().for_each(|sp| {
            if let VariableType::Predicate(p) = sp.variable_type() {
                let value = p.eval(&state).to_spvalue();
                if let Err(e) = state.force_from_path(sp.path(), &value) {
                    eprintln!(
                        "The predicate {:?} could not be updated in the check_goals_exact. Got error: {}",
                        sp.path(), e
                    );
                }
            }
        });
        // next -> cur
        let _changed = state.take_transition();
        if ts_model.bad_state(&state) {
            return false;
        }
        if goals.iter().all(|g| g.eval(&state)) {
            return true;
        }
    }
    return false;
}
fn check_goals_exact ( s : & SPState , goals : & [ & Predicate ] , plan : & [ Transition ] , ts_model : & TransitionSystemModel , ) -> bool { if goals . iter ( ) . all ( | g | g . eval ( s ) ) { return true ; } let mut state = s . clone ( ) ; for t in plan { if ! t . guard . eval ( & state ) { return false ; } // take all actions t . actions . iter ( ) . for_each ( | a | { let _res = a . next ( & mut state ) ; } ) ; // update state predicates ts_model . state_predicates . iter ( ) . for_each ( | sp | { if let VariableType :: Predicate ( p ) = sp . variable_type ( ) { let value = p . eval ( & state ) . to_spvalue ( ) ; if let Err ( e ) = state . force_from_path ( sp . path ( ) , & value ) { eprintln ! ( " " sp path ( ) e ) ; } } } ) ; // next -> cur let _changed = state . take_transition ( ) ; if ts_model . bad_state ( & state ) { return false ; } if goals . iter ( ) . all ( | g | g . eval ( & state ) ) { return true ; } } return false ; }
Checks wheter we can reach a goal exactly applying
a list of transitions in their given order
Checks wheter we can reach a goal exactly applying a list of transitions in their given order
s
&SPState
goals
&[&Predicate]
plan
&[Transition]
ts_model
&TransitionSystemModel