diff --git a/pumpkin-crates/core/src/branching/brancher.rs b/pumpkin-crates/core/src/branching/brancher.rs index 938b67fd7..92e2c0243 100644 --- a/pumpkin-crates/core/src/branching/brancher.rs +++ b/pumpkin-crates/core/src/branching/brancher.rs @@ -1,3 +1,5 @@ +use std::fmt::Debug; + use enum_map::Enum; #[cfg(doc)] @@ -33,7 +35,7 @@ use crate::statistics::StatisticLogger; /// /// If the [`Brancher`] (or any component thereof) is implemented incorrectly then the /// behaviour of the solver is undefined. -pub trait Brancher { +pub trait Brancher: Debug { /// Logs statistics of the brancher using the provided [`StatisticLogger`]. /// /// It is recommended to create a struct through the [`create_statistics_struct!`] macro! diff --git a/pumpkin-crates/core/src/branching/branchers/alternating/strategies/mod.rs b/pumpkin-crates/core/src/branching/branchers/alternating/strategies/mod.rs index 4f39ec1b8..f91638a50 100644 --- a/pumpkin-crates/core/src/branching/branchers/alternating/strategies/mod.rs +++ b/pumpkin-crates/core/src/branching/branchers/alternating/strategies/mod.rs @@ -1,3 +1,5 @@ +use std::fmt::Debug; + use crate::branching::Brancher; use crate::branching::BrancherEvent; use crate::branching::SelectionContext; @@ -7,7 +9,7 @@ use crate::results::SolutionReference; /// Defines methods for selecting which of two branching strategies to use; the default or the /// other brancher. -pub trait AlternatingStrategy { +pub trait AlternatingStrategy: Debug { /// Called when the next decision is made by the [`AlternatingBrancher`]. Returns true if the /// default brancher should be used and false otherwise. /// diff --git a/pumpkin-crates/core/src/branching/branchers/dynamic_brancher.rs b/pumpkin-crates/core/src/branching/branchers/dynamic_brancher.rs index bd8c95f3c..8b0746b20 100644 --- a/pumpkin-crates/core/src/branching/branchers/dynamic_brancher.rs +++ b/pumpkin-crates/core/src/branching/branchers/dynamic_brancher.rs @@ -29,6 +29,7 @@ use crate::statistics::StatisticLogger; /// [`DynamicBrancher::on_solution`] are called at the appropriate times as these methods ensure /// that the index to the current brancher to try is reset. If these methods are not called at the /// appropriate time then it will (likely) lead to incomplete solutions being returned! +#[derive(Debug)] pub struct DynamicBrancher { branchers: Vec>, brancher_index: usize, @@ -37,12 +38,6 @@ pub struct DynamicBrancher { relevant_events: Vec, } -impl Debug for DynamicBrancher { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("DynamicBrancher").finish() - } -} - impl DynamicBrancher { /// Creates a new [`DynamicBrancher`] with the provided `branchers`. It will attempt to use the /// `branchers` in the order in which they were provided. diff --git a/pumpkin-crates/core/src/branching/branchers/independent_variable_value_brancher.rs b/pumpkin-crates/core/src/branching/branchers/independent_variable_value_brancher.rs index 0fe83ce1e..9dec63303 100644 --- a/pumpkin-crates/core/src/branching/branchers/independent_variable_value_brancher.rs +++ b/pumpkin-crates/core/src/branching/branchers/independent_variable_value_brancher.rs @@ -1,6 +1,7 @@ //! A [`Brancher`] which simply switches uses a single [`VariableSelector`] and a single //! [`ValueSelector`]. +use std::fmt::Debug; use std::marker::PhantomData; use crate::basic_types::SolutionReference; @@ -17,6 +18,7 @@ use crate::engine::variables::DomainId; #[derive(Debug)] pub struct IndependentVariableValueBrancher where + Var: Debug, VariableSelect: VariableSelector, ValueSelect: ValueSelector, { @@ -34,6 +36,7 @@ where impl IndependentVariableValueBrancher where + Var: Debug, VariableSelect: VariableSelector, ValueSelect: ValueSelector, { @@ -49,6 +52,7 @@ where impl Brancher for IndependentVariableValueBrancher where + Var: Debug, VariableSelect: VariableSelector, ValueSelect: ValueSelector, { diff --git a/pumpkin-crates/core/src/branching/value_selection/value_selector.rs b/pumpkin-crates/core/src/branching/value_selection/value_selector.rs index 7c446a150..ee2292da6 100644 --- a/pumpkin-crates/core/src/branching/value_selection/value_selector.rs +++ b/pumpkin-crates/core/src/branching/value_selection/value_selector.rs @@ -1,3 +1,5 @@ +use std::fmt::Debug; + use crate::basic_types::SolutionReference; #[cfg(doc)] use crate::branching::Brancher; @@ -17,7 +19,7 @@ use crate::engine::variables::DomainId; /// A trait containing the interface for [`ValueSelector`]s, /// specifying the appropriate hooks into the solver and the methods required for selecting a value /// for a given variable. -pub trait ValueSelector { +pub trait ValueSelector: Debug { /// Determines which value in the domain of `decision_variable` to branch next on. /// The domain of the `decision_variable` variable should have at least 2 values in it (as it /// otherwise should not have been selected as `decision_variable`). Returns a diff --git a/pumpkin-crates/core/src/branching/variable_selection/variable_selector.rs b/pumpkin-crates/core/src/branching/variable_selection/variable_selector.rs index 16e4aef74..34fd85410 100644 --- a/pumpkin-crates/core/src/branching/variable_selection/variable_selector.rs +++ b/pumpkin-crates/core/src/branching/variable_selection/variable_selector.rs @@ -1,3 +1,5 @@ +use std::fmt::Debug; + #[cfg(doc)] use crate::branching::Brancher; use crate::branching::SelectionContext; @@ -14,7 +16,7 @@ use crate::engine::variables::DomainId; /// A trait containing the interface for [`VariableSelector`]s, /// specifying the appropriate hooks into the solver and the methods required for selecting /// variables. -pub trait VariableSelector { +pub trait VariableSelector: Debug { /// Determines which variable to select next if there are any left to branch on. /// Should only return [`None`] when all variables which have been passed to the /// [`VariableSelector`] have been assigned. Otherwise it should return the variable to diff --git a/pumpkin-crates/core/src/engine/constraint_satisfaction_solver.rs b/pumpkin-crates/core/src/engine/constraint_satisfaction_solver.rs index 4841ef3a6..193142b89 100644 --- a/pumpkin-crates/core/src/engine/constraint_satisfaction_solver.rs +++ b/pumpkin-crates/core/src/engine/constraint_satisfaction_solver.rs @@ -204,6 +204,7 @@ impl ConstraintSatisfactionSolver { } fn complete_proof(&mut self) { + #[derive(Debug)] struct DummyBrancher; impl Brancher for DummyBrancher { diff --git a/pumpkin-solver-py/src/brancher.rs b/pumpkin-solver-py/src/brancher.rs index 0ae40e269..88d2e0437 100644 --- a/pumpkin-solver-py/src/brancher.rs +++ b/pumpkin-solver-py/src/brancher.rs @@ -12,6 +12,7 @@ use pumpkin_solver::core::variables::DomainId; use crate::variables::IntExpression; +#[derive(Debug)] pub struct PythonBrancher { warm_start: WarmStart>, default_brancher: DefaultBrancher,