From ef66648d793b5986ceac7980d5d3e4b86fee4d5b Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Fri, 24 May 2024 15:43:18 +1000 Subject: [PATCH] Add get_trailed_int as part of the inspection actions --- crates/huub/src/actions/inspection.rs | 5 ++++- crates/huub/src/solver/engine.rs | 4 ++++ crates/huub/src/solver/engine/propagation_context.rs | 3 ++- crates/huub/src/solver/initialization_context.rs | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/huub/src/actions/inspection.rs b/crates/huub/src/actions/inspection.rs index 99e98cfa..c71be4c3 100644 --- a/crates/huub/src/actions/inspection.rs +++ b/crates/huub/src/actions/inspection.rs @@ -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; + #[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) { diff --git a/crates/huub/src/solver/engine.rs b/crates/huub/src/solver/engine.rs index a38dc62c..d1e3eca8 100644 --- a/crates/huub/src/solver/engine.rs +++ b/crates/huub/src/solver/engine.rs @@ -423,6 +423,10 @@ impl InspectionActions for State { } } + fn get_trailed_int(&self, x: TrailedInt) -> IntVal { + self.int_trail[x] + } + fn get_int_lower_bound(&self, var: IntView) -> IntVal { match var.0 { IntViewInner::VarRef(iv) => self.int_trail[self.int_vars[iv].lower_bound], diff --git a/crates/huub/src/solver/engine/propagation_context.rs b/crates/huub/src/solver/engine/propagation_context.rs index d382df67..d49178e4 100644 --- a/crates/huub/src/solver/engine/propagation_context.rs +++ b/crates/huub/src/solver/engine/propagation_context.rs @@ -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, @@ -192,6 +192,7 @@ impl InspectionActions for PropagationContext<'_> { delegate! { to self.state { fn get_bool_val(&self, bv: BoolView) -> Option; + 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); diff --git a/crates/huub/src/solver/initialization_context.rs b/crates/huub/src/solver/initialization_context.rs index 8f3a052b..ffee3264 100644 --- a/crates/huub/src/solver/initialization_context.rs +++ b/crates/huub/src/solver/initialization_context.rs @@ -86,6 +86,7 @@ where delegate! { to self.slv.engine().state { fn get_bool_val(&self, bv: BoolView) -> Option; + 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);