Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pumpkin-crates/core/src/branching/brancher.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Debug;

use enum_map::Enum;

#[cfg(doc)]
Expand Down Expand Up @@ -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!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Debug;

use crate::branching::Brancher;
use crate::branching::BrancherEvent;
use crate::branching::SelectionContext;
Expand All @@ -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.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<dyn Brancher>>,
brancher_index: usize,
Expand All @@ -37,12 +38,6 @@ pub struct DynamicBrancher {
relevant_events: Vec<BrancherEvent>,
}

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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,6 +18,7 @@ use crate::engine::variables::DomainId;
#[derive(Debug)]
pub struct IndependentVariableValueBrancher<Var, VariableSelect, ValueSelect>
where
Var: Debug,
VariableSelect: VariableSelector<Var>,
ValueSelect: ValueSelector<Var>,
{
Expand All @@ -34,6 +36,7 @@ where
impl<Var, VariableSelect, ValueSelect>
IndependentVariableValueBrancher<Var, VariableSelect, ValueSelect>
where
Var: Debug,
VariableSelect: VariableSelector<Var>,
ValueSelect: ValueSelector<Var>,
{
Expand All @@ -49,6 +52,7 @@ where
impl<Var, VariableSelect, ValueSelect> Brancher
for IndependentVariableValueBrancher<Var, VariableSelect, ValueSelect>
where
Var: Debug,
VariableSelect: VariableSelector<Var>,
ValueSelect: ValueSelector<Var>,
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Debug;

use crate::basic_types::SolutionReference;
#[cfg(doc)]
use crate::branching::Brancher;
Expand All @@ -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<Var> {
pub trait ValueSelector<Var>: 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Debug;

#[cfg(doc)]
use crate::branching::Brancher;
use crate::branching::SelectionContext;
Expand All @@ -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<Var> {
pub trait VariableSelector<Var>: 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ impl ConstraintSatisfactionSolver {
}

fn complete_proof(&mut self) {
#[derive(Debug)]
struct DummyBrancher;

impl Brancher for DummyBrancher {
Expand Down
1 change: 1 addition & 0 deletions pumpkin-solver-py/src/brancher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use pumpkin_solver::core::variables::DomainId;

use crate::variables::IntExpression;

#[derive(Debug)]
pub struct PythonBrancher {
warm_start: WarmStart<AffineView<DomainId>>,
default_brancher: DefaultBrancher,
Expand Down
Loading