Skip to content

Commit

Permalink
Add get_trailed_int as part of the inspection actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekker1 committed May 24, 2024
1 parent 61ff951 commit ef66648
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion crates/huub/src/actions/inspection.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use crate::{BoolView, IntVal, IntView};
use crate::{solver::engine::TrailedInt, BoolView, IntVal, IntView};

pub(crate) trait InspectionActions {
fn get_bool_val(&self, bv: BoolView) -> Option<bool>;

#[allow(dead_code)]
fn get_trailed_int(&self, x: TrailedInt) -> IntVal;

fn get_int_lower_bound(&self, var: IntView) -> IntVal;
fn get_int_upper_bound(&self, var: IntView) -> IntVal;
fn get_int_bounds(&self, var: IntView) -> (IntVal, IntVal) {
Expand Down
4 changes: 4 additions & 0 deletions crates/huub/src/solver/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ impl InspectionActions for State {
}
}

fn get_trailed_int(&self, x: TrailedInt) -> IntVal {
self.int_trail[x]
}

Check warning on line 428 in crates/huub/src/solver/engine.rs

View check run for this annotation

Codecov / codecov/patch

crates/huub/src/solver/engine.rs#L426-L428

Added lines #L426 - L428 were not covered by tests

fn get_int_lower_bound(&self, var: IntView) -> IntVal {
match var.0 {
IntViewInner::VarRef(iv) => self.int_trail[self.int_vars[iv].lower_bound],
Expand Down
3 changes: 2 additions & 1 deletion crates/huub/src/solver/engine/propagation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
},
propagator::{conflict::Conflict, reason::ReasonBuilder},
solver::{
engine::{int_var::IntVarRef, trail::HasChanged, PropRef, State},
engine::{int_var::IntVarRef, trail::HasChanged, PropRef, State, TrailedInt},
view::{BoolViewInner, IntViewInner},
},
BoolView, Conjunction, IntVal, IntView, LitMeaning,
Expand Down Expand Up @@ -192,6 +192,7 @@ impl InspectionActions for PropagationContext<'_> {
delegate! {
to self.state {
fn get_bool_val(&self, bv: BoolView) -> Option<bool>;
fn get_trailed_int(&self, x: TrailedInt) -> IntVal;

Check warning on line 195 in crates/huub/src/solver/engine/propagation_context.rs

View check run for this annotation

Codecov / codecov/patch

crates/huub/src/solver/engine/propagation_context.rs#L195

Added line #L195 was not covered by tests
fn get_int_lower_bound(&self, var: IntView) -> IntVal;
fn get_int_upper_bound(&self, var: IntView) -> IntVal;
fn get_int_bounds(&self, var: IntView) -> (IntVal, IntVal);
Expand Down
1 change: 1 addition & 0 deletions crates/huub/src/solver/initialization_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ where
delegate! {
to self.slv.engine().state {
fn get_bool_val(&self, bv: BoolView) -> Option<bool>;
fn get_trailed_int(&self, x: TrailedInt) -> IntVal;
fn get_int_lower_bound(&self, var: IntView) -> IntVal;
fn get_int_upper_bound(&self, var: IntView) -> IntVal;
fn get_int_bounds(&self, var: IntView) -> (IntVal, IntVal);
Expand Down

0 comments on commit ef66648

Please sign in to comment.