Skip to content

Commit

Permalink
Resolve self and super imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekker1 committed May 24, 2024
1 parent c45148c commit 61ff951
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 84 deletions.
4 changes: 1 addition & 3 deletions crates/huub/src/actions/explanation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::{BoolView, IntView, LitMeaning};

use super::inspection::InspectionActions;
use crate::{actions::inspection::InspectionActions, BoolView, IntView, LitMeaning};

pub(crate) trait ExplanationActions: InspectionActions {
fn get_int_lit(&self, var: IntView, meaning: LitMeaning) -> BoolView;
Expand Down
5 changes: 2 additions & 3 deletions crates/huub/src/actions/initialization.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::{
propagator::int_event::IntEvent, solver::engine::TrailedInt, BoolView, IntVal, IntView,
actions::inspection::InspectionActions, propagator::int_event::IntEvent,
solver::engine::TrailedInt, BoolView, IntVal, IntView,
};

use super::inspection::InspectionActions;

pub(crate) trait InitializationActions: InspectionActions {
fn subscribe_bool(&mut self, var: BoolView, data: u32);
fn subscribe_int(&mut self, var: IntView, event: IntEvent, data: u32);
Expand Down
3 changes: 1 addition & 2 deletions crates/huub/src/actions/propagation.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::{
actions::explanation::ExplanationActions,
propagator::{conflict::Conflict, reason::ReasonBuilder},
BoolView, IntVal, IntView,
};

use super::explanation::ExplanationActions;

pub(crate) trait PropagationActions: ExplanationActions {
fn set_bool_val(
&mut self,
Expand Down
3 changes: 1 addition & 2 deletions crates/huub/src/helpers/linear_transform.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::ops::{Add, Mul, Neg};

use super::div_ceil;
use crate::{IntVal, LitMeaning, NonZeroIntVal};
use crate::{helpers::div_ceil, IntVal, LitMeaning, NonZeroIntVal};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct LinearTransform {
Expand Down
11 changes: 5 additions & 6 deletions crates/huub/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ use pindakaas::{
Var as RawVar,
};

use self::{
bool::{BoolExpr, BoolView},
int::{IntVar, IntView},
reformulate::{ReformulationError, VariableMap},
};
use crate::{
model::int::IntVarDef,
model::{
bool::{BoolExpr, BoolView},
int::{IntVar, IntVarDef, IntView},
reformulate::{ReformulationError, VariableMap},
},
solver::{engine::int_var::IntVar as SlvIntVar, SatSolver},
Constraint, Solver,
};
Expand Down
8 changes: 4 additions & 4 deletions crates/huub/src/model/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use pindakaas::{
Formula, Lit as RawLit, TseitinEncoder, Valuation as SatValuation,
};

use super::{
int,
reformulate::{ReformulationError, ReifContext, VariableMap},
};
use crate::{
model::{
int,
reformulate::{ReformulationError, ReifContext, VariableMap},
},
solver::{
view::{self, BoolViewInner},
SatSolver,
Expand Down
8 changes: 4 additions & 4 deletions crates/huub/src/model/constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use pindakaas::{
Valuation as SatValuation,
};

use super::{
int::IntView,
reformulate::{ReifContext, VariableMap},
};
use crate::{
helpers::{div_ceil, div_floor},
model::{
int::IntView,
reformulate::{ReifContext, VariableMap},
},
propagator::{
all_different_int::AllDifferentIntValue,
array_int_minimum::ArrayIntMinimumBounds,
Expand Down
15 changes: 9 additions & 6 deletions crates/huub/src/model/flatzinc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ use pindakaas::{
};
use thiserror::Error;

use super::{
bool::{BoolExpr, BoolView},
int::IntView,
reformulate::ReformulationError,
ModelView,
use crate::{
model::{
bool::{BoolExpr, BoolView},
int::IntView,
reformulate::ReformulationError,
ModelView,
},
solver::SatSolver,
Constraint, IntVal, Model, NonZeroIntVal, Solver, SolverView,
};
use crate::{solver::SatSolver, Constraint, IntVal, Model, NonZeroIntVal, Solver, SolverView};

impl Model {
pub fn from_fzn<S: Ord + Deref<Target = str> + Clone + Debug>(
Expand Down
8 changes: 4 additions & 4 deletions crates/huub/src/model/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use pindakaas::{
Valuation as SatValuation,
};

use super::{
bool::BoolView,
reformulate::{ReifContext, VariableMap},
};
use crate::{
helpers::linear_transform::LinearTransform,
model::{
bool::BoolView,
reformulate::{ReifContext, VariableMap},
},
solver::{view, SatSolver},
IntVal, Model, NonZeroIntVal, ReformulationError, Solver,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/huub/src/model/reformulate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use pindakaas::{
};
use thiserror::Error;

use super::{bool, int, int::IntVar, ModelView};
use crate::{
actions::explanation::ExplanationActions,
model::{bool, int, int::IntVar, ModelView},
solver::{
view::{BoolView, BoolViewInner, IntViewInner, SolverView},
SatSolver,
Expand Down
3 changes: 1 addition & 2 deletions crates/huub/src/propagator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ pub(crate) mod reason;

use std::fmt::Debug;

use self::int_event::IntEvent;
use crate::{
actions::{explanation::ExplanationActions, propagation::PropagationActions},
propagator::conflict::Conflict,
propagator::{conflict::Conflict, int_event::IntEvent},
solver::engine::queue::PriorityLevel,
Conjunction,
};
Expand Down
6 changes: 4 additions & 2 deletions crates/huub/src/propagator/all_different_int.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::{reason::ReasonBuilder, PropagationActions};
use crate::{
actions::initialization::InitializationActions,
propagator::{conflict::Conflict, int_event::IntEvent, Propagator},
propagator::{
conflict::Conflict, int_event::IntEvent, reason::ReasonBuilder, PropagationActions,
Propagator,
},
solver::{
engine::{int_var::LitMeaning, queue::PriorityLevel},
poster::Poster,
Expand Down
6 changes: 4 additions & 2 deletions crates/huub/src/propagator/array_int_minimum.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::{reason::ReasonBuilder, PropagationActions};
use crate::{
actions::initialization::InitializationActions,
propagator::{conflict::Conflict, int_event::IntEvent, Propagator},
propagator::{
conflict::Conflict, int_event::IntEvent, reason::ReasonBuilder, PropagationActions,
Propagator,
},
solver::{engine::queue::PriorityLevel, poster::Poster, value::IntVal, view::IntView},
LitMeaning,
};
Expand Down
6 changes: 4 additions & 2 deletions crates/huub/src/propagator/array_var_int_element.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::{reason::ReasonBuilder, PropagationActions};
use crate::{
actions::initialization::InitializationActions,
propagator::{conflict::Conflict, int_event::IntEvent, Propagator},
propagator::{
conflict::Conflict, int_event::IntEvent, reason::ReasonBuilder, PropagationActions,
Propagator,
},
solver::{engine::queue::PriorityLevel, poster::Poster, value::IntVal, view::IntView},
LitMeaning,
};
Expand Down
6 changes: 4 additions & 2 deletions crates/huub/src/propagator/conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use std::{error::Error, fmt};

use pindakaas::Lit as RawLit;

use super::reason::{Reason, ReasonBuilder};
use crate::solver::engine::PropRef;
use crate::{
propagator::reason::{Reason, ReasonBuilder},
solver::engine::PropRef,
};

/// Conflict is an error type returned when a variable is assigned two
/// inconsistent values.
Expand Down
12 changes: 8 additions & 4 deletions crates/huub/src/propagator/int_lin_le.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use pindakaas::Lit as RawLit;

use super::{reason::ReasonBuilder, ExplanationActions, PropagationActions};
use crate::{
actions::initialization::InitializationActions,
helpers::opt_field::OptField,
propagator::{conflict::Conflict, int_event::IntEvent, Propagator},
propagator::{
conflict::Conflict, int_event::IntEvent, reason::ReasonBuilder, ExplanationActions,
PropagationActions, Propagator,
},
solver::{
engine::queue::PriorityLevel,
poster::Poster,
Expand Down Expand Up @@ -195,8 +197,10 @@ mod tests {
use flatzinc_serde::RangeList;
use pindakaas::{solver::cadical::Cadical, Cnf};

use super::IntLinearLessEqBounds;
use crate::{solver::engine::int_var::IntVar, Constraint, Model, NonZeroIntVal, Solver};
use crate::{
propagator::int_lin_le::IntLinearLessEqBounds, solver::engine::int_var::IntVar, Constraint,
Model, NonZeroIntVal, Solver,
};

#[test]
fn test_linear_le_sat() {
Expand Down
10 changes: 5 additions & 5 deletions crates/huub/src/propagator/int_times.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use super::{
conflict::Conflict, int_event::IntEvent, reason::ReasonBuilder, PropagationActions, Propagator,
};
use crate::{
actions::initialization::InitializationActions,
helpers::{div_ceil, div_floor},
propagator::{
conflict::Conflict, int_event::IntEvent, reason::ReasonBuilder, PropagationActions,
Propagator,
},
solver::{engine::queue::PriorityLevel, poster::Poster},
IntView, NonZeroIntVal,
};
Expand Down Expand Up @@ -144,8 +145,7 @@ mod tests {
use expect_test::expect;
use pindakaas::{solver::cadical::Cadical, Cnf};

use super::IntTimesBounds;
use crate::{solver::engine::int_var::IntVar, Solver};
use crate::{propagator::int_times::IntTimesBounds, solver::engine::int_var::IntVar, Solver};

#[test]
fn test_int_times_sat() {
Expand Down
9 changes: 3 additions & 6 deletions crates/huub/src/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ use pindakaas::{
};
use tracing::debug;

use self::{
poster::Poster,
value::{AssumptionChecker, ConstantFailure, Valuation, Value},
view::{BoolViewInner, IntView, SolverView},
};
use crate::{
actions::{explanation::ExplanationActions, inspection::InspectionActions},
solver::{
engine::{Engine, PropRef},
initialization_context::InitializationContext,
view::IntViewInner,
poster::Poster,
value::{AssumptionChecker, ConstantFailure, Valuation, Value},
view::{BoolViewInner, IntView, IntViewInner, SolverView},
},
BoolView, IntVal, LitMeaning, ReformulationError,
};
Expand Down
19 changes: 9 additions & 10 deletions crates/huub/src/solver/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ use pindakaas::{
};
use tracing::{debug, trace};

use self::{
bool_to_int::BoolToIntMap,
propagation_context::PropagationContext,
trail::{SatTrail, Trail},
};
use super::view::{BoolViewInner, IntViewInner};
use crate::{
actions::{explanation::ExplanationActions, inspection::InspectionActions},
propagator::{
Expand All @@ -27,10 +21,15 @@ use crate::{
reason::{Reason, ReasonBuilder},
Propagator,
},
solver::engine::{
int_var::{IntVar, IntVarRef, LitMeaning},
queue::PriorityQueue,
trail::HasChanged,
solver::{
engine::{
bool_to_int::BoolToIntMap,
int_var::{IntVar, IntVarRef, LitMeaning},
propagation_context::PropagationContext,
queue::PriorityQueue,
trail::{HasChanged, SatTrail, Trail},
},
view::{BoolViewInner, IntViewInner},
},
BoolView, Clause, Conjunction, IntVal, IntView,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/huub/src/solver/engine/bool_to_int.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pindakaas::{solver::VarRange, Var as RawVar};

use super::int_var::IntVarRef;
use crate::solver::engine::int_var::IntVarRef;

#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub(crate) struct BoolToIntMap {
Expand Down
2 changes: 1 addition & 1 deletion crates/huub/src/solver/engine/int_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use pindakaas::{
Lit as RawLit, Valuation as SatValuation,
};

use super::TrailedInt;
use crate::{
solver::{
engine::TrailedInt,
view::{BoolViewInner, IntViewInner},
IntView, SatSolver,
},
Expand Down
3 changes: 1 addition & 2 deletions crates/huub/src/solver/engine/propagation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ use delegate::delegate;
use pindakaas::Lit as RawLit;
use tracing::trace;

use super::{int_var::IntVarRef, PropRef, State};
use crate::{
actions::{
explanation::ExplanationActions, inspection::InspectionActions,
propagation::PropagationActions,
},
propagator::{conflict::Conflict, reason::ReasonBuilder},
solver::{
engine::trail::HasChanged,
engine::{int_var::IntVarRef, trail::HasChanged, PropRef, State},
view::{BoolViewInner, IntViewInner},
},
BoolView, Conjunction, IntVal, IntView, LitMeaning,
Expand Down
2 changes: 1 addition & 1 deletion crates/huub/src/solver/engine/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) enum PriorityLevel {
mod test {
#[test]
fn priority_order() {
use super::PriorityLevel::*;
use crate::solver::engine::queue::PriorityLevel::*;
assert!(Immediate > Highest);
assert!(Highest > High);
assert!(High > Medium);
Expand Down
10 changes: 5 additions & 5 deletions crates/huub/src/solver/initialization_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use pindakaas::{
Valuation as SatValuation,
};

use super::{
engine::{PropRef, TrailedInt},
view::{BoolViewInner, IntViewInner},
SatSolver,
};
use crate::{
actions::{initialization::InitializationActions, inspection::InspectionActions},
propagator::int_event::IntEvent,
solver::{
engine::{PropRef, TrailedInt},
view::{BoolViewInner, IntViewInner},
SatSolver,
},
BoolView, IntVal, IntView, Solver,
};

Expand Down
6 changes: 4 additions & 2 deletions crates/huub/src/solver/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use std::{fmt::Display, num::NonZeroI64};

use pindakaas::solver::FailedAssumtions;

use super::view::BoolViewInner;
use crate::{solver::SolverView, BoolView};
use crate::{
solver::{view::BoolViewInner, SolverView},
BoolView,
};

#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[allow(variant_size_differences)]
Expand Down
Loading

0 comments on commit 61ff951

Please sign in to comment.