Skip to content

Commit

Permalink
Change arry_var_int_element propagator to be incremental
Browse files Browse the repository at this point in the history
Allow propagators to inspect variable domains on notify_event
  • Loading branch information
AllenZzw committed Sep 9, 2024
1 parent 969baa4 commit 248d2d6
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 197 deletions.
4 changes: 2 additions & 2 deletions crates/fzn-huub/benches/fzn_huub_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ fn milliseconds(c: &mut Criterion) {
fn a_few_seconds(c: &mut Criterion) {
let mut group = c.benchmark_group("a_few_seconds");
let group = group
.sample_size(10)
.measurement_time(Duration::from_secs(60))
.sample_size(20)
.measurement_time(Duration::from_secs(120))
.sampling_mode(SamplingMode::Flat);

let instances = vec![
Expand Down
11 changes: 6 additions & 5 deletions crates/huub/src/propagator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ use std::fmt::Debug;

use crate::{
actions::{
explanation::ExplanationActions, propagation::PropagationActions, trailing::TrailingActions,
explanation::ExplanationActions, inspection::InspectionActions,
propagation::PropagationActions,
},
propagator::{conflict::Conflict, int_event::IntEvent},
solver::{
engine::{solving_context::SolvingContext, trail::Trail, State},
engine::{solving_context::SolvingContext, State},
poster::BoxedPropagator,
},
Conjunction,
};

pub(crate) trait Propagator<P: PropagationActions, E: ExplanationActions, T: TrailingActions>:
pub(crate) trait Propagator<P: PropagationActions, E: ExplanationActions, I: InspectionActions>:
Debug + DynPropClone
{
/// The method called by the solver to notify the propagator of a variable
Expand All @@ -35,7 +36,7 @@ pub(crate) trait Propagator<P: PropagationActions, E: ExplanationActions, T: Tra
///
/// The [`data`] argument will contain the data that the propagater has set
/// when subscribing to an event.
fn notify_event(&mut self, data: u32, event: &IntEvent, actions: &mut T) -> bool {
fn notify_event(&mut self, data: u32, event: &IntEvent, actions: &mut I) -> bool {
let _ = data;
let _ = event;
let _ = actions;
Expand Down Expand Up @@ -75,7 +76,7 @@ pub(crate) trait Propagator<P: PropagationActions, E: ExplanationActions, T: Tra
pub(crate) trait DynPropClone {
fn clone_dyn_prop(&self) -> BoxedPropagator;
}
impl<P: for<'a> Propagator<SolvingContext<'a>, State, Trail> + Clone + 'static> DynPropClone for P {
impl<P: for<'a> Propagator<SolvingContext<'a>, State, State> + Clone + 'static> DynPropClone for P {
fn clone_dyn_prop(&self) -> BoxedPropagator {
Box::new(self.clone())
}
Expand Down
8 changes: 4 additions & 4 deletions crates/huub/src/propagator/all_different_int.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
actions::{
explanation::ExplanationActions, initialization::InitializationActions,
trailing::TrailingActions,
inspection::InspectionActions,
},
propagator::{conflict::Conflict, int_event::IntEvent, PropagationActions, Propagator},
solver::{
Expand All @@ -24,13 +24,13 @@ impl AllDifferentIntValue {
AllDifferentIntValuePoster { vars }
}
}
impl<P, E, T> Propagator<P, E, T> for AllDifferentIntValue
impl<P, E, I> Propagator<P, E, I> for AllDifferentIntValue
where
P: PropagationActions,
E: ExplanationActions,
T: TrailingActions,
I: InspectionActions,
{
fn notify_event(&mut self, data: u32, _: &IntEvent, _: &mut T) -> bool {
fn notify_event(&mut self, data: u32, _: &IntEvent, _: &mut I) -> bool {
self.action_list.push(data);
true
}
Expand Down
8 changes: 4 additions & 4 deletions crates/huub/src/propagator/array_int_minimum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use itertools::Itertools;
use crate::{
actions::{
explanation::ExplanationActions, initialization::InitializationActions,
trailing::TrailingActions,
inspection::InspectionActions,
},
propagator::{conflict::Conflict, int_event::IntEvent, PropagationActions, Propagator},
solver::{
Expand Down Expand Up @@ -35,13 +35,13 @@ impl ArrayIntMinimumBounds {
}
}

impl<P, E, T> Propagator<P, E, T> for ArrayIntMinimumBounds
impl<P, E, I> Propagator<P, E, I> for ArrayIntMinimumBounds
where
P: PropagationActions,
E: ExplanationActions,
T: TrailingActions,
I: InspectionActions,
{
fn notify_event(&mut self, data: u32, event: &IntEvent, _: &mut T) -> bool {
fn notify_event(&mut self, data: u32, event: &IntEvent, _: &mut I) -> bool {
if data == self.vars.len() as u32 {
self.y_change = true;
} else {
Expand Down
Loading

0 comments on commit 248d2d6

Please sign in to comment.